Friday, July 03, 2020

Pimoticz : Vendor neutral Zigbee gateway with Raspi

Tldr: Instructions for preparing Raspi as zigbee gateway in 3 simple steps(git-clone/cd-to-dir/run-setup.sh;reboot)

These days its easy to find Zigbee based home automation devices at very low cost but all those Zigbee devices are targeted to be used with manufacturer provided gateway. This means, users are limited to a few set of zigbee devices supported by the manufacturer's gateway.

Using Commercial-Off-The-Shelf(COTS) hardware, there is a possibility to create your own "vendor neutral automation gateway" which opens up an interesting possibility of supporting more than 800 zigbee devices, but this involves an advanced knowledge of setting up Raspberry-Pi with various hw/sw components.

As an advanced user or DIY enthusiast, here is a list of components one would use to build a Zigbee gateway,

  1. Raspberry-Pi
  2. CC2531-USB-zigbee-Adapter(with koenkk firmware, can be purchased on amazon for ~$12)
  3. Raspberry-Pi OS(32bit)
  4. nodejs (ver 12 or higher)
  5. zigbee2mqtt
  6. mosquitto mqtt broker
  7. Domoticz
  8. zigbee2mqtt-plugin for Domoticz.

As an average user or a beginner to home-automation, its a challenging task to setup all these components to work together on a Raspberry-Pi.

Here is my attempt to simplify this setup using an automated installer script that takes care of installing all the dependencies and needed configuration. In about 5 minutes you should be ready to pair your first Zigbee device with Domoticz.

Items needed.

  1. Raspberry-Pi
  2. Micro sd-card
  3. 5v-power-adapter
  4. CC2531 based USB to zigbee adapter(important!!! to avoid programming setupbuy pre-programmed USb adapter with koenkk-firmware:CC2531_DEFAULT_20190608.zip or higher version)


Raspi-OS Installation steps:
NOTE: CC2531-usb-adapter/keyboard/mouse/monitor/internet-connection are needed during the initial setup only):

  1. Prepare the sd-card using Raspberry-Pi-Imager and install Raspberry-Pi-OS-32BIT(I assume this step is pretty straight forward, there are tons of guides explaining this).
  2. Insert the Raspberry-Pi-OS sd-card, connect key-board/mouse/monitor and internet to your Raspi and and turn on the 5Vdc power.
  3. On first boot, raspi-os will guide you through a setup wizard where you will be asked to setup few details like..
    • Language and key-board-lay-out(important to have a correct local time on your raspi for domoticz to work correctly).
    • Set new password for your "pi" Linux user.
    • check box asking if a black border is visible on the monitor(not important as your raspi will be running in headless mode after comoticz installation).
    • Wifi setup(ignore if you have already connected raspi using LAN wire).
    • Update sw(skip incase if you dont want to wait for all the upgrades to happen).
    • Reboot raspi to allow all the settings to take effect.

Pimoticz Installation steps:

  1. on raspberry PI, open a shell-terminal(using remote ssh login, or directly on Raspi)
  2. git clone https://github.com/hackboxguy/pimoticz.git
  3. cd /home/pi/pimoticz
  4. sudo ./setup.sh -h my-pimoticz (-h hostname is optional).
  5. wait for setup to finish (takes about ~5-6minutes)
  6. sudo reboot



After reboot, start the chrome browser on you raspi(or remote pc) and open http://127.0.0.1:8080 or http://my-pimoticz:8080 (here you will see domoticz webUI showing detected zigbee Coordinator-CC2531-USB-Zigbee-Adapter).