First shot at using Xbee…

Yesterday, I got delivery of my Xbee modules from sparkfun, and decided to try to see if I could do something with them. My ultimate goal is to use them to connect my satellite tracker to a PC which is hooked to the Internet so that the tracker can automatically receive updates to orbital elements and the like. But for the evening, I decided to just see if I could get them to work at all.

First of all, the equipment I ordered:

  • 2 x Xbee Series 1 modules, 1mw, with chip antennas
  • An Xbee Explorer, to hook the module to a PC.
  • An Xbee shield, for piggy backing an Xbee onto the Arduino. I should have read the product description carefully: you’ll need to add some headers to actually connect it to an Arduino board: luckily, I had a proto shield I hadn’t assembled, so I swiped those, and then ordered some spare ones from sparkfun.

(Instead, you could just have ordered this retail package and gotten all of the above, including the headers you need.)

Okay, you’ve got all that in front of you, what do you do? Well, you solder the headers in place. I plugged the new headers into another shield, put the board on top, and then quickly soldered the 28 connections. A quick inspection revealed my normally fair soldering had left a cold joint or two, which I touched up.

What next? Configuration! I plugged an Xbee into my Xbee Explorer, and configured it. About half the tutorials I read downloaded the Xbee configuration utility X-CTU, but as I started that, I realized it was over 48 megabytes. Pffft! Just to set a few bits in the microcontroller? Other utilities mentioned that you could use something like the old Hayes “AT” command set to configure them using just a terminal program, so that’s what I did.

I fired up PuTTY, told it to talk to the serial port, and turned on echo. I then configured the 16 bit ID for the module by typing “ATMY1234”, the 16 bit destination by setting “ATDL5678”, and the network id by “ATID1111,”. Each entry echoed “OK”. I then typed “WR” to write the results to EEPROM on the Xbee.

I then extracted the first Xbee module and plugged it into the shield. I then programmed the second one, but instead told its ID was 5678 (ATMY5678) and its destination was 1234 (ATDL1234). I programmed the same network ID and wrote it to the Xbee module.

Okay, now what? Well, I left PuTTY running on the PC with the USB Explorer. I powered down my satellite tracker and detached the current maze that connects to the breadboard containing the RTC, and then plugged in the Xbee Shield. I then reconnected the RTC clock and powered on the new stack.

No smoke. No fire. Lights blinking. Clock seems to work as before.

And staring over at the PC, the status messages that previously had appeared via the serial monitor are now going out over the wireless to an entirely different PC. Success! First try!

My use case was very simple: I really just wanted to eliminate a wire in the simplest way possible. Xbee is very easy to configure to do that. In fact, you can develop your entire sketch for the Arduino without any concern for Xbee at all: just use the serial port. In my case, I want to create an application (probably in Python) to periodically fetch elements and feed them to the tracker at intervals). I can use PySerial to talk directly to the Arduino, and not worry about the wireless at all. When I’ve got that all debugged, I just plug in the Xbee shield, plug in the Xbee explorer to the PC, and everything works exactly the same (no software changes at all).

Of course, my use case is pretty simple, and Xbee can do a lot more. It can (for instance) monitor a set of analog/digital pins, and automatically beacon them to another xbee module, all without any microcontroller at all. Or you can configure a couple of pins as output, and signal them. There are various broadcast modes you can use. Cool stuff.

If you want to deploy and Arduino + Xbee together, there might be a cheaper way to go: the Arduino FIO. (I have one of these from osepp.com.) Cool thing is that they have an Xbee socket mounted underneath it, and include a battery charge circuit so you can attach a lithium polymer battery to it, and charge it via the mini-USB connector. Not so cool? The USB plug isn’t for programming: you’ll need an FTDI cable to program it (which is a bit of expense up front). It also doesn’t have the standard Arduino footprint, so you are out of luck if you want to use standard shields. Still, I think I can find some use for it.

Satellite Tracker Update: I think I have a slow memory leak somewhere. After running for several hours, my tracker simply halts. By printing status messages, I found that it wasn’t the Gameduino which was locked, it’s the Arduino. I’ll instrument it a bit more carefully and do some debugging. I might also institute a watch dog timer reset to blunt the problem. Stay tuned.

Addendum: If you need some additional help, you might try using Jeremy Blum’s Arduino tutorial videos, which shows the process step by step. I watched these a couple of days ago, and while I didn’t refer to them again while setting this thing up, I essentially followed his exact steps, including the use of PuTTY. Jeremy also did an awesome appearance on the ZombieTech podcast. He’s a very talented guy.