Configuring the XBee radios

 

The XBee radios use an ‘AT’ command set. This is a throwback from the days when computers connected to each other over phone lines using acoustic couplers at 300 baud. You only have to do this once per chip, though, so it’s not too bad.


To configure an XBee radio, seat it in the XBee Explorer board and connect the board to a USB port on your computer. Start a terminal emulation program on your computer. (I used ZTerm on the Macintosh.) You will need to tell your program what device (or port, on Windows) with which to communicate. If you’re running Windows, this is the com port that the XCTU program found. On Macintosh, look for something like “tty.usbserial-A7004nsc” in the /dev/ directory. Default communications settings are 9600 baud, 8 bits, 1 stop bit, no parity bit, no flow control.


In the following discussion, ‘>’ indicates what you type and ‘<‘ indicates the response. Other than the ‘+++’ string, end all your entries with <return>.


Once you establish communications between your computer and the XBee, type

>   +++

(That’s three ‘+’ symbols, with no return.) If everything is working, the XBee will respond:

<   OK

If you wait more than 10 seconds between any commands, the XBee will drop out of the communications mode until it again receives the ‘+++’ string. If this happens, it will ignore your commands, you won’t see the “OK” after your commands, and you must put the XBee back in command mode by sending ‘+++’ again.

Next set the baud rate to something higher. I used 115,200 baud:

>   ATBD7

<    OK

After this, you need to set your communications speed to 115200 on your terminal program also!


The next step is to configure the XBee radio and sampling rate. Let’s have this first radio be the base station that will attach to your computer. First, set the network ID to something unique:

>    ATID1234

<    OK

(Replace ‘1234’ with some 4-digit hexadecimal number.)

Next set the radio’s address on that network:

>    ATMY0

<    OK

Finally, write these changes to more permanent memory on the XBee:

>    ATWR

<    OK


You may now disconnect that chip and put in the XBee that will be used as the “remote” chip. Put the chip in command mode:

>    +++ (no return!)

<    OK

Set the baud rate, the network ID, and the address. The network ID must be the same as the base station’s, and the address must be something different than that of the base station.

>    ATBD7, ID1234, MY1

<    OK

Also tell the remote chip the address of the base station:

>    ATDL0

<    OK

Next, configure the remote chip to take data from the A/D lines. The following lines will set the XBee to take measurements from A/D inputs 0, 1, and 2:

>    ATD02, D12, D22

<    OK

Set the sampling interval in milliseconds:

>    ATIR5

<    OK

Set the number of samples per “packet” to send back to the base station:

>    ATIT1

<    OK

And finally write the changes to memory:

>    ATWR

<    OK


Remember, if you DON’T get the ‘OK’ after commands, the chip probably dropped out of command mode and you should once again give it +++ (without a return) to get its attention.


You can also check settings by giving AT commands without parameters. The chip will reply with the current value of that setting.

>    ATID

<    1234

This picture has nothing to do with the topic at hand. It’s pretty, though. I took it in Fern Canyon, near Prairie Creek Redwoods State Park, while camping there with my family.