Using 2 xbees Series 2 and arduinos

arduinoxbee

I have 2 xbee series 2s that I want to talk to each other with ardunios. I have the ardunio xbee shields but I can't find any good resources on how to get them to communicate together. So how would I configure these to communicate with each other? As a lot of the resources i've found use the typical sparkfun shield/breakout board on another pin.

Best Answer

Series 2 is also pre-configured for 9600 bps, AT mode. PAN ID in the ones I have was 234, but YMMV. You will need a Windows computer with X-CTU software to set one of the XBees as coordinator (I'm guessing your problem is that they're both configured as "end devices" out of the box).

If you have the XBee explorer dongle, fine. If not, you can put the XBee in the Arduino shield and mount it on an Arduino, just remove the processor from the Arduino beforehand, so that it does not interfere with the serial signals.

The steps afterwards: fire up X-CTU, select the serial port for the Arduino/XBee shield, go to Modem Configuration, click on Read, and take note of the firmware version, e.g. ZNET ... Router/End device. Take note of the Serial numbers too (SH and SL). Change the PAN id (ID parameter) to something you like, and give the XBee a name (in the NI parameter, take care to delete the space that is there by default). Click on "Write".

Then, with the other XBee, do the same. Set the same PAN id, give it another name, e.g. "coordinator", then change the firmware to "ZNET ... Coordinator" (the ZNET part can be also something else, but must match in both XBees). Click on "Write".

Once done, make sure to have both XBees powered on, and plug the coordinator XBee to a computer. In X-CTU, go to the Terminal tab, and type +++ (type, not copy-paste. The tiny pause between keypresses plays a role). You should get "OK" back. now type ATND you should get a list that shows the other XBee's name, address, and some other infos. When you get to that point, you know they are talking to each other. From that point on, put the processor back into the arduino and use the xbee-arduino library from Andrew Rapp. Note that before using the library, you will need to use X-CTU again on both XBees to set API mode 2 (parameter AP, value 2). Do that only after you're certain the communication works, otherwise you'll have difficulty finding out where the problem is.

Remember, the Arduino canot be programmed with the shield on (or at least some jumpers or a switch on the shield have to be moved).

Check here for a list of resources & debugging tips I found useful: http://erion.elmasllari.com/topics/arduino-projects/

Cheers & good luck!