xbee is not transmitting

Hi guys,

I am using 2 xbee pro s2b modules. The one is configured as Router and it is connected on an Arduino Uno through a shield, which will be used to send data. The other one is configured as Coordinator and is connected directly on a computer which will be used to receive data.

I have changed the position of the switch on the xbee shield so it uses the pins 2 and 3 for RX and TX.

My Code:

#include <XBee.h>
#include <SoftwareSerial.h>

// Define SoftwareSerial TX/RX pins
#define ssRX 2
#define ssTX 3
SoftwareSerial nss = SoftwareSerial(ssRX, ssTX);

//Create an XBee object
XBee xbee = XBee();

//Define the Destination address of the packets
XBeeAddress64 destaddress = XBeeAddress64(0x0013A200, 0x406F1997);

char Hello = “Hello World\n”;

void setup()

//We hook the XBee into the Software Serial

Serial.println(“Goodnight moon!”);

void loop() // run over and over
Serial.println(“in the loop”);
ZBTxRequest zbtx = ZBTxRequest(destaddress, (uint8_t *)Hello, strlen(Hello));

Output of the code:

Goodnight moon!
in the loop
~ }3¢ @o -?ÿþ Hello World

My problem is how can the “Hello World” message be displayed on the Serial Monitor when it should be transmitted to the other xbee?

I haven’t written any code for the xbee that receives data, but i used the Terminal tab of the x-ctu program to check for any incoming data. Nothing was received.


This looks like you're using the wrong XBee library. You have to get the latest that has been updated to use software serial. I can't remember where I picked it up, but I think it was here: https://code.google.com/p/xbee-arduino/ on the downloads page. They also recommend using altsoftserial, but I don't for my stuff because it limits which pins can be used and 9600 is plenty fast for my stuff.

Wow! It worked like a charm! Thank you draythomp!

The other day I was getting an error that the setSerial() couldn't be recognized and a guy told me to download a newer version of the XBee library and so I downloaded the newest i could find. I guess there was an even newer version than that to solve this problem, too.

~.....}3..@o......Hello World..

This is the output of the transmitted data that was displayed on the x-ctu program. I only sent the "Hello World" message, why are the rest of the characters there? Because I will be sending the string data that is generated from the GPS so, I wouldn't like any irrelevant characters in the string.

What you’re seeing is the entire API packet. Check out the XBee user’s guide and you’ll see all the stuff like the start sentinel, length, frame type, etc. The extraneous stuff is actually necessary to get the packet to where it’s actually going. There a lot of things you need to know that would probably bore the other readers of this thread, and I think I summed them up on my blog. So, go there, prowl around a bit, and then ask any left over questions you have. Sound fair? Start here <link>

You’ll be most interested in the stuff I have on using the XBee library.

Brilliant! Thank you!