The Arduino Wireless Shield allows your Arduino board to communicate wirelessly using ZigBee. This documentation describes the use of the shield with the XBee® ZB ZigBee® RF Modules module. The XBee® ZB ZigBee® RF Modules and the XBee® 802.15.4 OEM RF Modules are not compatible over-the-air because they use different chipsets. In particular in XBee® 802.15.4 OEM RF Modules implements the 802.15.4 protocol while the the XBee® ZB ZigBee® RF Modules implements the ZigBee protocol or the ZNet 2.5 protocol. Digi International continue to support both ZigBee and Znet 2.5, so you are free to use either on the Series 2 radios. Remember that only radios with the same type of firmware can communicate with each other.
The Xbee 802.15.4 modules support point-to-point or multipoint communication without routing, so they are ready out of the box to establish peer communication between two radios without any configuration.
The XBee with ZNet 2.5 or ZB firmwares are designed to form networks with star, cluster tree or mesh topologies, where there is a hierarchy of devices and one coordinator is always necessary. Simple peer-to-peer communication with these modules is therefore more complicated than with the 802.15.4 modules. Each ZB module must have its firmware configured as coordinator, router, or endpoint before you can begin communication.
In a ZigBee network there must be only one coordinator that manages all the network. There can be several routers attached to each coordinator and many end devices that can communicate directly with a coordinator or pass messages to other end devices through router and the coordinator. Though each module must be configured for a specific role, the advantage is that you can form wider networks than you can with the 802.15.4 modules. The ZigBee protocol allows you to set up a radio link between the modules that are distant from each other by sending messages through multiple routers from endpoint to endpoint. You can also make networks in which the endpoints save power by sleeping, but don't lose messages when asleep.
To enable simple communication between two ZB radios, you'll need to configure one with the coordinator firmware, and one with router or endpoint firmware. The next section shows you how to do this.
These instructions show you how to get two Arduino boards talking to each other over ZB radios using Wireless Shields.
To configure a ZB module as coordinator, router, or end device, you'll need to change the firmware. You need Digi's configuration software, X-CTU, to do this. Unfortunately it's only available for Windows. Download it from this link.
If you are running a Linux, you can install X-CTU trough Wine. You'll need to create a link from the Arduino device on which the radio is mounted to the Wine dosdevice directory. To do so, open a terminal windows and type:
ln -s /dev/ttyUSBx ~/.wine/dosdevices/com1
or
ln -s /dev/ttyACMx ~/.wine/dosdevices/com1
To configure the modules from the computer, put the serial switch to the USB position and upload an empty sketch, like this:
Then mount the radio on your Wireless shield.
Open the X-CTU sofware and type the Arduino XBee module's COM port number into the "Com Port Number" field. Then click the Add button. The COM port you created will appear in the two text boxes on the left. Select both and then click the "Test / Query" button, will appear a screen like this:
The settings that are most important are the PAN ID (ID)and the serial number high word (SH) and low word (SL). Radios which share a PAN ID can communicate with each other. Radios on different PAN IDs will ignore each others messages. The Serial number consists of two 16-bit numbers, stored in two addresses: SH (serial high) and SL (serial low). This is the radio's unique address, and is used to send messages to it. In the settings below you only need to change the PAN ID. Use the same number for both radios so that they can communicate. Read the SH and SL parameters and take note of them, because you'll need to tell the coordinator this address in the next step.
Now the end device configuration is complete. Check the "Always Update Firmware" in the check box and press "Write" button, and the configuration will be uploaded on your module. If you are unable to read these parameters from the list, you can go in the "Terminal" tab and type three plus signs: +++ to enter in the configuration mode, then type ATSH an ATSL to get the serial number from the module, the module will answer like below:
Send Command | Expected Response | What it does |
+++
| OK <CR>
| Puts the radio in command mode |
ATSH <press Enter>
| 13A200 <CR>
| Reads the serial number high word |
ATSL <press Enter>
| 407B0E9F <CR>
| Reads the serial number low word |
You can also configure the PAN ID like so:
Send Command | Expected Response | What it does |
+++
| OK <CR>
| Puts the radio in command mode |
ATID1111 <press Enter>
| OK <CR>
| Set the PAN ID to 1111 |
ATWR <press Enter>
| OK <CR>
| Save the new configuration to flash memory |
Mount the second module on the Wireless Shield socket and repeat the procedure for connecting to X-CTU. Click on the "Modem Configuration" tab and click the "Read" button. This module should be recognized with the XB24-B firmware and you have to change its function switching it on "ZNET 2.5 COORDINATOR AT". The version number will change to 1047. Now you have to do three simple things:
As for the previous module, the configuration is complete, you must only check the "Always Update Firmware" in the check box and press "Write" button and the configuration will be uploaded on your module.
Note that you didn't have to set the end device's destination address. That's because the end device always speaks to the coordinator. The modules now form a network. The coordinator is managing only one end node, so it's as if it were a transparent serial communication. You should be able to get two Arduino boards with Wireless Shields talking to each other using just the standard Arduino serial commands (described in the reference). Following is an example.
To upload a sketch to an Arduino board with a Wireless shield, place the switch in the USB position. Then, you can upload a sketch normally from the Arduino environment. In this case, upload the Communication | Physical Pixel sketch to one of the boards. This sketch instructs the board to turn on the LED attached to pin 13 whenever it receives an 'H' over its serial connection, and turn the LED off when it gets an 'L'. You can test it by connecting to the board with the Arduino serial monitor (be sure it's set at 9600 baud), typing an H, and pressing enter (or clicking send). The LED should turn on. Send an L and the LED should turn off. If nothing happens, you may have an Arduino board that doesn't have a built-in LED on pin 13 (see the board index to check for sure), in this case you'll need to supply your own.
Once you've uploaded the Physical Pixel sketch and made sure that it's working, unplug the first Arduino board from the computer. Change the switch to the Micro setting. Now, you need to upload a sketch to the other board. Make sure its switch is in the USB setting. Then upload the following sketch to the board:
When it's finished uploading, check that it's working with the Arduino serial monitor. You should see H's and L's arriving one a second. Turn off the serial monitor and unplug the board. Change the switch to the Micro setting. Now connect both boards to power. After a few seconds, you should see the LED on the first board turn on and off, once a second. (This is the LED on the Arduino board itself, not the one on the XBee shield, which conveys information about the state of the XBee module.) If so, congratulations, your Arduino boards are communicating wirelessly.
The Xbee module on the shield is set up to work at 9600 baud by default, so unless you reconfigure it, you'll need to make sure you're passing 9600 to the Serial.begin() command in your sketch.
If you want to deepen in the configuration and networking with ZigBee using XBee Series 2 modules we recommend that you read the book by Robert Faludi: Building Wireless Sensor Networks, published by O'Reilly.
For more information, see: the hardware page for the Xbee shield, and the Digi Xbee page. The text of the Arduino getting started guide is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain.