- Category: Ciseco product documentation
- Last Updated on Tuesday, 11 June 2013 09:24
XBee Shield V0.6
The XBee Shield is a pre-assembled Arduino shield that allows an Arduino or similar micro controller to connect to an XBee shaped wireless module. To use it like this, simply plug in a radio unit, plug the shield on to your Arduino, add a line of code to your sketch to urn pin 8 high (this controls the XBee power) and you are up and running. Unlike most other shields you can still program your Arduino with the radio module installed due to some clever circuitry. Additionally there is support for a 2nd XBee shaped module (WiFi, Bluetooth etc) and a real time clock with battery backup. Various sensors, LEDs or buzzers can be installed to make instant demo devices. If using it with the Ciseco XRF it can also be used to remotely program the Arduino up to 1000 meters away.
Power to the first XBee socket is derived from pin 8. If pin 8 is high, the socket is powered. If pin 8 is low, floating, or an input, then the socket is not powered. This ensures that the Arduino is still programmable over USB or FTDI cable with a radio module attached. Arduino Pins 0 and 1 (Rx and Tx) are connected to socket pins 2 & 3 respectively through a switch. With most modules this will simply mean that whatever data is sent to the Arduino serial port (TX) is simply broadcast out of the radio, and whatever is received on the radio comes in to the Arduino serial port (RX). Please check the data sheet for your specific radio module some devices like the series 2 XBee need configuration before they will converse.
The XBee shield has space to add a second set of XBee header sockets. This will allow the Arduino to communicate via two different radio mediums, making it, perhaps in to a gateway type device. For example, you could have a Roving Networks XV in the primary socket and an XRF in the secondary socket. That way the Arduino could potentially receive data from LLAP devices via the XRF and post that data onto a cloud provider such as Pachube via the WiFly XV module.
Pin 1 on the secondary socket is connected to 3v3, and pin 10 is connected to ground. In order to use the secondary socket you will also need to connect the appropriate communication pins from the XBee socket to the appropriate Arduino pins. Please refer to the datasheet of the module you are using. All of these pins are broken out to solder pads next to them to make it easy to wire them up. For the example above, connect XBee socket pin 2 to Arduino pin 3 and XBee socket pin 3 to Arduino pin 2. This allows Software Serial 2 & 3 to talk to the XRF module.
Xbee Series 2 Note
The current v0.6 shield are shipped with a 0R link fitted for remote reset. Powering up an Xbee series 2 has been knowen to set pin 17 LOW and casue a reset of the arduino. This enters a loop of the Arduino sketch powering up the Xbee, the Xbee reseting the Arduino (and hence powering down the Xbee), the Arduino powering up the Xbee.... etc.
In order to avoid this you can remove the 0R resistor on the Remote Reset pad.
With a soldering iron heat one side then the other, moving quickly between each other until the 0R resistor moves, most likely it will jump to the iron when it's hot enough.
The following Arduino code assumes an XRF is plugged in to the secondary XBee socket, and a Roving Networks XV is plugged in to the primary socket. It will use software serial to listen for LLAP commands sent to the XRF, and upload the data to Pachube. You will need to add your Pachube feed, Pachube API key, wireless SSID and passphrase on the credentials.h file to match your settings. The sketch is set to listen for various types of information from a few different LLAP sensors. You will probably need to change these to match your sensors.
Download the code from here
The XBee shield has provision for a DS1307 RTC to be added. This will require a 8 pin DIP socket, DS1307, 32.768Mhz crystal, 100nf capacitor and (if required) a coin cell holder and coin cell for battery backup. Mount the chip socket, capacitor and crystal as per the legend on the board. The battery holder can either be mounted on the top of the board (if you are not using the secondary XBee socket), or underneath the board (if there is sufficient clearance from the board below). SCL and SDA on the DS1307 need to be connected to the SCL and SDA pins (A5 and A4) on the Arduino. Connecting an off board battery is fine just dont exceed a nominal 3v.
The following code gives an example on how to set the time on the DS1307 and read the time from it.
Download the code from here
The XBee shield has several component outlines for different potential uses. For example, a DS18B20 temperature sensor could be used to measure temperature. Or a buzzer could be fitted to alert you to a certain event. These areas are not wired to any Arduino pins, so you are free to choose where to connect them to. The tracks are quite easy to follow on the top of the board, but please use a multimeter to ensure you know what is connected to what.
Preparing the XBee shield
We need to ensure that the primary XBee socket is always powered up, this is because we need it to have power whilst the Arduino resets. We do this by inserting a jumper across the holes marked “REM PROG”.
Ensure that the remote reset zero ohm resistor is in place (is by default)
Preparing the remote XRF
Firstly we need to configure the XRF that is to go in the XBee shield, here I'm using the Ciseco USB interface. You might have a Sparkfun XBee explorer or similar. A MAX232 will suffice if you are familiar with them. Never connect an XRF direct to a PC com port you may cause damage.
XCM is used to configure the XRFs. This is available for free download from here; http://openmicros.org/index.php/articles/84-xrf-basics/105-xcm-software-config-for-the-xrf
Baud rate to 115200 (for Arduino Uno)
Set the Node ID – this can be any two letters but must not match any currently powered up XRF (I used TT), I have a lot of traffic on the normal frequency so I set the channel offset to 3
Upload, Write and then Apply changes
The XRF can now be inserted into the XBee Shield which is plugged into an Arduino Uno and powered up. This image doesn't show the REM PROG pads joined. To do remote programming you need to add a jumper (see close up image above in section "Preparing the XBee shield" )
Preparing the PC
Here I am using an URF board, the same settings are also used on the XRF, we just thought it worth showing you could use either device.
Configure remote programming using XCM.
Set the remote ID to the ID of the remote XRF (in this case TT), set the channel offset to the same value you used for the remote (in this case 3) and enable the remote reset.
Upload the settings, you may want to Write them as well so that the URF will remember the settings.
Remote programming of the Arduino
Now all we need to do is to start up the Arduino IDE, selecting Arduino Uno as the board type and the com port of the URF.
When you hit upload the sketch should be compiled, the remote Arduino reset and the program uploaded successfully.
The commonest issue seen is the remote reset failing. This can easily be seen if you can see the Pin 13 LED – or of you attach an LED to pin 13. This LED should flash when the Arduino is reset.
If this does not happen immediately after the sketch has been compiled then you may need to recheck all the settings above, also ensure that the remote XRF is at least 6 feet away from the URF as it may be swamped with a too powerful radio signal.
If the LED does flash indicating an Arduino reset then then problem may be down to radio noise – try uploading again.