XBee

For a video introduction to using an XBee with NLTK, see the video Using the XBee wireless node.

The XBee modules by Digi are small radios that can communicate across hundreds of feet. They include serial interfaces as well as inputs and outputs (9 ports, 5 of which can be analog inputs) for sensors and effectors. They are low cost, low power, and in many cases can be used without any microcontroller.

Once set up, The Xbee nodes are very easy to use and very reliable. On the other hand, it can be confusing to configure them properly for your application. There are different modes, and you need a PC to use Digi’s configuration software called XCTU.

Modes

There are two basic modes that the XBee’s can operate in: Transparent (AT) and API (Packet) Mode. The toolkit uses the API mode, where an XBee is connected directly to your computer as the local coordinator, and one or more XBees are remote and communicate wirelessly with the local coordinator. No Arduino is required.

Configuration

Configuring the XBees is a seemingly complex process, and certainly hard to understand at first. While some people have developed simple interfaces for setting up the XBees with “AT” commands, right now we recommend getting the XCTU software from Digi, and using that to configure your XBees. Unfortunatly, X-CTU only runs on the PC, so you’ll need access to a machine running Windows XP (we’re using VMware Fusion on the Mac).

Getting Started

Here’s what you need to set up the XBee radios before you can use them:

Once you have all of this ready to go:

  • On your Windows computer, install the FTDI drivers and X-CTU software. If you are on Windows 8, there are installation restrictions for unsigned software – see this Digi information page for how to get around this.
  • Carefully plug the XBee into the XBee Explorer USB, making sure the angled sides are facing away from the USB port and matching the white lines drawn on the Explorer.
  • Plug the USB cable into your computer (if you are on a Mac and running PC emulation software, start it up before you plug in the USB cable – you’ll need to make sure the PC emulator has access to the USB/Serial port).
  • Start up X-CTU
  • WIth the PC Setting tab selected at the top of the X-CTU interface, select the appropriate COM port. It should look something like “USB Serial Port (COM7)” (where the COM number will vary depending on where you’ve plugged it into your computer).
  • Assuming your XBees are new, use the default settings for the Baud Rate, Flow Control, etc. (i.e. 9600, NONE, 8, NONE, 1)
  • First, update the firmware to 10CD.
  • Then set the individual settings per the below for the local and remote XBee unites

Configuration for the Coordinator (local) XBee

The Coordinator XBee is the module that’s connected to your computer (or microcontroller) and is the master unit. It can receive data from any remote XBee, as well as tell individual remote XBees how to act (in API mode).

  • Networking & Security Section
    • ID=3332 (the default) – This is called the PAN ID, and establishes a common network among all the XBees – Every XBee in your network MUST have the same number for the PAN ID (you can set it differently from 3332 if you want).
    • DH=0
    • DL=0
    • MY=1234
    • CE=1 (Coordinator)
  • Serial Interfacing Section
    • BD=3 for 9600 baud – you can use other rates, but be careful to remember what rate you set the unit to. Write the rate on the unit, and remember you will have to set X-CTU and any other software to communicate at that rate once you’ve changed it.
    • AP=2 API Enable

Configuration for End-Device (remote) XBee

  • Networking & Security Section
    • ID=3332
    • DH=0
    • DL=1234
    • MY=1 – This is the identifier for the remote XBee, so each End-Device should have a unique value for MY – Be sure to label the XBee with this number – put a little bit of Scotch tape on it and use a Sharpie to indicate it is an End-Device #1 (or whatever number you assign). Note that this number is in the HEX numbering system that counts from 0 to 15. So for example, if you set MY=10, that is equal to 16 in the decimal system that you would use in the AnalogInput widget for the xbeeRemoteID.
    • CE=0 (End-Device)
  • Serial Interfacing Section
    • BD=3 for 9600 baud – you can use other rates, but be careful to remember what rate you set the unit to. Write the rate on the unit, and remember you will have to set X-CTU and any other software to communicate at that rate once you’ve changed it.
    • AP=2 API Enable
  • I/O Settings (sample configuration – pick your own settings once you get to know the system)
    • D8=3 Digital Input
    • D7=1 CTS FLOW Control
    • D6=4 Digital Output Low
    • D5=1 Associated Indicator (helps in seeing how things are working)
    • D4=2 Analog Input
    • D3=2 Analog Input
    • D2=2 Analog Input
    • D1=2 Analog Input
    • D0=2 Analog Input
    • IU=1 I/O Output Enable
    • IT=1 Samples before TX – how many samples the XBee will collect before transmitting them back to the coordinator
    • IR=64 Sample Rate in milliseconds – i.e. the XBee will transmit the number of IT samples every 64 milliseconds (about 15 times a second). You can make the Sample Rate lower so it transmits more frequently, but that will use more power because it is transmitting more often. Set the number higher (i.e. fewer times per second) if you don’t need a smooth data rate (e.g. you are monitoring a door switch and only need to know every second you can set it to 1000)

More reference info on Xbees – AT vs. API Mode

Transparent (AT) Mode

If you want to create a simple point-to-point configuration, where the Xbee acts as a wireless serial modem between a computer or microcontroller and a remote device (e.g. Arduino) using simple serial communications, you want to set up the XBee in “Transparent Mode”. This is the mode used in this example for the XBee Arduino Shield.

Features of the Transparent mode:

  • Simple
  • Compatible with any device that speaks serial
  • Limitied to point to point communication between two XBees

API (Packet) MODE

For the NETLab Toolkit, we’re using the XBee in API mode, which offers more capabilities. In particular, the API mode enables you to set up a network of XBees and communicate to each one individually. This mode is supported by the series of XBee libraries developed by Andrew Rapp which we’ve incorporated into the Hub.

Features of the API mode:

  • I/O Line passing (receive data from a stand-alone remote XBee)
  • Allows for Broadcast communication and communication with more than one XBee
  • Receive acknowledgement that a packet was successfully delivered
  • Obtain RSSI (signal strength)
  • Remote Configuration

Last modified October 29th, 2013