Hardware Reference
In-Depth Information
your computer. Most shields only allow a connection between the XBee and
Arduino on the hardware serial UART port. If your shield supports it, you
can avoid unplugging your XBee to program to your Arduino by using the
SoftwareSerial library. The library allows you to define two arbitrary digital
pins on your Arduino to act as RX/TX pins for talking with your XBee. For
this to work, your XBee shield must have jumpers that enable you to choose
which Arduino pins the RX/TX lines from the XBee connection. The SparkFun
XBee shield has a switch that allows to you connect the RX/TX pins to pins
2 and 3 instead of pins 0 and 1. If your shield supports this, you can use the
SoftwareSerial commands throughout this chapter in place of the traditional
Serial commands when communicating with the XBee radio.
ConiguringYourXBees
Before you can actually use your XBees, you need to configure them to talk to
each other. Out of the box, XBees can already talk to each other; they are set
to a default channel and are in broadcast mode. In other words, they send and
receive with any other similarly configured XBee within range. Although this
is okay, at some point you may want to use multiple XBee setups within range
of each other, change communication speed, or otherwise configure them in
a way unique to your setup. Here, you learn how to configure your XBees to
speak specifically to each other.
ConiguringviaaShieldoraUSBAdapter
You can program XBees, just like you can program your Arduino, via a USB
serial connection. You can program an XBee in two ways. The first option is
to use the USB-serial converter that is built in to your Arduino (via the FTDI
chip or 8U2/16U2 Atmel chip that was explained in Chapter 6, “USB and Serial
Communication”). The second option is to use a dedicated XBee USB adapter.
I strongly recommend getting an XBee USB adapter; it will make it easier to
handle communication between an Arduino and your computer later in this
chapter. In this chapter, I use the popular SparkFun XBee USB Explorer (see
Figure 11-6) to program the XBees.
 
Search WWH ::




Custom Search