This is really more about the XBee than the shield, but we'll cover some of the different types of shields first. All are typical shields, or at least most are, but there are one or two odd ones. First, the way the shield brings serial pins to the XBee. The Sparkfun shield gives you the choice of either the USART or pins 2 and 3 for transmit and receive. A switch chose between the USART or the pins. In addition, there were solder jumper pads that could be opened to disconnect pins 2 and 3, so that you could use whichever pins you wanted. More recent boards, like the TinySine (upper left) attempt to duplicate that functionality, but hardwire the sofware port at pins 2 & 3, the two interrupt pins. Others, like the generic board (upper right) give you the choice of connecting the MCU to either the USB or the XBee. For them, you need to flip the switch to program the Arduino. It is a little unhandy, and what if you need to use a software serial? Too bad. At least with all of the boards you can directly program the XBee using XCTU without a USB Explorer adapter.
A second kind of difference is in the way the shield plugs into the Arduino. Some must be the top shield, some can be other than the top shield. Some mount the XBee sideways and hanging out over the edge, while others line the XBee up on the axis of the Arduino. Some of the shields with sideways-mounted XBees only have two of the Arduino I/O connectors, power and lower digital. There isn't even any circuit board at the other end. You can't stack it with another board on top. Some don't have through connectors on them, but use typical single-row male headers to attach to the Arduino and standard female single-row headers for the next higher board. But you can't use the next higher board because the XBee antenna is in the way.
All this to say you have to really look at the XBee shield to make sure it can do everything you need it to do.
XBees come in many flavors, but it really boils down to three decisions on your part:
The choice of power comes down to three values - XBee @1mW (300ft), XBee ZigBee @ 3.1mW/6.3mW (4000ft) and XBee Pro @ 63mW (2mi). Those ranges are based on open, line of site testing. If you just need it to get around in your back yard, the XBee may be fine, and it will be a lot cheaper than the Pro. The XBee ZigBee costs about the same as the XBee, but has three to six times the power. The Pro versions, which give you that 2 mile range are a different breed. They deliver quite a bit more power, but they use nearly 1/4 amp during transmit.
The antenna choices are similarly broad.
The wire and the PCB antennas are probably adequate for most around the house uses, but to get out farther you will want an antenna with some gain. The RPSMA connector allows you to connect a standard 2.4GHz antenna to the XBee, but now what do you do to package it? The U.fl connector allows you to use a pigtail cable that has a panel mount RPSMA connector, so you can mount an antenna on the box somewhere.
The XBee 802.15.4 (S1 modules) will communicate out of the box, like a point-to-point modem. The ZigBee modules will not. They don't know what they are yet. It is very easy to configure the XBee ZigBee units to communicate with each other point-to-point. The process is described below.
|XBee 1mW (S1)||XBee 63mW (S1 PRO)||XBee ZigBee 3.1mW (S2C)||XBee ZigBee Pro 63mW (S2C PRO)|
There is another module, called the 900HP, which is like a ZigBee Pro, but operates on 900MHz. It has a line of sight range of 28 miles with the proper high-gain antenna. It also comes with multiple antenna options, but since it is not compatible with the XBee and XBee Pro, we won't go farther with it.
Fresh out of the box, a pair of XBee ZigBee radio modules won't do much. They need to be configured to talk. The program that makes it happen is XCTU from Digi. It is available for Windows and OS X. Setting up one radio as an endpoint and one as a coordinator seems to be the simplest configuration for point-to-point.
XBee radio modules use a lot of power, which may only matter if you are running from batteries. I often do, and had run into problems with a pair of radios not coming out of a deep sleep after programming. I keep them around as reminders. If you are going to use "pin sleep", in which a high on one pin can put the module to sleep, make sure the pin is low before you issue the AT command to enable pin sleep or you might wind up making bricks out of them. I actually did that to three modules, but I was able (a year later) to wake one of them by buggering a USB explorer to hold the pin low while doing a recovery with XCTU.
The XCTU utility is fairly self-teaching, but here are a few pointers. For testing you need two XBee USB explorers, or one explorer and one Arduino Uno + XBee shield. If you have to use an Arduino, you can write a sketch that reads the serial device and writes to the XBee over a software serial port (and vice versa) for testing. If you have two explorers, you can just hook them both up and test using XCTU. I have a $24.95 Sparkfun Explorer, and a $3.33 import, and they work identically, but the Sparkfun board has pins to plug into a breadboard, and that's what saved me up above.
The first thing you need to do is upgrade the firmware. The firmware in the XBee determines the role the device plays. We need one "Endpoint AT" and one "Coordinator AT". Start with the endpoint. When you've upgraded the firmware, you need to give it a "PAN ID", which is typically a 4 digit number. Remember it. It is your network ID. With the ZigBee network you have to enter a destination address, too. The destination address is the MAC address of the other unit. It goes in the destination high and destination low fields. You can get the data from the other unit in the serial number high and serial number low fields.
The second unit needs its firmware upgraded, too. It needs to be a coordinator. When the upgrade is done, give it the same PAN ID as the endpoint, and set the destination address to the serial number of the other unit. Now you have to test. This is where two explorers come in handy. If you have them, plug one unit into each explorer (mind the polarity!), plug in the USB cables and and switch to the console screen in XCTU. That is the tab in the upper right with an icon of a computer. Connect to each unit using the "Open" button at the top of the console window.
The console will show you what is sent in blue and what is received in red. It should be as simple as typing in the Console log window and seeing that it appears in the console log of the other console. If you would like to see both windows at the same time, click the "Detach" button at the top of the console window and the window will pop out so you can drag it wherever you would like.