Sunday, January 31, 2010

Connection XBee Series 2 (AKA ZB Pro/ZNet) to an arduino

My goal was to have two xbee series 2 modules communicate to each other in a two way configuration.  I found the the various instructions on the internets to be confusing and hard to follow (but then again, I am no Rocket Surgeon).

My first mistake happened before I even got out of the shoot.  From what I have read, the series 1 xbees are way easier and probably better suited for this task.  But that is not what I ordered.  sigh.

My second mistake was only ordering one communication cable (intending to use my Arduino for the other side of the communication).  The cable is way useful and easier to use and works with the X-CTU (the xbee configuration utility) without any additional monkeying around.

Nevertheless, I am nothing if not determined (yes, I am slow as a frozen turkey when it comes electronics, but I do eventually get the job done).

Here is my setup:

Step 1: Configure the XBees
  • Grab the XBee control software (X-CTU) from Digi
  • Plugin one of the modules using the USB to TTL-232 cable and set it up to be the Coordinator (ZNET 2.5 Coordinator AT)
  • When first starting, setup the xbees to send and receive from any other compatible ZNET device (running at the same frequencies, etc) by setting
    • Destination Address High (DH) to be zero (0), and
    • Destination Address Low (DL) to be FFFF.
  • Pick a PAN ID (it doesn't matter, just so long as you use the same id on both xbees)
  • Write the configuration changes to the xbee (at the point, I hooked up this xbee to my arduino running the sample soft serial program in the NewSoftSerialLibrary).
  • Plugin the second xbee module into the USB to TTL-232 cable and set it to be an End Device (ZNET 2.5 ROUTER/END DEVICE AT)
  • Set the DH and DL as above
  • Set the PAN ID to the same id as above
  • Write the configuration to the device
  • Now use serial terminals to send packets between the modems. (I like putty, but the built-in terminal emulators in arduino and the X-CTU programs will work as well).
Finally, the blinky lights on the xbee adapter kits can tell you about state of the xbee modules.  You really want to see the green LED blink constantly.  The red LED will light to indicate when data is being received (as far as I know).

And there you have it.

The resources which I found useful in this little endeavor: