MQTT services - DoESLiverpool/somebody-should GitHub Wiki
MQTT is a lightweight publish/subscribe messaging protocol applicable to many scenarios such as controlling and monitoring all the equipment in the space.
- See Sonoff switches for MQTT controlled mains power monitors and switches.
- See ESP devices for accounts of the ESP8266 and ESP32s in operation
mqtt.local
There is a RaspberryPi wired into the network in the main room by the TV with the mDNS name "mqtt.local". It is set up from ballina and has no SSH access. Its ipnumber was 10.0.30.194. Sometimes the mDNS service fails, but can be fixed by power cycling it.
When it was programmed to have a wifi access point, its ssid was "DoESLiverpool-MQTT" and the ip-number was "10.3.141.1".
MQTT Broker
There is an MQTT broker on the mqtt.local RaspberryPi. The various sensors and sonoff switches can interact with it over the network. You can also interact with it over the command line:
Install mosquitto and then try the following commands:
To see all messages, type: mosquitto_sub -v --host mqtt.local --topic '#'
(sometimes you need mqtt.localdomain) To see all messages about ip-numbers, try the topic '+/ip'
.
To publish a message, type: mosquitto_pub --host mqtt.local --topic this/that/777 -m "Hooray"
Node-red
The mqtt.local RaspberryPi also has an instance of node-red capable of handling the MQTT messages and putting them into the database. Access it from http://mqtt.local:1880/
. The MQTT receiving nodes are
InfluxDB
The mqtt.local RaspberryPi also has a time series database on it called InfluxDB that node-red can post into on port 8086 username/password root, database name balena-sense
. This has been running for many weeks on the SDcard without any problems.
Grafana
The mqtt.local RaspberryPi also has a UI for viewing time series data called Grafana that can access the InfluxDB instance on the same machine and present different graphs and dials. This requires going to http://mqtt.local/login
and getting the right login, which is admin, bubbl1n0. Then select the dashboard Does Power1
Dashboards
There is a RaspberryPi on the wall above the mqtt.local machine with an official 7inch touchscreen capable of showing a small dashboard view of the Grafana Does Power1 dashboard. It used to show the http://mqtt.local:1880/ui which interacted with the node-red control system.
Mains controlled devices
See Sonoff switches.
Other MQTT devices
The Electric Liver Bird
MQTT to voice device
like at: https://github.com/DoESLiverpool/somebody-should/issues/809
Galvo level
Also looks like a coffee level pointer. https://github.com/goatchurchprime/jupyter_micropython_developer_notebooks/blob/master/projects/mqtt2galvo.ipynb (Currently on loan.)
Doorbots
These don't yet have any MQTT responses, but should do, so we can plot them.
https://github.com/DoESLiverpool/somebody-should/issues/949
Video analysing devices
We have the tech to convert live stream to data (eg using a camera looking at the coffee pot). This needs to be rebuilt.
Old provisioning of the Rpi (before using Balena technology)
See also https://github.com/DoESLiverpool/somebody-should/issues/803
* Install raspbian and update, plugged into ethernet
* sudo raspi-config (to enable ssh and change hostname)
* ifconfig to get the ip number
* from: https://oneguyoneblog.com/2017/06/20/mosquitto-mqtt-node-red-raspberry-pi/
* sudo apt-get install mosquitto mosquitto-clients
* sudo apt-get install nodejs
* sudo apt-get install nodered
* sudo node-red (makes it run prior to reboot)
* sudo systemctl enable nodered.service
* sudo npm i -g [email protected]
* In localhost:1880 nodered menu manage pallette install, look for dashboard
* sudo apt-get install avahi-daemon
* sudo nano /etc/hosts; change 127.0.1.1 to host name "mqtt"
Install hotspot installer: https://github.com/billz/raspap-webgui
* wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap
* Connect to wifiname=raspi-webgui password=ChangeMe, then http://10.3.141.1/ Username: admin, password: secret
* Change so that wifiname=mqtt-wifi, password=bubblino; and Auth is admin, arduino
* node-red at http://10.3.141.1:1880/