XBee Shield and Explorer USB Quickstart Guide


XBee Shield and Explorer USB

Welcome to the wonderful world of XBee wireless communications. This page serves as a starting point for everything you need to get up and running with your XBee Explorer USB and XBee Shield for Arduino.

How do I assemble them?

For a step by step guide to assembling the XBee shield, see the XBee Shield and Explorer USB Assembly Guide.

What do I do with them?

How do I make them work?

Will XBee solve my problem? What are my choices for wireless communication?

If you want moderately reliable, moderately priced, bi-directional communication at moderate speeds XBee may well solve your problem. As with any technology choice there are trade offs and this Wireless Buying Guide can help you choose (it's a couple of years old but the underlying concepts are still relevant).

How do I send data from my Arduino to my computer wirelessly?

Normally when you send data from your Arduino to your computer it travels over a USB cable. You can use XBee as a "cable replacement", this means the data will travel wirelessly between the Arduino and your computer without the need for a cable to connect the two devices.

First you need to assemble your XBee shield and insert one of your XBee modules into the headers provided.

The following instructions assume your XBee modules are in their default state which means they communicate at 9600 baud. See the section on resetting your XBee modules if this is not the configuration of your XBee modules or you simply can't remember how they're configured.

Next move the small switch near the RX/TX pins on the shield into the position marked "DLINE". When the switch on the shield is in the "DLINE" position the hardware serial port (which uses the RX and TX pins) of the Arduino can be used for uploading sketches:

Connect the shield to your Arduino and then connect the Arduino via USB cable to your computer as you normally would.

At this time the red power LED on the shield should light and the green LED labeled DIO5 should blink.

Upload the sketch from File > Examples > 4. Communication > ASCIITable to your Arduino.

Use the Serial Monitor to check you can view the output of the ASCIITable sketch—make sure the Serial Monitor is configured to communicate at 9600 baud.

Close the Serial Monitor.

Now move the switch on the shield to the "UART" position. When the switch on the shield is in the "UART" position the hardware serial port of the Arduino is used to transfer data from the Arduino to the XBee module.

[TODO: Continue.]

How do I change the speed (baud rate) at which data is transferred?

If you are using Microsoft Windows you can use a program called X-CTU, otherwise you can use the xbeeconfigure Processing sketch or the Arduino serial monitor. Note that speeds above 19200 may be unreliable or not show improved throughput.

Before you begin you need to connect the XBee module you want to program to the XBee Explorer USB board and ensure the orientation of the module is correct. Connect the XBee Explorer USB board to your computer with a USB cable.

Using X-CTU to change the baud rate

  1. Open the X-CTU application and select the correct serial port from the list displayed:
  2. Click on the "Modem Configuration" tab, then click on the "Read" button to read the current configuration of the XBee module:
  3. Scroll to the "Serial Interfacing" section and change the "BD" setting to the desired baud rate:                                 
  4. Click on the "Write" button to save the new configuration back to the module.
  5. The module is now configured to communicate at the new speed. Make sure you also reconfigure your second module and change the baud rate used in your sketch.

Using the Arduino Serial Monitor to change the baud rate

Follow the instructions in the section How do I reset my XBee modules to their default settings but instead of the command "ATRE" use the command "ATBD" followed by a space and then the configuration value of the baud rate you want to use. You can look up the configuration value for a specific baud rate from this table:

Configuration Value

Baud rate
0 1200
1 2400
2 4800
3 9600
4 19200
5 38400
6 57600
7 115200

For example, if you want to change the baud rate to 19200 baud you would send the command "ATBD 4" because the configuration value for a baud rate of 19200 is 4.

Don't forget to follow the instructions to the end so the new value is written to the XBee module.

Using xbeeconfigure to change the baud rate

Download the xbeeconfigure sketch and follow the instructions in the README file.

How do I reset my XBee modules to their default settings?

If you or someone else has changed the configuration of an X-Bee module and need to return the module to the original settings it shipped from the factory with you need to reset the module to its default settings.

You have three options for resetting XBee modules to their default settings: the X-CTU tool for Microsoft Windows, the xbeeconfigure Processing sketch or using the Arduino serial monitor. Here we will describe the method that uses the Arduino serial monitor.

  • Connect a XBee module to the USB explorer board and then connect the board to your computer.
  • In the Arduino IDE select the correct serial port from the Tools > Serial Port menu.
  • Open the serial monitor in the Arduino IDE.
  • First, ensure that the communication speed is set to the same speed as the XBee module using the pop-up menu at the bottom of the serial monitor window (labeled Step 1 in the image below). By default the speed will be 9600 baud but if you have reconfigured the XBee modules it may be different. If you are unsure what speed the XBee module is configured for, you will need to try each speed in turn. If this is the case you might prefer to use the xbeeconfigure Processing sketch as it will auto-detect most communication speeds automatically.

  • Next, ensure the line-ending pop-up menu (labeled as Step 2 in the image above) is set to "No line ending". This means when we send characters to the XBee module no additional characters will be added—this is important when we want to enter the XBee module's command mode.
  • Now, enter the three characters "+++" into the serial monitor text field (labelled Step 3 in the image above) and then press the button labeled "Send".
  • After a moment the XBee module should respond with the text "OK" as shown in the following image. This means the XBee module is now in "command mode":

  • It is essential that less than ten seconds elapses between entering command mode and sending the first text command otherwise the XBee module will leave command mode automatically and you'll need to repeat the steps to reenter command mode. For the same reason, there must also be less than ten seconds elapsed between sending each command.
  • Before you send the first command you need to change the line-ending pop-up to "Carriage return" as labeled with Step 1 in the image below.

  • Next, type "ATRE" into the text field as labeled Step 2 in the image above and then press the button labeled "Send". The "AT" is required at the start of each command (and is short for "attention"). The command "RE" resets the configuration to the default settings but the change will be lost when power is removed unless the new configuration is saved—which the next command will do. As before, the XBee module will respond with the characters "OK" as shown in the image below:

  • Now, it is time to tell the XBee module it should save (or "write") the new configuration to its permanent memory so the configuration will survive when the power is removed. The command for this is "WR" (for "write") and in the same way you did before you need to type the characters "ATWR" into the text field then press the button labeled "Send":                                                                

  • As before the XBee will respond with "OK" to indicate it has saved the configuration and will now use the default configuration (including communicating at 9600 baud when the power is next applied):                                    

  • You can now close the Serial Monitor window in the Arduino IDE and disconnect the XBee Explorer. You will need to repeat the steps with your second XBee module in order for the two XBee modules to communicate.

How do I program my Arduino wirelessly?

For the moment you can check out this existing Wireless XBee/AVR Bootloading tutorial or you may have success following this Arduino Fio XBee tutorial.

 

Schematic and PCB Layout

For technical information including the schematic and design files, please see the product page. You may also want to add/review the comments on this page or do a Google search for example projects that use the XBee shield.

 

Have a suggestion for how we can improve this quickstart guide? Concepts not explained clearly? Need more example code? Please let us know. You can leave a comment below or email us spark@sparkfun.com. Also let us know if this is the most awesome Quickstart guide you have ever encountered and we will stop trying to improve it.

Comments 5 comments

  • To add to the resources for Mac and Linux people, I was able to get X-CTU up and running on CrossOver-Mac (Wine) from CodeWeavers.com. I submitted the app to their repository with a couple of how-to tips.

  • I have two xbee pro s2 xbees which I can configure and read with the usb explorere however I cannot get the devices to communicate when I insert into the shield on the Arduino. The power light comes on but the DIO5 light stays solid and does not blink on the sheild. Any ideas on what may be going wrong?

    • (A bit late, but for future questions) XBee Series 2 would be a whole different tutorial. Basically you need to upload the correct firmware to your modules. If you have any questions please feel free to email techsupport.

    • I’m having the exact same issue

  • Try Xbee shield Product Page