Skip to content

Install zigbee2mqtt on a NanoPI Neo 256Mb

April 2nd, 2021 - houseinfrastructureit(1 min)

Yesterday I’ve received my NanoPi Neo with 256Mb of RAM. Such a cute and tiny board:

NanoPi

It has a bunch of pins too :)

pins

Initial setup

I’ve started with Armbian first, but I hadn’t too much luck. I’ve been told it was the power supply though :)

After, I’ve downloaded FriendlyCore from Friendly ARM, which is an Ubuntu Core 16.04 system. It’s a bit out of date, but it worked out of the box.

I’ve logged into the machine via SSH and updated the system:

sudo apt update
sudo apt upgrade

As a bit of hardware, I’ve got Slaesh’s CC2652RB stick (from here). I’ve got the type 4 for maximum range :)

Install zigbee2mqtt

I’ve installed the system using verbatim the guide on the site. The only change is that I’ve used /dev/ttyUSB0 instead of /dev/ttyACM0.

For my own reference, here are the steps I’ve run:

  1. Add the node 14.x repo:

    sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
  2. Install the required dependencies:

    sudo apt-get install -y nodejs git make g++ gcc
  3. Clone the zigbee2mqtt repo (and change the ownership)

    sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
    sudo chown -R pi:pi /opt/zigbee2mqtt
  4. Install dependencies:

    cd /opt/zigbee2mqtt
    npm ci --production

    You should get an output similar to:

    node-pre-gyp info ok
    added 383 packages in 111.613s
  5. Update the configuration file (/opt/zigbee2mqtt/data/configuration.yaml) with something like:

    # 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
    advanced:
      network_key: GENERATE

    You will want to set up your own mqtt server address (I have mine as plugin in HomeAssistant) and credentials.

  6. (optional) Start the server:

    cd /opt/zigbee2mqtt
    npm start

    I’ve done this just to see it connects to the mqtt server.

  7. Add the service.

    Edit /etc/systemd/system/zigbee2mqtt.service with something like:

    [Unit]
    Description=zigbee2mqtt
    After=network.target
    
    [Service]
    ExecStart=/usr/bin/npm start
    WorkingDirectory=/opt/zigbee2mqtt
    StandardOutput=inherit
    # Or use StandardOutput=null if you don't want Zigbee2MQTT messages filling syslog, for more options see systemd.exec(5)
    StandardError=inherit
    Restart=always
    User=pi
    
    [Install]
    WantedBy=multi-user.target
  8. Start the service:

    sudo systemctl start zigbee2mqtt
  9. Check it’s working:

    systemctl status zigbee2mqtt.service
  10. If all is ok, then enable the service:

    sudo systemctl enable zigbee2mqtt.service

Notes

  1. If you run zigbee2mqtt from root, redo sudo chown -R pi:pi /opt/zigbee2mqtt because the logs created will be owned by root :)

  2. If the service doesn’t work, then check it with the status command above. You can also see the error in:

    sudo journalctl -u zigbee2mqtt.service -f

HTH,

Share on

A little experiment: