SoftwareSerial Problems with XBee Radio [SOLVED - No solution sadly...]

I'm using an XBee radio with an Arduino Uno. I can get data to transmit between the radios, but there's something funky going on with the Arduino side. First if I send the value 0 (not the character '0') the Arduino receives the value 128. Then if I send 1 through 15, I get 129 through 143, but as soon as I send 16 the Arduino receives 128... This is an Arduino side problem, if I use a FTDI serial to usb converter with the XBee I receive the right data. I've tried this on multiple Arduinos, they all get the same data. Has anyone run into this before? Is there a simple way of fixing this? I've tried inverting the signal (3rd argument in the SoftwareSerial constructor), but that didn't do anything productive... Could this be an ordering problem (as in bits or endianess)?

I'll tell you what the problem is. The problem is you haven't posted your code.

Read this before posting a programming question

And no, you don't order an Arduino with a particular endian-ness.

Wow seriously? Why the attitude? No wonder my collegues told me not to ask questions here… I apologize for not posting my code…but your a moderator, act like it.


//Software Serial Header
#include <SoftwareSerial.h>

//Global Variables
int tx_pin=10;
int rx_pin=11;
SoftwareSerial xbee_radio(rx_pin,tx_pin);

void setup()
	//Setup Serials

void loop()
	//Check Xbee Radio
		//Get a Byte From Xbee Radio

		//Print Byte to Serial

I wasn’t asking if I could order an Arduino with a certain endianess, I was asking that, since I am sending bytes on a big endian machine, if this could be a problem with the atmega being a little endian chip. I do not find it coincidental that this “reset” only happens when I send bytes that are multiples of 16…this sounds like a bit swapping problem…

I’ve tried switching the TX and RX pins, wondering if that could be the issue, but nothing changed when I switched to pins 2 and 3 (which are common on all the tutorials I’ve read).

Wow seriously?

Yes, seriously. You come into the programming forum, where we discuss programs, and didn't post yours. If you expect help, that is the minimum you need to do.

Why the attitude?

What attitude? Nick sounded quite reasonable to me.

No wonder my collegues told me not to ask questions here.

Perhaps they meant "without posting code!".

but your a moderator, act like it.

And exactly how would that be? If I'd answered first, I'd have said exactly the same things.

You've posted code on one side. That's not enough. What is sending the data to the XBee? What kind of XBee is it? How is it configured?

Now, about your code:


Why do you feel it necessary to cast an int to an int?

How about something like:

Could you post your code? It helps us help you, and its a rule (stickied post).

Instead of something that made me feel completely unwelcome. All the post did was start a debate that had nothing to do with the question. And yes, I could have read the sticky and followed the rules. But I do not believe in adding gasoline to the flame, hence why I apologized...

On the computer side I've used Hyperterminal on a Windows machine, I've echoed straight to the file descriptor on a Linux machine, and I've used a serial program that I wrote in c++. They all have the same result with the Arduino. If I connect the radio on the Arduino to another computer, and send data between the radios (without the Arduino, just with two computers) then I do not see these problems.

The radios are set to 57600 baud and they have the same pan id. I'm sending and receiving at 57600 baud on both the computer and Arduino sides. I am using these XBee radios. I can change to a different set of XBee radios, but I do not believe this will fix much, because the radios are sending and receiving fine between the two computers.

I originally had the recv variable typed as a character (because it was a character the arduino was receiving). I was casting to an integer so I could see the value of the character. I changed it to an integer just to see if there was an overflow/underflow problem (since sending 0 gives me 128). I guess I didn't get rid of the type cast that is no longer required.

EDIT: This is a SoftwareSerial problem. If I use the hardware serial everything works fine. In SoftwareSerial.cpp (in the Arduino includes folder) you can play with the 16 mhz timing table and try to get this to work...I haven't got it working I'm just going to stick with hardware serial for the time being...