Using Zigbee on NAVQ Plus

 

This application note provides a step-by-step guide on how to set up Zigbee2MQTT on the NAVQ Plus and establish connections with Zigbee devices.

1. Zigbee

Zigbee is a wireless communication protocol that is designed for low-power, low-data-rate applications. It operates on the IEEE 802.15.4 standard and is commonly used for home automation, industrial automation, and other Internet of Things (IoT) applications. Zigbee enables devices to communicate with each other in a mesh network, allowing for reliable and scalable wireless communication. It offers features such as low power consumption, low latency, and support for large networks with thousands of devices. Zigbee is widely used for applications such as smart lighting, smart thermostats, home security systems, and industrial monitoring and control systems.

2. Zigbee Adapter

A Zigbee Adapter is the interface between the NAVQ Plus, where Zigbee2MQTT runs under Linux, and the Zigbee radio communication. Zigbee2MQTT supports a variety of adapters. This application note describes using the SONOFF Zigbee 3.0 USB Dongle Plus-P, commonly referred to as the ZBDongle-P (available for purchasing on Amazon).

Please refer to the Supported adapters section on the Zigbee2MQTT site for more information.

2.1. Zigbee Sensor

This example below describes the use of the Aqara Temperature and Humidity Sensor as an example Zigbee sensor (available for purchasing on Amazon).

3. Hardware Setup

Connect the ZBDongle-P to the NAVQ Plus using an USB hub that is plugged into the USB1 port of the NAVQ Plus. Run the below command to verify it is properly connected:

user@imx8mpnavq:~$ ls -la /dev/ttyUSB0 crw-rw-rw- 1 root dialout 188, 0 Oct 24 11:56 /dev/ttyUSB0

Depending on the dongle type and its firmware, the path to serial device could also be /dev/ttyACM0:

user@imx8mpnavq:~$ ls -la /dev/ttyACM0 crw-rw---- 1 root dialout 166, 0 Oct 26 18:53 /dev/ttyACM0

4. Software Setup

To ensure the proper operation of the Zigbee network with the NAVQ Plus, use the NAVQ+ BSP Release 1.1.8 or higher.

Additionally, Zigbee2MQTT requires installation of an MQTT broker. This application note specifically covers the usage of the Mosquitto MQTT broker.

Mosquitto is an open-source MQTT (Message Queuing Telemetry Transport) broker that provides a lightweight and scalable messaging protocol for IoT (Internet of Things) applications. It acts as a central hub or an intermediary between MQTT clients, allowing them to publish and subscribe to messages.

4.1. Installing the Mosquitto MQTT Broker

Install the Mosquitto package by running the below commands:

user@imx8mpnavq:~$ sudo apt update user@imx8mpnavq:~$ sudo apt install -y mosquitto mosquitto-clients

Enable the Mosquitto service to start automatically when the system boots up:

Start the Mosquitto service:

4.2. Installing Node.js

Node.js is an open-source JavaScript runtime environment that allows developers to run JavaScript code outside of a web browser. It uses the V8 JavaScript engine from Google Chrome to execute code on the server-side, enabling the development of scalable and high-performance web applications.

Set up the Node.js 16.x repository:

This command downloads and runs a script that adds the Node.js 16.x repository to your system.

Install the Node.js package. This command installs Node.js on your system using the package manager:

To verify the proper installation of Node.js and npm (Node Package Manager) versions, use the following commands:

5. Installing Zigbee2MQTT

Zigbee2MQTT is an open-source project that allows you to control Zigbee devices from different manufacturers using a single Zigbee coordinator and a MQTT-based communication protocol. It provides a bridge between Zigbee devices and MQTT, enabling you to integrate Zigbee devices into your smart home or an IoT system.

Create a directory for Zigbee2MQTT:

Clone the Zigbee2MQTT repository:

Install the required dependencies using npm:

Build Zigbee2MQTT:

6. Configuring Zigbee2MQTT

Copy the default configuration file and edit it:

Change the file contents to:

7. Starting Zigbee2MQTT

Start Zigbee2MQTT using the commands below:

8. Connecting Temperature Sensor

Open your browser and enter the IP address of the NAVQ Plus followed by port 8080. This will open the Zigbee2MQTT interface in your browser:

 

Move the dongle antenna away from any large metal objects, such as a PC case.

By default, Zigbee2MQTT usually starts with the permit_join option set to true, allowing new devices to join the network. When all your devices are connected, you can change the permit_join option to false in the Zigbee2MQTT configuration.

Press and hold the reset button on the sensor until the LED on the sensor starts blinking. This usually takes approximately 5 seconds.

The Zigbee2MQTT console log will display the following information:

The Aqara Temperature and Humidity Sensor will appear in the Devices list:

To read the temperature and humidity, click on the device name and navigate to the state section.

9. Running Zigbee2MQTT as a Service

Create a systemctl service file:

Insert the following content into the file:

Save the changes and exit the text editor.

Start the Zigbee2MQTT service by running:

Enable the service to start on boot-up: