Setting Up Wireless Connections on Your Arduino
- Jan 20, 2014
Chief among the devices to connect Arduinos is the XBee, an Arduino-friendly wireless module capable of connecting a whole network of microcontrollers. In Figure 4.1, you can see one of my own projects, a LEGO robot controlled with Wii nunchucks connected to XBee-equipped Arduinos. You can learn how to build it in my book, Make: Lego and Arduino Projects (ISBN 978-1449321062). After you get up to speed on the XBee, you will tackle the third project, a wireless doorbell!
FIGURE 4.1 This XBee-equipped bracer enables you to control a robot wirelessly.
XBee Wireless Modules
XBee modules (see Figure 4.2) are based on ZigBee, which is an industry standard protocol that creates networks of multiple wireless nodes via serial data transmission, meaning only one bit (0 or 1) is sent at a time, making it slow but easy to configure. ZigBee is the default protocol used in home automation, so learning the platform’s ins and outs could aid you in creating your own curtain-puller or light-switcher!
FIGURE 4.2 Two Series 1 XBee modules attached to Adafruit breakout boards.
XBee also happens to be the default communication method used by Arduino, enabling them to work together nicely. However, a wide assortment of XBee flavors are available, and you must sure to get the right one. Let’s focus on just four of those XBee flavors in this chapter:
- XBee Pro
- XBee Series 1
- XBee Series 2
XBee Versus XBee Pro
You first need to choose between XBee “regular” and “professional”—the distinction is purely about radio power. Ordinary XBees feature 1mW (one thousandth of a watt) power, whereas Pros are rated at 63mW, giving you a much greater range. What kind of range exactly? It depends on a complicated array of factors, including electromagnetic interference, antenna type, and physical obstructions.
That said, Digi International, the maker of XBee products, issues range estimates for the various models. The regular 1mW XBee is rated for 80 feet indoors and 300 feet outdoors, and the company claims the Pro model is good for 140 feet indoors and an impressive 4,000 feet—almost a mile—outdoors. Of course, for that last number, you would need the most ideal circumstances, like beaming from one hilltop to another. Any sort of obstruction will reduce the effective range of your radio.
If you don’t need 4,000 feet, you might be better off skipping the Pro model because it costs more.
Series 1 Versus Series 2
The second consideration in choosing an XBee is what sort of networking you would like to configure. Digi International sells what it describes as Series 1 and Series 2 XBees.
Series 1—Series 1 offers the simplest networking setup in that you don’t have to set it up. Basically, every Series 1 module talks to every other Series 1 module within range—a configuration known as the mesh network. It’s an easy way to get started playing around with wireless technology.
If you want to direct data to a single module, you have to use software to set an identifier during both transmission and reception. This sounds intimidating, but it can be as simple as adding a single digit. Say you want to send data to Node 5; you can add a 5 to the beginning of your stream of data and the other nodes will ignore it.
Series 2—Series 2 is more robust, offering—in addition to the settings of the Series 1—the ability to
- Create more intricate networks with nodes being designated as “coordinators,” able to issue commands.
- Create “routers” that send and receive data.
- Create end devices that may only receive.
On the downside, having all these features means that you can’t plug-and-play, because you must configure the modules before using them, unlike Series 1, which you can use right out of the box! More technically, the Series 2 use a different wireless protocol that makes them incompatible with Series 1 modules, so don’t even try!