dsc_0005_crop

A while ago I picked up a pair of Series 2 Xbee modules, an Arduino Xbee shield, and a Xbee USB Explorer.  My first mistake was buying the Series 2 Xbees (AKA Zig 2.5), which are more complicated to setup. I had trouble getting this setup working, since the documentation is sparse, and forum post info is fragmented – so I figured I’d share how I got it working.

My hardware setup was one Xbee plugged into the Xbee Explorer, connected to the computer (for sending data with Processing), and one plugged into an Arduino (to control LEDs and servos)

Even for simple Xbee to Xbee communication over serial, you’ll need to flash the firmware of both units using the X-CTU software from Digi. Blah. This is a PC only software so you’ll need a Windows machine, or a virtual machine running on a Mac. Ugh. You’ll also need to be connected to the web to download the firmware files. Fun times.

I found that if I plugged each Xbee into the USB Explorer, then plugged that into the PC, it could read and write to the devices. To make sure it was communicating, I’d hit ‘Test / Query’ in the PC Settings tab.  The default Baud of 9600 should work for a brand new Xbee, since it comes set at 9600 (more on setting the baud later). 

There are a couple of things you will need to configure on each Xbee they can talk to each other.

Select Modem Config tab. Click Read to pull in the current values from the Xbee.

For the Xbee that would be on the Arduino:

I set the firmware type to be flashed as an End Device (ZNet 2.5 Router / End Device AT), by selecting that from the dropdown.
Set the ID (PAN ID) to whatever number – both Xbees need to have the same PAN ID to be able to talk. I used 999.
Copy down the values shown in SH and SL. These are unique identifiers for this Xbee. 
Check “Always update firmware”, then hit Write. This will flash the firmware.
My Xbees seemed to reset / reboot when X-CTU told them to, so I didn’t even need to unplug them to reset them.

Now swap out the Xbee to the one that would be plugged into the Computer:

This Xbee will be configured as a Coordinator.
Set the firmware type as a Coordinator (ZNET 2.5 Coordinator AT)
Set the PAN ID to the same number as the ID you set on the other Xbee
Set DH to the SH value you copied
Set DL to the SL value you copied.
The DH and DL values tell this Coordinator Xbee to talk directly (and only) with your one other Xbee. I believe this is a unicast system. 
Check “Always update firmware”, then hit Write. 

The Coordinator should be connected to the computer using the USB Explorer, and the End Device Xbee should be plugged into the Xbee Shield. With external power hooked up to the Arduino, make sure the jumpers are set to Xbee (not USB) When you hit reset on the End Device, you should see a green LED on the Coordinator labelled RSSI light up for a little while. And the End Device Xbee should have a blinking orange LED (twice a sec) If you’re lucky, it will work. Very possibly it won’t

You should now be done with the hardware config (unless I forgot about something critical) – important to note is that the Xbees are setup for 9600 baud. You’ll want to setup your Arduino and Processing sketches to the same value or nothing will work.

You can now output your serial data to the Coordinator Xbee and the End Device will receive it and pipe it to the Arduino transparently. There are plenty of examples / posts on the web on how to send serial from Processing to Arduino, so I won’t cover that.

—————–

To set a higher baud rate, change the value in the Modem Config screen of X-CTU. I had trouble getting a definitive answer on the top speed of the Xbee, but from my research 38400 seemed safe. You won’t need to Update the firmware, so uncheck that, then hit Write.

Do the same for the other Xbee, and set the variables accordingly in Arduino / Processing etc. Note that now you’ve changed the device’s baud rate, in order for X-CTU to talk to it any more, you’ll need to change to the appropriate value in the ‘PC Settings’ tab.Hit ‘Test / Query’ to see if it works.

Things to note:
If you find yourself unable to communicate with an Xbee after flashing the firmware, the Xbees may have reset to their default 9600 Baud rate, or you may have changed it intentionally. Try switching X-CTU back to 9600 (or to whatever value you set) and hit ‘Test / Query’

You’ll want matching Firmware versions (1047 with 1247) (1041 with 1241)