Video Tutorial (Optional)
Watch first if you want the full walkthrough for setting up Zigbee2MQTT on a Raspberry Pi with the Sonoff Zigbee 3.0 USB Dongle Plus-E.
Project Overview
Set Up Zigbee2MQTT on a Raspberry Pi: Follow this guide to configure a Raspberry Pi with the Sonoff Zigbee 3.0 USB Dongle Plus-E and a Zigbee motion sensor to run Zigbee2MQTT, providing an open MQTT bridge for Zigbee devices.
- Time: 20 to 45 minutes
- Skill level: Beginner to Intermediate
- What you will build: A Raspberry Pi running Zigbee2MQTT with a Sonoff Zigbee USB dongle and a paired Third Reality motion sensor reporting to MQTT
Parts List
From ShillehTek
- ShillehTek resources - reference guides and consulting for Raspberry Pi IoT projects
External
- Raspberry Pi 4 or Raspberry Pi 3 with Raspberry Pi OS installed
- Sonoff Zigbee 3.0 USB Dongle Plus-E (EFR32MG21 based) - the Zigbee coordinator USB dongle
- THIRDREALITY Zigbee Motion Sensor (Model: 3RMS16BZ) - example Zigbee device used for pairing
- Network access for the Pi (Ethernet or WiFi) and an internet connection for package installs
Note: Use the /dev/serial/by-id path shown by the Pi to set the serial port in configuration.yaml. The Sonoff dongle uses the ezsp adapter in this guide.
Step-by-Step Guide
Step 1 - Plug in the USB Dongle
Goal: Verify the Pi detects the Sonoff Zigbee 3.0 USB Dongle Plus-E.
What to do: Insert the Sonoff dongle into any USB port on the Raspberry Pi, then list serial devices to find the by-id path.
Code:
ls /dev/serial/by-id
Expected result: You should see an entry like usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_XXXXXXXXXXXX-if00-port0 in the output.
Step 2 - Install Mosquitto (MQTT Broker)
Goal: Install and enable a local MQTT broker for Zigbee2MQTT to publish data.
What to do: Run the following commands in a terminal on the Pi.
Code:
sudo apt update
sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto
Test:
mosquitto_sub -t zigbee2mqtt/bridge/state -v
Expected result: Nothing prints until Zigbee2MQTT starts publishing, which is normal.
Step 3 - Clone and Install Zigbee2MQTT
Goal: Get Zigbee2MQTT source and its build tools on the Pi.
What to do: Clone the repository and install Node.js and pnpm, then install dependencies.
Code:
sudo apt install -y git curl
sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
cd /opt/zigbee2mqtt
Install Node.js 18.x:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Install pnpm:
sudo npm install -g pnpm
Install dependencies:
sudo pnpm install
Expected result: Zigbee2MQTT repository is cloned and dependencies are installed to allow starting the service.
Step 4 - Configure Zigbee2MQTT
Goal: Point Zigbee2MQTT at your Sonoff dongle and enable the frontend UI.
What to do: Open the configuration file and update the serial port path to the value you found earlier.
Code:
sudo nano /opt/zigbee2mqtt/data/configuration.yaml
Example configuration:
mqtt:
base_topic: zigbee2mqtt
server: mqtt://localhost:1883
serial:
port: /dev/serial/by-id/usb-Itead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_V2_XXXXXXXXXXXX-if00-port0
adapter: ezsp
frontend:
port: 8080
host: 0.0.0.0
enabled: true
advanced:
log_level: info
Reference: Example full configuration file: https://github.com/shillehbean/youtube-p2/blob/main/configuration.yaml
Expected result: configuration.yaml is updated with the correct serial port and the frontend is enabled on port 8080.
Step 5 - Start Zigbee2MQTT
Goal: Launch Zigbee2MQTT and watch it initialize.
What to do: Start Zigbee2MQTT from the project directory.
cd /opt/zigbee2mqtt
sudo npm start
Expected result: You should see output similar to:
Starting Zigbee2MQTT...
Zigbee2MQTT started!
If you see warnings about ezsp being deprecated, those can be ignored for now with newer dongles.
Step 6 - Access the Zigbee2MQTT UI
Goal: Open the Zigbee2MQTT frontend to manage devices and permit joining.
What to do: In a browser on your local network go to the Pi IP and port 8080.
http://<your_pi_ip>:8080
Expected result: The Zigbee2MQTT dashboard loads. Use the Permit Join option to allow pairing.
Step 7 - Pair Your Zigbee Sensor
Goal: Pair a Zigbee device such as the THIRDREALITY motion sensor so it publishes to MQTT.
What to do: In the UI click Permit Join, then put your sensor into pairing mode by holding its pairing button until its LED blinks.
Expected result: The Zigbee2MQTT logs will show a successful interview similar to:
[info] z2m: Successfully interviewed '0xb40e060fffe0595b'
[info] z2m: Device '0xb40e060fffe0595b' is supported, identified as: Third Reality Wireless motion sensor (3RMS16BZ)
Rename the device in the UI to a friendly name like motion_office for easier automation.
Conclusion
You now have Zigbee2MQTT running on a Raspberry Pi with the Sonoff Zigbee 3.0 USB Dongle Plus-E and a paired THIRDREALITY motion sensor, publishing device data to your local MQTT broker for automation and Home Assistant integration.
Want the exact parts or help building a custom Raspberry Pi IoT solution? Grab parts and guides at ShillehTek.com. If you need help customizing this project or building a product-grade solution, check out our consulting: https://shillehtek.com/pages/iot-and-robotics-consulting-by-shillehtek.