Wireless Zigbee sensors are reliable, secure and cheap, making them ideal for situations that require remote and frequent monitoring of properties such as temperature, humidity or ambient light
Zigbee devices communicate using a low-power wireless protocol that is different from both WiFi and Bluetooth. They require a gateway device to facilitate communication with each other or external systems, and have a pairing process that ensures communication is secure.
In order to capture and analyze these sensors readings, it is necessary to first pair the sensors to a gateway and then bridge this gateway to the MQTT message broker.
Zigbee to MQTT
By using the open-source software available from zigbee2mqtt.io, is it possible for the USB device, CC2531 to be used together with a PC or Raspberry Pi to act as a universal Zigbee gateway.
Once sensors are paired with this gateway, it will then forward all readings to Busroot’s MQTT broker making them available for immediate analysis and visualization.
- One or more Zigbee sensors (example)
- CC2531 USB Zigbee Sniffer
- CC Debugger for CC2531
- Downloader Connector Board
- A PC or Raspberry Pi
Step 1: Flash the CC2531 device
The zigbee2mqtt firmware needs to be loaded onto the CC2531 device to allow the PC or Raspberry Pi to use it. An additional unit (CC Debugger) and cables are required for this step, however they are an inexpensive one-time purchase.
The firmware to be flashed and full instructions on this step can be found here.
Step 2: Install bridging software on the PC or Raspberry Pi.
Next, your PC or Raspberry Pi needs to to run the control software that will manage sensor pairing and forward readings to the MQTT broker.
The software and full installation instructions can be found here.
Step 3: Add Busroot account ID and password to configuration file.
Once the software is installed on both the CC2531 device and the PC or Raspberry Pi, it’s time to add your Busroot credentials to the configuration file located at: /opt/zigbee2mqtt/data/configuration.yaml
In the ‘Code & Config Samples’ of your account management page, you will find a pre-generated configuration.yml file. Just copy & paste into /opt/zigbee2mqtt/data/configuration.yaml
After this is done, the sensors readings will be passed directly onto to Busroot without need for an intermediary MQTT broker.
Step 4: Pair your sensors to the gateway.
But default, the zigbee2mqtt software is setup to pair any sensor automatically (permit_join: true). Therefore all that is required is to bring the sensor close to the CC2531 and start the sensor’s pairing mode (see instructions for the sensor).
We strongly recommend that after each sensor is paired, you edit the configuration.yml file and give the new sensor a ‘friendly name’ that is unique and descriptive to your project. Otherwise you may lose track of which sensor is which.
Once you have finished pairing all your sensors, it is recommended that you set permit_join to false in the configuration file to avoid accidental joining of other Zigbee devices.
Step 5: Validate readings in Grafana
As soon as your sensors pair with your gateway, readings should begin appearing in Grafana.
The source will be set to the ‘friendly name’ of the sensor and the type will be dependant on the sensor connected.