Hardware Reference
In-Depth Information
Duplex Radio Transmission
In this example, you'll connect an RF
transceiver and a potentiometer to the
microcontroller. Each microcontroller will
send a signal to the other when its poten-
tiometer changes by more than 10 points.
When either one receives a message, it
will light up an LED to indicate that it got
a message. Each device also has an LED
for local feedback as well.
MATERIALS
» 2 solderless breadboards
» 1 uSb-to-Xbee adapter
» 2 Arduinos Arduino Fio models are a nice
alternative designed to work with XBees
» 2 Digi Xbee 802.15.4 RF modules
» 2 Arduino wireless shields
If you choose not to use wireless shields or Arduino
Fios, you can use the parts below to connect the
XBees to the Arduinos:
» 2 3.3V regulators
» 2 1µF capacitors
» 2 10µF capacitors
» 2 Xbee breakout boards
» 4 rows of 0.1-inch header pins
» 4 2mm female header rows
» 6 LEDs
» 2 potentiometers
The RF transceivers used in this project implement the
802.15.4 wireless networking protocol on which ZigBee
is based. In this example, you won't actually use any of
the benefits of ZigBee, and few of the 802.15.4 benefits.
802.15.4 and ZigBee are designed to allow many different
objects to communicate in a flexible networking scheme.
Each radio has an address, and every time it sends a
message, it has to specify the address to which to send.
It can also send a broadcast message , addressed to every
other radio in range—you'll see more of that in Chapter
7. For now, you'll give each of your two radios the other's
address so they can pass messages back and forth.
you'll give each of your two radios the other's address so
they can pass messages back and forth.
Step 1: Configuring the XBee
Modules Serially
The easiest way to connect an XBee to your personal
computer is to use an XBee-to-USB serial adapter. Since
this topic's first edition was published, the popularity of
XBees has grown exponentially, and multiple versions
are now available (most hobbyist electronics vendors sell
a version). They're all basically a USB-to-Serial adapter
mounted on a board with pins spaced to fit an XBee radio.
The first image in Figure 6-12 shows two options: Adafruit's
XBee USB adapter board and Spark Fun's XBee Explorer.
Both have LEDs mounted to indicate serial transmit
and receive. Adafruit's model also has LEDs to indicate
whether the radio is associated with a network or whether
it's asleep. The sleep mode indicator LED is attached to
pin 13, which goes low when the radio is in sleep mode,
and high when it's active. The associate indicator LED is
attached to pin 15. When the radio's associated, this LED
will blink.
There are many things that can go wrong with wireless
transmission, and as radio transmissions are not detectable
without a working radio, it can be difficult to troubleshoot.
Because of that, you're going to build this project in
stages. First, you'll communicate with the radio module
itself serially, in order to set its local address and destination
address. Then, you'll write a program to make the micro-
controller send messages when the potentiometer
changes, and to listen for the message to come through
on a second radio attached to your personal computer.
Finally, you'll make two microcontrollers talk to each
other using the radios.
In this example, you won't actually use any of the features
of ZigBee or the 802.15.4 protocol. Those protocols are
designed to allow many different devices to communicate
in a multitiered networking scheme. Each radio has an
address, and every time it sends a message, it has to specify
the address to which to send. It can also send a broadcast
message, addressed to every other radio in range—you'll
see how to send broadcast messages in Chapter 7. For now,
Plug your XBee into the adapter, connect it to your com-
puter's USB port, and open your favorite serial terminal
program.
Search WWH ::




Custom Search