ZigBee Communication Protocol Tutorial for Smart Home
ZigBee is a Smart Home Communication Protocol based not on WiFi but on radio frequency that allows to connect up to 65,000 smart devices in a mesh network.
Therefore large networks are possible compared to Z-Wave (232 devices) and WiFi (32 devices). In practice a ZigBee network can handle around 240 devices.
Table of Contents
The communication protocol was established in 2002 by the ZigBee Alliance to create a protocol for smart home applications with the benefit of low power consumption for battery powered devices like buttons and window sensors.
Today the ZigBee Alliance consolidates more than 500 companies from chip manufacturer to vendors of smart home devices. The Alliance maintains and publishes the ZigBee standard. The newest standard is ZigBee 3.0 that is backward compatible with all other ZigBee ZigBee profiles and unifies the previous cluttered profiles to only one for home automation.
The following table shows the technical key facts for the ZigBee 3.0 smart home communication protocol:
The communication protocol of ZigBee is based on the IEEE standard 802.15.4 wireless-data specification for low-rate wireless personal area networks (WPANs). Therefore ZigBee is an open wireless standard that builds on the physical layer and media access control of the IEEE standard. Compared to WiFi, one advantage of ZigBee is, that there is no need to control IP addresses.
The following picture shows the relationship between the IEEE 802.15.4 standard and the ZigBee standard in context of the Open Systems Interconnection model (OSI model).
The bottom two network layers, physical layer (PHY) and medium access control layer (MAC), are defined by the IEEE standard that was initially released in 2003. The ZigBee standard only contains the upper three layers:
- Network layer (NWK): The ZigBee communication protocol supports multiple network typologies such as star network, tree network and generic mesh network.
- Application layer: In the application layer there are ZigBee Device Objects (ZDOs) that are responsible for including and keeping track of device roles, managing requests to join a network, as well as device discovery and security. Also the application layer includes manufacturer-defined application objects that are not part of the communication standard.
- Security layer where data encryption and data authentication via Advanced Encryption Standard (AES) is implemented. All encryption keys are secured by 128 bit.
Because manufacturer can define own application objects, companies can implement their own products and there is no guarantee for interoperability. If you want to build a smart home based on smart devices with ZigBee communication, this could be a problem when multiple ZigBee devices from different brands my not be able to communicate.
ZigBee Network Devices
Independent of the typology there are also three different kinds of ZigBee devices: Coordinator, Router and End Device.
The coordinator is the root of the network and therefore the most capable device. There is only one coordinator in each network. The task of the coordinator are the following:
- Select the channel for the communication of the whole network.
- Assign a unique ID to this network.
- Allocate unique addresses to each device of the ZigBee network.
- Initiate and transfer messages in the network.
The coordinator is the smart home hub that you can buy like a Samsung SmartThings Hub, Philips Hue Smart Hub or Wink Smart Home Hub.
The router acts as intermediate node between the coordinator and the end devices. There can be more than one router in a network that has the permission to allow other routers and end devices to join the network. Because a router routes traffic between different nodes, it has to be always on and can not enter any power saving mode. Therefore a router should never by powered by a battery. If an end node is not directly accessible, the router can store the message until the end node returns from power saving mode. A router in a ZigBee network is no fancy box like your internet router but a normal smart device that has a reliable power supply like a smart light switch.
End devices contain just enough information to talk to the parent node and because end devices are not requested any time in the network, they may sleep (a standby) for the most time, which makes end devices a suitable choice for battery operated devices. If an end device is waken up it is responsible for requesting any pending messages from its parent. For example if a parent node requests the current temperature from a temperature sensor, the end device is waken up, requests the open message and sends the temperature to its parent node.
The network topology defines how the ZigBee devices are connected to each other. There are three different network typologies supported in the standard: Network Topology, Mesh Topology and Tree Topology.
The star topology is the simplest and less expensive implementation where you have only one coordinator and multiple end devices but no router. Also each end device only communicates with the coordinator and not directly with any other end device. The main disadvantages of a star network is, that if the coordinator fails, then the whole network fails. Also the range of the network is limited to the range of the coordinator itself.
A mesh topology is the best ZigBee network topology because if a node fails, data can be re-routed using another path (called self-healing process or resilience). Therefore every node is connected with the neighboring node, except for the end devices. A message hops from one device to another in order to reach its destination. Routers act themselves as a repeater thus strengthening the network and are sender and receiver at the same time. In a mesh network the range of the network can be extended with other devices in the mash network.
A tree topology is like a mesh network but the routers are not interconnected. Therefore every end device is connected to only one router.
ZigBee Radio Frequency
The ZigBee radio frequency is related to the WiFi frequency (2.4 GHz and 5 GHz). There are three frequency bands assigned to ZigBee but only one channel is used in a network
- Europe: Channel 0: 868.3 MHz
- US and Australia: Channel 1-10: 902 MHz – 928 MHz (2MHz each channel)
- Across the World: Channel 11-26: 2.4 GHz – 2.4835 GHz (5MHz each channel)
It is not recommended to use the exact WiFi frequency because this can cause in interference and usually the ZigBee network will take the hit. The following picture shows the WiFi and also the different ZigBee channels.
From the picture you see that the three non-overlapping WiFi channels (1, 6, 11) use the same frequencies as the ZigBee channels 11…22. When you deploy a ZigBee and a WiFi network in you smart home, you have to plan the different channels to reduce the interference to a minimum. This said you choose only two of three WiFi channels that are next to each other (1 & 6 or 6 & 11) and the other free channel frequency can be used by the ZigBee network.
How Smart Devices access the Network Channel
There are two methods how smart devices can access the ZigBee network. The first method is the contention-free method, also called beacon-enabled network. The second way is the contention based method or non-beacon-enabled network.
Contention-free method (beacon-enabled network)
The following picture with one coordinator and 5 end devices shows how the contention-free method works.
The coordinator dedicates a specific time slot to each device, called the guaranteed time slot (GTS). The time slots for every device is guaranteed and therefore can not overlap. The coordinator transmits a synchronization messages (called beacon) periodically to each device in the network. This objective of this beacon is to synchronize the clock of every device. From the second cycle of the example, you see that not all devices have to transmit data in each period. To reduce the power consumption, all devices sleep most of the time and only wakes up when the beacon is received and if the device transmits data to the ZigBee network.
Contention based method (non-beacon-enabled network)
In the contention based method, the devices do not need to be synchronized and therefore no beacon is transmitted to each device. But the network use the carries sense multiple access – collision avoidance mechanism. When an end device wants to transmit data, first the device switches into the receiver mode and detects if there is any signal in the channel. If there is no signal, the device switches into the transmit mode and transfers the data. But if there is already a signal in the channel, the device backs off of for a random period of time and restart the process to transfer data until the message is send.
If you have any questions regarding ZigBee, smart home communication protocols in general or other questions, leave a comment and I will answer your questions as soon as possible.
And if you are interested in other smart home communication protocols, check out the tutorial for Z-Wave and MQTT.