O'Reilly logo

Building Wireless Sensor Networks by Robert Faludi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Buying an Adapter

You’ll be using a computer to configure your XBee and to send and receive data directly from your desktop or laptop. The XBee is made to be soldered directly into a printed circuit board, so you’ll need an adapter to connect it to your computer’s USB port. If you need to connect to an older 9-pin or 25-pin serial port instead, check the Appendix A for other options.

There are several different adapters available, along with a few handy hacks if you want to avoid buying one or if you get caught without one.

Digi Evaluation Board

If you buy a complete drop-in networking starter kit from Digi, such as their iDigi Professional Development Kit ZB (part no. XK-Z11-PD), it will include an evaluation board with a power supply, a USB connector, and some handy buttons and lights (Digi part no. XBIB-U). The kits are a good value if you need everything they include. However, if you only want some radios and an adapter, other approaches are more cost-effective. Also, the Digi evaluation board is substantially larger than most third-party adapters, making it somewhat cumbersome to carry around. At the time of this writing, the development kit was available for $300, though occasional promotions have brought it down to $150. (See Figure 1-3.)

Digi evaluation board

Figure 1-3. Digi evaluation board

USB Adapters

Several different XBee USB adapters are available from third-party manufacturers (see Figure 1-4):

XBee adapters are available from many vendors in a variety of different formats

Figure 1-4. XBee adapters are available from many vendors in a variety of different formats

Note

Almost all XBee USB adapters require drivers from FTDI (http://www.ftdichip.com/Drivers/VCP.htm). Be sure to install these before using your adapter.

SparkFun XBee Explorer

The Explorer is a very popular adapter that uses a fairly standard USB A to mini-B cable to connect with your computer. We’ll be using it in most of the examples in this book. The cable is sold separately, but before you buy, check to see if you already have one. Many digital cameras come with this type of cable. Be aware that if you add male headers to use it in a breadboard, the pin order will not be the same as on the XBee. Check the data sheet carefully if you are using the Explorer with a breadboard setup. (About $25; http://www.sparkfun.com/commerce/product_info.php?products_id=8687.)

Adafruit XBee Adapter Kit

This is an inexpensive board that you’ll need to solder together yourself. It also must be used with a special USB cable called the FTDI USB TTL-232, which can attach to its pin headers. The cable can be used with certain Arduino-type boards as well. Male headers can be added so that this adapter can be used in a breadboard. (About $10; http://www.adafruit.com/index.php?main_page=product_info&cPath=29&products_id=126. Cable about $20; http://www.adafruit.com/index.php?main_page=product_info&cPath=29&products_id=70.)

New Micros XBee Dongle

One of the smallest adapters, it needs no external cable. The Dongle does not provide any access to the radio beyond USB. Also, because it has no cable, its shape sometimes interferes with other cables or the computer casing. On the other hand, it’s a very small all-in-one device that’s easy to carry in a pocket. It’s terrific for use on the go. (About $39; http://www.newmicros.com/cgi-bin/store/order.cgi?form=prod_detail&part=USB-XBEE-DONGLE-CARRIER.)

Gravitech XBee to USB Adapter

Like the Explorer, this is another simple adapter board that uses the USB A to mini-B cable (not included). This one also has standard breadboard pinouts. (About $28; http://store.gravitech.us/xbtousbad.html.)

Breadboard front and back, showing metal clips

Figure 1-5. Breadboard front and back, showing metal clips

Breadboard with bus strips and terminal strips indicated

Figure 1-6. Breadboard with bus strips and terminal strips indicated

Breakout Boards

All XBee radios have 20 connection pins, each spaced 2 mm apart. The tight spacing of the pins helps to keep the radios very small, but doesn’t allow them to fit into a solderless breadboard. Luckily, this is a very easy problem to solve. Simple XBee breakout boards that adapt to 0.1″ breadboard spacing (see Figure 1-7) are available from:

You will generally need to solder 2 mm female pin headers to one side of these breakout boards, and regular 0.1-inch male headers to the other side.

Breakout board showing pin spacing

Figure 1-7. Breakout board showing pin spacing

Note that the XBee Explorer (Figure 1-8), Adafruit XBee Adapter Kit, and the MCPros XBee Simple Board each have mounting holes for 0.1-inch male headers. Solder a set of male header pins into them to adapt these for breadboard use.

XBee Explorer board from SparkFun

Figure 1-8. XBee Explorer board from SparkFun

Arduino Board Adapter Hack

The Arduino microcontroller board we’ll be using in Chapter 4 can be modified to function as an adapter for XBee radios. This is a useful hack if you don’t want to buy an adapter—or anytime you find yourself caught without your regular XBee adapter setup. You’ll still need a breakout board, however.

Warning

This hack allows you to connect to the XBee from a terminal program (described later in this chapter). It lets you use some features of X-CTU (also described later), but it does not support firmware upgrades. For that, you should use a proper XBee adapter.

Here’s what you’ll need:

  • XBee radio (see Buying an XBee Radio)

  • XBee breakout board (see Breakout Boards)

  • Arduino microcontroller board with USB connection (Uno or similar) (SFE DEV-09950, AF 50)

  • USB A-to-B-type cable (AF 62, DK 88732-9002, SFE CAB-00512)

  • Solderless breadboard (AF 64, DK 438-1045-ND, SFE PRT-09567)

  • Hookup wire (22 gauge or similar, different colors) or jumper wire kit (AF 153, DK 923351-ND, SFE PRT-00124)

  • Wire strippers (AF 147, DK PAL70057-ND, SFE TOL-08696)

  • IC extractor (DK K374-ND, RS 276-1581) or small flat-blade screwdriver (SFE TOL-09146)

Note

These part numbers are prefaced with abbreviations for the suppliers: DK, DigiKey; SFE, SparkFun Electronics; AF, Adafruit; RS, Radio Shack.

Insert the XBee into the breakout board, then mount the breakout board in the breadboard so that one set of legs is on each side of the breadboard’s center channel. Cut four lengths of wire or select some precut jumper wires long enough to reach from the Arduino to the XBee. Use red, black, and two other colors of wire if you have them. Figure 1-9 shows the Arduino adapter hack breadboard layout, while Figure 1-10 shows the schematic:

  1. Make sure that the Arduino is unplugged from the USB and disconnected from any other external power supply before setting up your wiring.

  2. Carefully remove the ATMEGA chip from the Arduino, using an integrated circuit (IC) extractor or a small flat-blade screwdriver (when you replace it later, be sure the notch at one end of the chip is aligned with the notch in the socket). Or, if you don’t want to pull the chip, program the Arduino with the following null code, which prevents the Arduino chip’s bootloader from responding accidentally:

    void setup() {
    }
    void loop() {
    }
  3. Connect a (red) wire from the 3.3 V socket on the Arduino so that it mates with the XBee’s pin 1, the 3.3 V input pin in the upper-left corner of the XBee.

  4. Next, connect a (black) wire from either GND socket on the Arduino so that it mates with pin 10 on the XBee in its lower-left corner.

  5. Now wire up a connection from the TX pin (pin 1) on the Arduino to pin 2, the TX/DOUT pin on the XBee. See Table 1-2 and Figures 1-11 and 1-12 for a full list of the XBee’s hardware pins and their functions.

  6. Finally, wire a connection from the RX pin (pin 0) on the Arduino to pin 3, the RX/DIN pin on the XBee.

  7. Check all your connections. It is very important that you supply only 3.3 V power to your radio.

Warning

XBee radios will not work with voltages larger than 3.3. Giving them more than 7 volts will burn them out. When in doubt, remove the radio from your project and confirm the voltage with a multimeter (AF 71, DK BK117B-ND, SFE TOL-09141) before proceeding.

When you’re done with the hack, set it aside for now. You won’t need to power up this circuit until you get to Configuring XBee in Chapter 2.

Note

If you already have an Arduino Mini, you can use the same USB adapter you use for uploading code to the Arduino Mini as a connector for an XBee on a breakout board. For this adapter, wire RX to RX on the XBee and TX to TX on the XBee (http://www.makershed.com/ProductDetails.asp?ProductCode=MKSP3).

Arduino adapter hack breadboard layout

Figure 1-9. Arduino adapter hack breadboard layout

Arduino adapter hack schematic (This and other schematics were created with an open-source software package for electronic prototyping called Fritzing. Learn more at http://fritzing.org.)

Figure 1-10. Arduino adapter hack schematic (This and other schematics were created with an open-source software package for electronic prototyping called Fritzing. Learn more at http://fritzing.org.)

What Are All Those Pins?

Table 1-2. XBee pin descriptions

Pin #

Name(s)

Description

1

VCC

3.3 V power supply

2

DOUT

Data Out (TX)

3

DIN

Data In (RX)

4

DIO12

Digital I/O 12

5

RESET

Module reset (asserted low by bringing pin to ground)

6

PWM0/RSSI/DIO10

Pulse-width modulation analog output 0, Received Signal Strength Indicator, Digital I/O 10

7

DIO11

Digital I/O 11

8

Reserved

Do not connect

9

DTR/SLEEP_RQ/ DIO8

Data Terminal Ready (hardware handshaking signal), Pin Sleep Control (asserted low), Digital I/O 8

10

GND

Ground

11

DIO4

Digital I/O 4

12

CTS/DIO7

Clear to Send (hardware handshaking), Digital I/O 7

13

ON/SLEEP

Sleep indicator (off when module is sleeping)

14

VREF

Not used in Series 2

15

ASSOC/DIO5

Association indicator: blinks if module is associated with a network, steady if not; Digital I/O 5

16

RTS/DIO6

Request to Send (hardware handshaking), Digital I/O 6

17

AD3/DIO3

Analog Input 3, Digital I/O 3

18

AD2/DIO2

Analog Input 2, Digital I/O 2

19

AD1/DIO1

Analog Input 1, Digital I/O 1

20

AD0/DIO0/COMMIS

Analog Input 0, Digital I/O 0, Commissioning Button

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required