Two-way XBee radio communication
There are two simple modes for using XBees:
Basic supplies to get started:
I. Choose addressesEach XBee needs four ID numbers: channel (CH), Personal Area Network ID (ID), source ID (MY) and destination ID (DL). To figure out addresses for your two XBees, fill out the following with numbers in the specified range:
II. Configuring the Xbee for serial communication1. Press the first XBee into the XBee Explorer board, connect it to your computer using the mini-USB cable, and run the XBee radio terminal program.
2. To see if the XBee is speaking to the terminal, type "+++" and wait. This command calls the attention of the XBee. You should see "OK" appear
3. Next, configure your XBees by typing in the AT commands. For example to set the CH to 15, type "ATCH=15" then hit return. You should see "OK" appear, which signifies that CH has been set. If not, you may have waited too long before hitting "+++" and sending the next command. If this has happened, imply type "+++" again, wait for the "OK," and quickly enter in your AT command. When you've configured all of the ID numbers, type "ATWR" and then hit return to save it to the XBee.
For example, to configure XBee A using the IDs above, you would connect XBee A, run the XBee terminal program and type in the following:
Then to configure XBee B using the IDs above, you would connect XBee B, run the XBee terminal program and type in the following:
To check that you've configured the XBee ID properly, type the command without a value. For instance to check that CH has been set to 15, you would type in "ATCH" and "15" should appear.
4. After configuring both XBees, they are now ready to be used as "wires" in serial communication. Simply connect the XBees to the microcontrollers by connecting tx to rx (the transmit tx of the microcontroller goes to the receive pin rx of the XBee, and vice versa).
III. Setting up direct input/output communicationThe XBee has 9 input/output pins, 6 of which can read analog values:
(A = analog input; D = digital; I = input; O = output)
ATDn = 2 for analog input
ATDn = 3 for digital input
ATDn = 4 for digital output, LOW
ATDn = 5 for digital output, HIGH
ATDn = 0 for disable
To make an input/output pair, simply enable a pin on one XBee as input and enable the matching (same number) pin on the other XBee as output. For example, to use pin 18 (D2) as digital input on XBee A and digital output HIGH on the XBee, configure using "ATD2=3" for digital input and "ATD2=5" for digital output. If you decide that you don't need such a function, set "ATD2=0" for both XBees. Don't forget to enter "ATWR" to save your configuration! Following the example, in the terminal program,For XBee A, you would type:
For XBee B you would type:
Note that digital output pins can be set to output only LOW or only HIGH. Once this is set, when XBee A sense a HIGH input, XBee B will output HIGH.
After configuring the XBees, you simply need to complete your circuit, and power the XBees. In my messenger cranes project (see week 12), I used the direct input/output configuration and a 3.7V li-ion battery.
Back to index