Read an Excerpt
ZigBee Wireless Networking
By Drew Gislason
Newnes
Copyright © 2008 Elsevier Inc.
All right reserved.
ISBN: 978-0-08-055862-2
Chapter One
Hello ZigBee
Wireless networking standards are everywhere. You've heard of WiFi™ and Bluetooth™ and cellular technology. Perhaps you've heard of Active RFID, Wibree, WiMAX™, or Wireless USB. So, why ZigBee™?
The ZigBee wireless networking standard fits into a market that is simply not filled by other wireless technologies (see Figure 1.1). While most wireless standards are striving to go faster, ZigBee aims for low data rates. While other wireless protocols add more and more features, ZigBee aims for a tiny stack that fits on 8-bit microcontrollers. While other wireless technologies look to provide the last mile to the Internet or deliver streaming high-definition media, ZigBee looks to control a light or send temperature data to a thermostat. While other wireless technologies are designed to run for hours or perhaps days on batteries, ZigBee is designed to run for years. And while other wireless technologies provide 12 to 24 months of shelf life for a product, ZigBee products can typically provide decades or more of use.
The market category ZigBee serves is called "wireless sensor networking and control," or simply, "wireless control." In fact, the slogan for ZigBee is, "Wireless Control That Simply Works."
I'll get to that in a moment (the first code example in this book, "Hello ZigBee," simply works). The wireless control market has a number of unique needs for which ZigBee is ideally suited, because ZigBee is:
Highly reliable
Cost-effective
Able to achieve very low power
Highly secure
An open global standard
To achieve the low power and low cost criteria, ZigBee added a constraint to the technology:
Low data rate
Now, why would a networking standard want to encourage low data rates? Because ZigBee is all about wireless monitoring and control. Think of a light switch. How often does it need to communicate? Ten times per day? Or perhaps, not at all, on a given day? How large is that data set? By keeping focused on the appropriate technology for wireless control, ZigBee achieves an elegant solution that makes sense and fits a set of markets very well. Just don't expect to stream voice or video over ZigBee. Yes, I have seen companies stream voice over ZigBee, but that's not the intended use, and it consumes way too much bandwidth for most ZigBee networks.
"Wireless Control That Simply Works." Those words, the slogan of the ZigBee Alliance, are oh-so-easy to say and oh-so-hard to do. ZigBee comes pretty close, as you'll see over the course of this book. Unfortunately, making wireless control that simply works from an end-user perspective requires a fair bit of work from the developer and system designer, with some thought taken on how the application is to be solved. ZigBee has the necessary networking primitives to make it possible, and in many cases also has the necessary Application Profiles to make compatibility with other products possible. In this book, I'll show you how to apply ZigBee appropriately to achieve wireless control that simply works.
1.1 What's a ZigBee?
Before I delve into ZigBee in detail, I'd like to address one question that seems to come up every time I speak about ZigBee in public. Where did the name ZigBee come from?
Well, the way I first heard it was at the ZigBee Open House in Seattle, back in 2004.
This story was told during a time when ZigBee was often confused with Bluetooth™. Just so you don't confuse the two: Bluetooth™ is great at point-to-point (as seen in many headsets and cell phones). ZigBee is great at wireless control, where anywhere from two to thousands of nodes are all connected together, in multi-hop mesh network.
Bob Heile, Chairman of the ZigBee Alliance explained the origin of ZigBee something like this:
A Norwegian legend speaks of a little troll by the name of ZigBee, who lived in the village of Vik far inland on the fjord of Sogn. Now, Norwegian trolls aren't the big, nasty and smelly, hard-as-rock variety often told of in other tales, at least not always. ZigBee was a kindly, quiet little troll, who didn't speak much, but when he did speak it was always reliable. A person could count on ZigBee.
One time, ZigBee sensed that a decomposing pile of hay stacked up against a barn had become too hot and had begun to smolder. ZigBee, in no time at all, sounded the alarm to every house in the village, and the villagers were able to put out the fire before the barn was lost.
Another day, a grandfather left the port of Vik i Sogn in his small fishing boat to catch Salmon with his granddaughter Brita. This day, unlike other days, Brita was not being careful. Bestefar (that is the name Norwegians give to their grandfathers) didn't notice when Brita fell overboard as he was busy hauling in a net full of fish off the stern of the little boat. ZigBee, sensing immediately that Brita had fallen, alerted Bestefar who was able to save her from drowning.
Yet another time ZigBee saved the whole village of Vik. And the way I heard it was this. A local villager by the name of Haarold Bluetooth, was far up in the snow-capped mountains, tending his flock of sheep in the early spring. It had been a warm spring that year, following a particularly hard winter.
The shepherd, Bluetooth, brought his flock to a stream he knew well, but this year he couldn't approach it. The steam had turned into a flooding river from the rapidly melting snow. Alarmed, Bluetooth now wished he could let the villagers know about the flood before it reached the village, but the village was too far away for him to be heard. Bluetooth simply didn't have the range to help the village.
ZigBee, sensing there was trouble, saw the flood as well. And ZigBee, like Bluetooth, realized he was too far away for a single shout to be heard. So he immediately began to hop down the mountain, ledge by ledge until he reached the village. He automatically opened the dam and the flood passed through without harm to the village.
It was a very lucky thing for Vik i Sogn that they had ZigBee, and that ZigBee knew how to multi-hop.
1.1.1 ZigBee Is Highly Reliable
Wireless communication is inherently unreliable. Prove this to yourself by walking around with your cell phone, then step into an elevator. Anyone who has used a cell phone has experienced dropped calls or poor reception. It's all because radio waves are just that: waves. They run into interference patterns, can be blocked by metal, water or a lot of concrete, and vary depending on many complex factors including antenna design, power amplification, and even weather conditions.
Wireless control, however, doesn't usually have the same remedies normally associated with a cell phone call, of moving to find better reception, or waiting to try back later. The ZigBee Alliance understands this, and so the ZigBee specification reflects this need. ZigBee achieves high reliability in a number of ways:
IEEE 802.15.4 with O-QPSK and DSSS
CSMA-CA
16-bit CRCs
Acknowledgments at each hop
Mesh networking to find reliable route
End-to-end acknowledgments to verify data made it to the destination
The first is relying on a very reliable, low-range wireless technology, the IEEE 802.15.4 Specification. This specification is a very modern, robust radio technology built on over 40 years of experience by IEEE. It uses what's called Offset-Quadrature Phase-Shift Keying (O-QPSK) and Direct Sequence Spread Spectrum (DSSS), a combination of technologies that provides excellent performance in low signal-to-noise ratio environments.
ZigBee uses what's called Carrier Sense Multiple Access Collision Avoidance (CSMACA) to increase reliability. Before transmitting, ZigBee listens to the channel. When the channel is clear, ZigBee begins to transmit. This prevents radios from talking over one another, causing corrupted data. CSMA-CA is similar to what people do in conversations. (Or at least should!) They wait for the other speaker to finish, and then talk.
ZigBee uses a 16-bit CRC on each packet, called a Frame Checksum (FCS). This ensures that the data bits are correct.
Each packet is retried up to three times (for a total of four transmissions). If the packet cannot get through after the fourth transmission, ZigBee informs the sending node so something can be done about it.
Another way that ZigBee achieves reliability is through mesh networking. Mesh networking essentially provides three enhanced capabilities to a wireless network: extended range through multi-hop, ad-hoc formation of the network, and most importantly automatic route discovery and self healing.
With mesh networking, data from the first node can reach any other node in the ZigBee network, regardless of the distance as long as there are enough radios in between to pass the message along (see Figure 1.2). Node 1 wants to communicate to node 3, but is out of radio range. ZigBee automatically figures out the best path and so node 1 sends the information to node 2, which forwards it on to node 3.
Now suppose that over time, something happens to this route. Perhaps node 2 has been removed or dies, or some barrier intervenes, such as a concrete wall or a large tank of water. This doesn't bother ZigBee at all. ZigBee will automatically detect the route failure and route around the obstruction (see Figure 1.3).
In addition to mesh networking, ZigBee provides reliable broadcasting, a technique for distributing a message to many nodes in the network. ZigBee also provides multicasting, which can send a message to any given group of nodes. And, as a back-up routing technique, ZigBee provides tree routing to augment ZigBee mesh networking in RAM limited systems.
ZigBee also provides automatic end-to-end acknowledgments. Your application can know whether a particular packet was received by the other node. With all of these retries, ZigBee filters out any duplicate received packets, so your application doesn't have to.
All of these concepts are explained in detail in Chapter 7, "The ZigBee Networking Layer."
1.1.2 ZigBee Is Cost-Effective
Obviously, a book is not the place to look for current prices, but at the time of this writing, ZigBee is pretty cheap. And it looks like it is getting even less expensive over time. A quick search for ZigBee chips (I used DigiKey.com) yielded inexpensive prices (see Table 1.1).
Most of the entries in the table are the price for a combination MCU and radio. That's right, a single chip solution yields prices in the $3 to $5 range, on average. One of the entries, the Freescale MC13203, is a stand-alone radio that can be combined with any MCU or CPU.
The final two entries, the Digi International XBee and the Panasonic PAN802154, are complete, ready-to-ship, precertified modules. Connect a couple of AA or AAA batteries and a sensor or actuator to these boards, put it in some plastic enclosure, and ship your product.
These prices are for low-volume sales. OEM and higher volume (10,000+ units) knock off about a dollar, as a rule of thumb. And, as the competition for the 802.15.4 market stiffens, the prices will likely be brought down even further. Some have predicted that the 802.15.4 radio market will see prices around $1 in quantity over the next three to five years.
But the low cost of ZigBee isn't just about low silicon costs. In addition to low MCU and radio costs, developing applications for ZigBee is cheap in other ways:
It uses the 2.4GHz spectrum for worldwide distribution.
There are certification houses with expertise in 802.15.4 and ZigBee.
There are module vendors who provide ready-to-go ZigBee boards.
Its core technology is free of patent infringements.
It requires only low cost development environments.
ZigBee experts are available for consulting or custom engineering.
There are Application Profiles for ready-made vendor interoperability.
The 802.15.4 radios come in both 2.4GHz and 915MHz flavors. Radios in the 2.4GHz band may be shipped worldwide, license-free (that's governmental RF spectrum license-free, not license-free from the standpoint of vendor licenses). The 915MHz band is available license-free in the Americas. In either case, new RF boards must be certified by the government to ensure they don't interfere with other products in the intended markets.
Some companies offer easy and relatively low-cost governmental RF certification, including FCC certification in the U.S., IC in Canada, and CE Marking in Europe. Others offer ZigBee certification, such as NTS and TUV.
Another cost saver, available because ZigBee is an international standard, is the availability of modules. A module is a single board computer complete with an MCU and ZigBee RF solution. Module vendors, such as Digi International, Panasonic, and LS Research, provide precertified ZigBee modules, ready to communicate out-of-the-box. Using this approach, the only development cost is software, and even that can be reduced by using the sample programs which come with the ZigBee kits, or the built-in software in the modules.
(Continues...)
Excerpted from ZigBee Wireless Networking by Drew Gislason Copyright © 2008 by Elsevier Inc.. Excerpted by permission of Newnes. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.