JetHub peripherals in MQTT via mqtt-io in Linux
You can use the mqtt-io project to route controller resources in MQTT.
Installing
sudo apt install python3-pip
sudo pip3 install mqtt-io
Manual start
Before running, you must unexport all GPIO from sysfs:
Warning
Example for D1/D1+ basic. See Configuration files for other controllers.
echo 436 452 453 454 455 456 462 467 469 470 471 472 | xargs -n 1 echo >/sys/class/gpio/unexport
Launch:
python3 -m mqtt_io /etc/mqtt-io.yaml
Automatic start via systemd
Note
We assume that mqtt-io itself and /etc/mqtt-io.yaml
are already installed.
Launch the editor:
sudo nano /etc/systemd/system/mqtt-io.service
Insert the following into it:
Warning
Example for D1/D1+ basic. For other controllers
ExecStartPre
must be replaced.See Configuration files for other controllers.
[Unit] Description=mqtt-io After=network.target [Service] ExecStartPre=sh -c "echo 436 452 453 454 455 456 462 467 469 470 471 472 | xargs -n 1 echo >/sys/class/gpio/unexport; exit 0" ExecStart=python3 -m mqtt_io /etc/mqtt-io.yaml StandardOutput=inherit StandardError=inherit Restart=always User=root [Install] WantedBy=multi-user.target
Starting the service:
sudo systemctl enable mqtt-io sudo systemctl start mqtt-io
We look at the logs:
sudo journalctl -u mqtt-io -f
Configuration files
Note
Remember to change host
, user
, password
to match your MQTT server settings.
JetHub D1/D1+ basic
Unexport
echo 436 452 453 454 455 456 462 467 469 470 471 472 | xargs -n 1 echo >/sys/class/gpio/unexport
Limitations
One of the CPU cores can be as high as 40-60% (github issue).
Unable to use GPIO through sysfs at the same time.