Zigbee2mqtt with Sonoff Dongle Plus ZBDongle-P

December 16th, 2024, last changes on December 17th, 2024

Install MQTT Broker

  1. Install mosquitto broker and client sudo apt install mosquitto mosquitto-clients.
  2. Enable mosquitto broker sudo systemctl enable mosquitto.
  3. Create custom config under /etc/mosquitto/conf.d/*.conf, e.g.:
listener 1883 # allow remote access
allow_anonymous true # enable non-authenticated access
  1. Restart mosquitto sudo systemctl restart mosquitto.
  2. Test: subsription mosquitto_sub -v -t test/message, publisher `mosquitto_pub [-h ADDRESS] -t test/message -m 'Hello'

Prepare und Update Zigbee Gateway

Here Sonoff Zigbee 3.0 USB Dongle Plus (ZBDongle-P) with CC2625P chip. Visible in my case as /dev/ttyUSB0 or by ID as /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_*-if00-port0.

  1. Get flasher from https://github.com/wirenboard/wb-cc2652p-flasher.
  2. Test flasher with python cc2538-bsl.py --bootloader-sonoff-usb:
sonoff
Opening port /dev/ttyUSB0, baud 500000
Connecting to target...
CC1350 PG2.1 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: xx:xx:xx:xx:xx:xx:xx:xx
  1. Get firmware from https://github.com/Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_3.x.0/bin, file CC1352P2_CC2652P_launchpad_*.zip.
  2. Prepare environment: python -m venv ., . bin/activate, pip install pyserial, pip install intelhex, pip install python-magic.
  3. Flash with python cc2538-bsl.py -e -w -v --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_*.hex:
sonoff
Opening port /dev/ttyUSB0, baud 500000
Reading data from CC1352P2_CC2652P_launchpad_coordinator_20240710.hex
Firmware file: Intel Hex
Connecting to target...
CC1350 PG2.1 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: xx:xx:xx:xx:xx:xx:xx:xx
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F988
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0xd9dd0124)

Updating on Windows

The procedure works exactly the same way. The same python tool does the job.

COM Port

In my case the tool was not able to find the respective COM port, so looking it up in the Device Manager and providing explicitly in the command line solved the issue: python wb-cc2652p-flasher-1.0.0\cc2538-bsl.py --bootloader-sonoff-usb -p COM6 -e -w -v SELECTED_IMAGE.hex.

ZBDongle as a Router

There is an alternative firmware for the ZBDongle, making it work as a router (repeater). The update procedure is identical as above, just the image is different: from https://github.com/Koenkk/Z-Stack-firmware/tree/master/router/Z-Stack_3.x.0/bin the file CC1352P2_CC2652P_launchpad_router_*.zip. After rebooting the dongle, it will automatically try to join a network and becomes visible as router:

Zigbee2mqtt Device List

Zigbee2mqtt Exposed Properties

Install Zigbee2mqtt

  1. Add Node.js LTS repository curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -.
  2. Install Node.js sudo apt-get install -y nodejs git make g++ gcc libsystemd-dev.
  3. Test node --version -> output v20.18.1.
  4. Test npm --version -> output 10.8.2.
  5. Create target directory sudo mkdir /opt/zigbee2mqtt, sudo chown -R ${USER}: /opt/zigbee2mqtt/.
  6. Download sources git clone --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt.
  7. Download dependencies cd /opt/zigbee2mqtt, npm ci -> output added 647 packages, and audited 648 packages in 8m.
  8. Build app npm run build -> output > zigbee2mqtt@1.42.0 build > tsc && node index.js writehash, pretty fast.
  9. Create a config file, template from /opt/zigbee2mqtt/data/configuration.example.yaml to /opt/zigbee2mqtt/data/configuration.yaml:
# Home Assistant integration (MQTT discovery)
homeassistant: false
permit_join: false

# Enable the frontend, runs on port 8080 by default
frontend: 
    port: 8888
    host: 0.0.0.0

# MQTT settings
mqtt:
    # MQTT base topic for zigbee2mqtt MQTT messages
    base_topic: zigbee2mqtt
    # MQTT server URL
    server: 'mqtt://localhost'
    # MQTT server authentication, uncomment if required:
    # user: my_user
    # password: my_password

# Serial settings
serial:
    # Location of CC2531 USB sniffer
    port: /dev/ttyUSB0

# Advanced settings
advanced:
    # Let Zigbee2MQTT generate a network key on first start
    network_key: GENERATE
    # Let Zigbee2MQTT generate a pan_id on first start
    pan_id: GENERATE
    # Let Zigbee2MQTT generate a ext_pan_id on first start
    ext_pan_id: GENERATE
    log_level: info
  1. Start zigbee2mqtt npm start:
> zigbee2mqtt@1.42.0 start
> node index.js

Starting Zigbee2MQTT without watchdog.
[2024-12-16 15:34:15] info:     z2m: Logging to console, file (filename: log.log)
[2024-12-16 15:34:15] info:     z2m: Starting Zigbee2MQTT version 1.42.0 (commit #bc6eccf)
[2024-12-16 15:34:15] info:     z2m: Starting zigbee-herdsman (2.1.9)
[2024-12-16 15:34:16] info:     zh:zstack:znp: Opening SerialPort with {"path":"/dev/ttyUSB0","baudRate":115200,"rtscts":false,"autoOpen":false}
[2024-12-16 15:34:16] info:     zh:zstack:znp: Serialport opened
[2024-12-16 15:34:17] info:     zh:zstack:znp: Writing CC2530/CC2531 skip bootloader payload
[2024-12-16 15:34:18] info:     zh:zstack:znp: Skip bootloader for CC2652/CC1352
[2024-12-16 15:34:44] info:     zh:controller: Wrote coordinator backup to '/opt/zigbee2mqtt/data/coordinator_backup.json'
[2024-12-16 15:34:44] info:     z2m: zigbee-herdsman started (reset)
[2024-12-16 15:34:44] info:     z2m: Coordinator firmware version: '{"meta":{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20240710,"transportrev":2},"type":"zStack3x0"}'
[2024-12-16 15:34:44] info:     z2m: Currently 0 devices are joined.
[2024-12-16 15:34:44] info:     z2m: Zigbee: disabling joining new devices.
[2024-12-16 15:34:45] info:     z2m: Connecting to MQTT server at mqtt://localhost
[2024-12-16 15:34:45] info:     z2m: Connected to MQTT server
[2024-12-16 15:34:45] info:     z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload '{"state":"online"}'
[2024-12-16 15:34:45] info:     z2m: Started frontend on port 0.0.0.0:8888
[2024-12-16 15:34:45] info:     z2m: Zigbee2MQTT started!

Next: Raspberry Pi with SIM7600X 4G HAT as a router

Previous: LineageOS for Samsung S7 Edge

Main Menu