Raspberry Pi ZigBee Gateway » Controlling ZigBee devices with the Raspberry Pi
Published: 03.07.2024 | Reading Time: 7 minutes
This text is machine translated.
With a ZigBee gateway, you can turn the Raspberry Pi into a universal control center for ZigBee devices. ZigBee is one of the most important transmission protocols for measurement and control tasks with low data volumes. Whether for private rooms, offices or the commercial sector: ZigBee has established itself as a cost-effective standard for building automation, remote control and the Internet of Things (IoT).
It networks wireless sensors and actuators with each other via a control center, for example lamps, radio-controlled sockets, motion detectors, buttons and many other devices.
With ZigBee, a simple voice command or press of a wireless button is all it takes to set rooms to the desired lighting mood or switch wireless sockets throughout the house. The ZigBee control center, bridge or hub connects the individual ZigBee devices with each other. A ZigBee gateway for your Raspberry Pi replaces the radio control centers of the various manufacturers. It bundles their functions into a single gateway. This means that all ZigBee devices in the building can be controlled without a separate gateway and without a cloud.
Philips Hue, Ikea Tradfri, Ledvance/Osram Smart +, Paulmann LED, Müller Licht and Q-Leuchten: Lighting systems in particular use the energy-efficient ZigBee wireless protocol. Products from Bosch Smart Home, Homee, Samsung and Xiaomi use ZigBee to coordinate motion, smoke and water sensors, switches and alarm sirens. Each of these systems has its own ZigBee bridge as a wireless control center. It forms a bridge between the devices, the Wi-Fi, the manufacturer's cloud and the control app on your smartphone.
A ZigBee gateway such as the RaspBee II turns the Raspberry Pi into a ZigBee bridge for all the devices you have installed. It connects the ZigBee clients to form a uniform smart home network with central control. This means you only have a single bridge that networks all ZigBee devices. This means you can turn your back on proprietary control centers such as the Philips Hue bridge or the Tradfri gateway from Ikea.
Background: Theoretically, ZigBee devices from different manufacturers are largely compatible with each other from ZigBee 3.0 onwards. With the Philips Hue Bridge, for example, Ikea Tradfri lamps can be linked and controlled together. In practice, however, interoperability between devices from different manufacturers often does not work smoothly. The interaction is usually limited to basic functions such as light on/off, dimming, RGB color selection and timer control.
Device-specific functions are only available with the respective manufacturer's bridge and app. This means that you end up running several bridges in one building, which consume power and do not exactly correspond to the idea of a uniform control system. A ZigBee gateway for your Raspberry Pi frees you from compatibility restrictions in home automation.
A ZigBee gateway such as RaspBee II is a space-saving, cost-effective hardware expansion module in the form of a wireless adapter for the Raspberry Pi. The adapter is available in two versions: as an add-on board or USB dongle. The add-on module is connected to the GPIO (General Purpose Input Output) connector strip on the Raspberry Pi board. Connect the USB dongle to the USB port of the mini-computer.
The gateway module on the Raspberry Pi is controlled via the free deCONZ software. deCONZ serves as a ZigBee control layer, runs in the background and provides API interfaces.
Home automation applications such as Home Assistant, FHEM, openHAB, Homebridge, ioBroker, Domoticz, Node-RED and Mozilla IoT are based on this.
With these applications, you can set up a standardized smart home control center with its own rules and automatisms on the Raspberry Pi. Over 200 products, protocols and manufacturers such as AVM, Amazon Alexa Echo, Bluetooth, HomeKit, LG, HomeMatic IP, Google Assistant, Gardena, Magenta SmartHome, Somfy and Rademacher are supported.
Products from categories ranging from lights to garage doors, door locks and hi-fi systems to garden irrigation can be combined in groups, for example to map a room in the house. The possibilities for building control are complex and require a little tinkering.
Use the free Phoscon app as easy-to-understand software for operating the ZigBee devices in the browser. Phoscon offers you extensive options for configuring and controlling lighting installations. You can use the Phoscon app to control light sources, lamps, sensors and switches interactively and via scenes.
The Hue Essentials app is recommended for convenient operation of the devices networked via the ZigBee gateway on smartphones and tablets. The basic version of the free app for Android and iOS controls the lighting via scenes and effects.
As smart devices become increasingly networked, the flow of data increases. With ZigBee devices, the configuration and user data is usually stored on the respective manufacturer's cloud servers. Settings, control instructions and signals from sensors run via the provider's server. This could use switching operations to determine when you enter a room and switch on the light, how long you stay and when you leave again. In principle, this makes it possible to create user profiles.
How protected the data in the cloud is depends on the provider's security and encryption mechanisms. Cross-industry security standards such as Matter from the Connectivity Standards Alliance (CSA) contribute to data protection and privacy.
By using a ZigBee gateway, you improve the data protection of your home automation system. The gateway does not require a cloud that could leak usage data. No login or registration is necessary either. Control via the single-board computer is purely local and does not require an internet connection. The ZigBee components only communicate within the private network. They are not connected to the cloud of the manufacturer behind the respective devices. Device settings, switching statuses and sensor messages never leave the home network.
Are you looking for home automation with the Raspberry Pi and a community-supported software solution such as Home Assistant, openHAB or Homebridge? Then you have a choice of two ways to address smart devices: Connect the respective manufacturer's bridge to the Raspberry or use a gateway and replace the manufacturer's bridge.
Networking via the manufacturer bridge
When networking via the manufacturer bridge, you create a connection from the software on the Raspberry Pi to the bridge for the desired device. For example, if you want to operate your Philips Hue lights via the openHAB software, proceed as follows:
First set up the lights in the Hue app on your smartphone. If control via the Hue app works as desired, create a link called “Binding” with the Hue Bridge in openHAB.
This makes the Hue Bridge part of the open HAB network, whereby all control commands are still transmitted via the Hue Bridge. If you want to add another manufacturer's devices to openHAB, make the system known to the corresponding bridge. The manufacturer's cloud remains active in the background.
Networking via a gateway
If you not only want to combine the individual bridges in programs such as openHAB on the Raspberry Pi, but also replace them, use a gateway such as RaspBee II. The Raspberry Pi takes over the task of the Hue bridge via the ZigBee gateway. To do this, the deCONZ software emulates the bridge hardware. The Pi communicates directly with the ZigBee devices and bypasses the cloud. You do not need any other control centers for the ZigBee protocol. Thanks to the gateway chip, you don't need to be tied to the manufacturer's bridge - simply switch off the bridge.
When selecting a ZigBee Raspberry Pi gateway, look for the “real-time clock” or “RTC” (Real Time Clock) feature in the product description. The Raspberry Pi does not have a real-time clock by default. After an interruption in the power supply or the Internet connection, the system clock time of the single-board computer may deviate from the actual time. As a result, automation processes such as switching lamps and other devices on and off using the timer are executed at the wrong time.
A ZigBee gateway equipped with a battery-operated real-time clock, such as RaspBee II, protects you from unwanted time deviations. It permanently supplies the Pi with the exact time.
ZigBee is particularly widespread in smart lighting technology and the range of devices is large. Setting up a ZigBee network is quick and the transmission of signals costs little energy - practical for battery-operated devices.
The encrypted wireless protocol works in a similar way to Wi-Fi, but differs in one important aspect when it comes to range: while in Wi-Fi all connections are made centrally via the router, the devices in the ZigBee network communicate not only via a control center, but also with each other. The result is a self-managed mesh network in which devices connected to the power grid, such as lamps or sockets, automatically act as repeaters. The signals are routed as a target via the mesh connection. This results in improvements in terms of range and reliability. A well-placed ZigBee socket or a ZigBee light is usually sufficient to supply remote rooms or floors.