Research & Learning
Other Class pages
This tutorial is intended to provide information for getting started with XBee and XBee Pro 802.15.4 modules.
XBee radios are 2.4GHz radio transceivers that can be used in two ways. They can be used as pass through data modems, to send serial data from one computer or microcontroller to another. They also have their own digital and analog I/O pins on board that you can use to collect sensor data or to control remote devices. They are addressable, so you can set up a network of several radios as well.
When used as serial radios (called serial mode or AT mode), they simply take in whatever comes in their serial input and send it out over 2.4GHz radio waves to a destination radio. When used as standalone devices with sensors or actuators attached (called API I/O mode), they gather data from their inputs and transmit it using their API protocol. They can also receive transmissions that set their output pins using this protocol.
You generally choose to work in either API mode and AT mode and can't use both at the same time. However the exception is that even radios running in AT mode will still produce API-formatted packets when they receive I/O information from other radios set up as standalone sensors.
There are several varieties of XBee radios, the Series 1 radios (also called the 802.15.4 OEM Modules), the Series 2 radios (also called the ZigBee OEM Modules). This tutorial deals only with the 802.15.4 modules, which are the easiest to start with.
For this lab you will need to have the following parts:
1. Connect an XBee to your personal computer via USB
There are two ways you can do this. You can use a pre-made USB-to-serial board like the Xbee Explorer shown here:
Or you can build your own USB-to-serial adaptor using an XBee breakout board and a USB-to-serial adaptor as shown below:
Set up a breadboard as shown in the photos below:
The above images show an XBee Module connected to a FTDI USB-to-serial adaptor. The USB adaptor draws power from the USB bus, and the XBee draws power from the adaptor via its 3.3 voltage output. Note that the adaptor shown is an older model, and the pin positions on newer models have changed. Check the datasheet on the model you bought, and connect the XBee's transmit pin (TX or DOUT) to the adaptor's receive pin (RX or DIN) and vice versa.
Important: XBees can only take 3.3 volts max. Always check to see that your voltage is not above this level before you put your XBee into your board.
Once you've got the XBee module's circuit built and powered,The LED on pin 13 should stay on steadily, and the LED on pin 15 will blink. The former is lit (LED is on) when the module is active. And the later blinks when the radio is associated with a network (LED blinking) or not (LED on steadily). Make sure your circuit is connected to your computer and open Processing (you can also use your favorite serial terminal program if that is more familiar).
2. Configure the XBee Modules Serially
The next thing that needs to be done to start using your XBees, is to communicate with each radio module serially in order to set its local address and destination address.
XBee AT commands are all terminated by a carriage return ('\r', or ASCII 0x0D). If your terminal program allows you to set the string terminator (i.e., the characters sent when you press return), set it to 0x0D. CoolTerm allows you to do this, and is cross-platform. Here's a screenshot of the Options panel from CoolTerm, set up to work with XBees:
If you can't use CoolTerm, Tom Igoe has written an XBee Serial terminal for processing that makes things easy by printing newlines for return characters. Download it here and open it up in Processing. Make sure the sketch is working.
There is one thing that you might want to do before you start serial communication. Get a piece of tape (masking tape works well) tear off a small square and stick it on your XBees. (you don't have to remove it from the board you just built). With a marker, give your XBee a number. "1" works well. This will be your XBee's id and will be used later when you program it. Go ahead and label your second XBee, "2".
Now that you've named your individual XBees, you need to set up a PAN ID for them. All radios with the same PAN ID can talk to each other and ignore the radios on a different PAN ID. Go to the PANID page Choose a series of letters or numbers-- hopefully ones you can remember, and input them on the page so that someone else at ITP won't be trying to talk on the same network as you.
Now we're ready. In order to program the XBee, you first need to put the XBee is in command mode. Xbees essentially have two modes:
You put the XBee into command mode by typing "+++" (that's plus, plus, plus without the quotes, and WITHOUT hitting a return afterward).
Try programming the XBee by clicking on the processing sketch and typing the following commands:
Congratulations, you have just configured your First XBee. Wondering what all of that stuff meant? To program an XBee, you use "AT" commands. Some of the ones we just used are described below:
Commonly Used XBee "AT" Commands
Typing only ATID and hitting return will output the current address for the XBee you are programming. To actually change the address, you will need to enter the AT command, followed by the ID you wish to set. So, you would enter: ATID1437(or whatever you choose for your PAN) and then hit return.
You just did the following commands for Radio 1 (in Column 1). You will now need to do the commands for Radio 2, to program it.
Quit the Processing sketch, and unplug your board from your computer. Next, remove the XBee from the circuit, insert the second XBee and configure it using the same procedure as listed above. Change ATMY to 2, and ATDL to 1. Don't set the radio's destination address to the same value of its source address, or it will talk only to itself.