XBEE RADIOs!
If you want to send signals back and forth between your computer and a remote arduino, you’ll need to use XBee radios. If you want to use them in the Arduino Interface, read Robert Faludi’s Account of how to set up a Zigbee network in this book. If you want to communicate between Arduinos within the grasshopper interface, then follow this account of how to set up your radios:
Supplies:
-2 XBee Radiso
-XBee Shield & XBee Explorer from Sparkfun (you can get a kit with all four of these
supplies here http://www.sparkfun.com/products/9897)
-Assembled as instructed here: http://www.sparkfun.com/tutorials/194
-Arduino
1. After soldering and assembling your shield, plug it into your arduino. The red power light should light up on the shield. If it does not, check to make sure that
-your arduino is powered (is the green light on the arduino board lit up?)
-you have aligned the pins correctly between the shield and the arduino
-that you have soldered correctly and that there is not excess solder accidentally connecting circuits
2. Insert your Xbee into the shield. The DI05 should light up on the shield. If it does not, check to make sure that
-your xbee is oriented correctly (with the beveled end of the radio pointing outward, not inward)
-your xbee radio is working? Try to insert the other radio and see if this one works. While I’ve never had problems with a radio, I’ve read forums where people complain about the radio dying and not working anymore.
3. For creating a conversation between two Xbees, you’ll simply need both radios to have the same name, address, and baud rate. If your radios are brand new, they should be programmed so that they are both named 0, their address is 3332, and their baud rate is 9600. However, if these radios have been used before, you’re going to need to check to see how they have been formatted. Also, if you plan on creating a large network of XBees (something that we’ll not be explaining how to do here because we’ve not yet done it), you might need to give the radios different names from each other, or you might need to change the address if you anticipate that other XBee radios, ones you don’t want to communicate with, will be in the same area. If you want to check or change this information, you’ll need to use a program called X-CTU. It’s free and you can download it here:
(http://www.digi.com/support/productdetl.jsp?pid=3352&osvid=57&s=316&tp=5&tp2=0).
You can also use programs like HyperTerminal, etc, but X-CTU is more user-friendly than many of its competitors.
Using X-CTU
Plug one radio into the Explorer, and plug the Explorer USB into your computer. The red power light should be illuminated.
Open up X-CTU. Select USB Serial Port (It should also be labeled with a COMid. This number should be somewhere between 3 and 10). Then select the Baud Rate at which you think the radio is set. This will probably be 9600, unless you have changed it to something else. The other settings should read Flow Control: None, Data Bits: 8, Parity: None, Stop Bits: 1. Then click Test/Query. A window should then pop up that reads: “Communication with Modem. OK. Modem Type: XB24 Modem Firmware: 10E6”
Of course, if you don’t have an XB24, 10E6, then your window will instead tell you what XB module you have. If you do not get this window, try entering a different baud rate in the first window, and try unplugging and replugging your radio. Select OK, then click on the top tab labeled “Modem Configuration.” Once in this tab, click on the Read Button. The window should then display all types of information about your XBee. The most important things to change/check here are the Pan ID (under “Networking and Security”) and the Interface Data Rate (under “Serial Interfacing”). Your Pan ID is your address, and the two radios should be at the same address. The address is composed of 4 numbers (I think you can add letters too, but I’m not positive). If they are new, they should both be at 3332. Your Interface Data Rate should also be the same, and if you plan to use the Firefly Firmata, it needs to be at 9600. If you plan to create a larger network, I believe (but am not exactly sure) you’ll need to change the numbers for DL and MY under Networking & Security. The DL number refers to the number of the XBee that this radio is talking to and MY number refers to the number the radio calls itself. If you have several radios that are sending messages to a receiver, you should identify the receiver as 1, for example, and all the transmitting radios can have their own number: 2, 3, 4, 5, for example.
If you make any changes, you must click the Write button at the top of the screen. This writes the changes to the radio. You’ll need to plug in each radio, one at a time so that you can read and write the changes to each of them.
4. If you’ve been using the Explorer and X-CTU, you can now unplug the explorer and the close out of X-CTU. Plug the Shield back into your arduino. Don’t plug the radio in yet, and don’t power your arduino yet. Begin by connecting the Shield to the Breadboard and hooking up a few sensors or responders to the arduino. The pins of the Shield can be treated in the same way as the pins of the arduino, so you can plug sensors up in the same way. For example, if you want to read a sensor through Analog Pin 2, just plug the signal wire into the A2 pin on the Shield. If you need some help understanding how to wire up sensors into your arduino, check out the examples in Fritzing. (Fritzing is a free program you can download. You can find a link to it on this website’s homepage).
5. Now plug the Arduino into your computer, but not the radio yet! Open Arduino. You’ll need to upload the Firefly Uno Firmata to your Arduino, but it is important that you change one thing in the Firmata: the baud rate. It needs to be set to 9600. In the new firmata, it is set to 115200. Before uploading the sketch find the place in the code where it identifies the baud rate and change it to 9600. Then upload the sketch. If you’re having problems uploading the sketch, make sure that the radio is not plugged in, and that you are selecting and reading the right serial port (Toolsà Serial Port).
6. Now you can unplug the Arduino and connect it to another power source. You can use a nine volt battery If you plan to leave it outside somewhere, a Solar Cell/Battery Kit is a great power source. We’ve used this one: http://ladyada.net/products/usbdcsolarlipo/ and it works quite well. This particular kit is great because it uses the solar cell to power the arduino and to charge the battery. This way, when the solar cell is not providing enough energy, it uses the battery reserves. You’ll need to solder one thing together to make the kit work, but after that, the assembly is fairly straightforward. You’ll need to take the red and black wires coming out of the jack and plug them into the breadboard. You’ll need to connect them to the power and ground on your Arduino microcontroller.
7. Now you can plug the radio in again to the shield, and now you can take your Shield/Arduino/Radio/Sensor network and put them somewhere. Don’t take it too far away because most Xbees only communicate within three hundred feet or so.
8. Now plug the Explorer into your computer. Open Grasshopper. Take out the Firefly Open Port, Read, and Write Components. Make sure that you have changed the Baud Rate in the Open Port Component to 9600, that the Port number is the one associated with the Explorer, and that you have a timer hooked up to the UnoRead Components. Now you should be able to control the outside station from your computer, remotely, in the same way that you would use Firefly to control the arduino if it were connected to your computer.
