Today, we'll be talking about how to set up something called the XBee with the Arduino.  The XBee is a wireless device  made by Digi International.  The weakest XBee made is capable of communicating at a distance of up to 400 feet outdoors (100 feet indoors) in a high interference environment (Robogames, for example) with almost no data loss, etc.  In addition, you can run thousands of units on one network simultaneously.

Now, before we begin, I realize there are dozens of articles similar to this one scattered around the web.  However, when I first started using the XBee, I was unable to find an article that had all the information I needed in one place.  Therefore, I thought I'd make my own!

This article assumes you're using a Windows machine, but I may update later on with instructions on how to do this under Linux.

Here's what you'll need:

  • One Arduino Uno or Arduino Mega.

  • One Arduino Wireless SD Shield.

  • Two XBee wireless modules.

  • One USB XBee interface.

  • One 6V 2Amp power supply.

  • One USB A to B cable.

  • One USB A to Mini-B cable.

You can get all of these items in a kit from Trossen Robotics.

Step 1: Configuring the XBees

The first thing you'll need to do is download and install the X-CTU software from Digi International, which is under the "Diagnostics, Utilities and MIBs" drop-down menu.  After that is installed, mount one of the XBees on the USB to XBee interface as shown in the picture below.

Plug the interface into your computer using the USB A to Mini-B cable and then launch the X-CTU application.  Change the value under "Baud" to 9600.

You should now see something similar to "USB Serial Port (COM4)" in the "Select Com Port" box.; select it, and then click on the "Modem Configuration" tab in the window.  Now you'll see a window similar to the one below.

Click the "Read" button and then wait a few seconds.  The space that was blank should now have a bunch of different information in it.  The items we'll be modifying are ID - PAN ID, DL - Destination Address Low, MY - 16-bit Source Address and BD - Interface Data Rate.

The PAN-ID (or ID) is the Personal Area Network Identifier.  For XBees to "see" and communicate with each other, they must have identical PAN-IDs.  It can be any number between 0001 and 9999; just don't use 3332 because that's the default!  Also, be sure to remember this number because you'll need it for the second XBee too!

The Interface Data Rate determines how fast your XBees can communicate with each other.   We'll be using a rate of 38400 Bits Per Second (BPS), which corresponds to "5" in the X-CTU utility.

For the rest of the values, it should look like the following:

ID: XXXX DL: 11 MY: 10 BD: 5

Once you have entered the values, click "Write" and wait for it to finish.  After it has finished, repeat this process for the second XBee using the following values (ID and BD stay the same):

ID: XXXX DL: 10 MY: 11 BD: 5

Step 2: Setting up the Arduino

Next up, you need to get your Arduino ready to use!  First, download and extract the Arduino Software and then plug the Arduino into your computer via the USB A to B cable.  You don't need to worry about the power supply yet; the USB cable supplies power to the Arduino automatically.

Windows will now try to install the driver software for the Arduino.  Once it invariably fails, you will need to tell the Windows Add Hardware wizard to search the FTDI USB Drivers folder which should be in the Arduino folder you extracted, under Drivers (arduino-x.x.x >> drivers >> FTDI USB Drivers).

Once Windows finishes installing the drivers, launch the Arduino software.   Then go to Tools >> Serial Port and select the COM port your Arduino is connected to.

Now you need a program for the Arduino!  Download and extract this file and then open it inside the Arduino editor (I've commented almost every line to explain what everything does).  You should now see a screen similar to the one below.

Click the green arrow pointing to the right (the second icon on the top left of the screen).  This will "upload" the program to the Arduino board.  Once it has finished uploading, close the editor and unplug everything from the computer.

Step 3: Putting it all together

You're almost done!  We now need to plug one of the XBees into the Arduino.  To do this, we must first install the Wireless SD shield on it, and then the XBee will go on top of that.

You can see the finished result in the image below.  I'm using an Arduino Mega, but the Wireless SD Shield mounts in the exact same way on an Arduino Uno.  Also, take careful note of the direction that the XBee and Wireless SD Shield are mounted in.

Be sure to verify that the tiny switch on the top of the Wireless SD Shield is set to "Micro".

Next, plug the other XBee into the computer via the USB interface.  Then, plug the 6V power supply into an outlet but don't plug it into the Arduino yet.

Your setup  should now look something like the picture below (excluding the Arduino being plugged in).

Open the Arduino software on your computer and go to Tools >> Serial Port to select the COM port your XBee USB interface is connected to.

Go to Tools >> Serial Monitor; you should see a blank screen.  Set the baud value at the bottom right of the serial monitor window to "38400".

Now it's time to plug the Arduino in! A few seconds after plugging it in, the serial monitor should be outputting some stuff similar to the image below.

Congratulations, now you're thinking with portals XBees!  From here, you can do all sorts of things like wireless data collection, autonomous robots of mass destruction, etc.

Since this is my first real tutorial, please leave your comments and tell me if anything should be improved or changed.

Sources: XBee Basics (For description of PAN-ID and BD Interface Data Rate)