Here is some holiday fun with the Pi Pico, I decided to hook up to it some sensor to it in order to monitor the children bedroom temperature, and thought it is a good occasion to mess around with MQTT and dashboards.
I pulled my electronics box and had to dig a little in some components and Pi documentation to make sure I’ve got the correct resistors…ah! I didn’t want to fry anymore of these microcontroller boards. After that put together some basic Python code to connect to my LAN, imported the correct sensor libraries, read from the GPIO and pushed out the messages to my MQTT broker on Ubuntu…
Done, that was easy! Other solution would have been to convert the temp sensor signal from analog to digital but that was not the point here, so decided to cut corners with a library. You can find the code in my github repo if you wish.
Above we could see the feed coming in nicely on my Ubuntu machine after stopping all firewall processes, but indeed this is a bit ugly so I spun up another VM running docker and got Grafana, I followed the instructions here: https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/
At first I though the docker containers networking would give me some grief but not at all, all interfaces and ip-routes were correctly populated so you could access from a container to your LAN and internet in and out… great! I could access to my Grafana on anotherVM:3000 and started the set-up: I had to connect it to the MQTT data source, which was easy with tcp://mqttbrokerhost:1883 , selected the correct topic, and that’s it, I do not even have to configure the JSON “pick-up” between humidity and temperature Grafana seems to do it for me straight away.
One thing I’ve noticed is that Grafana does not “keep” the data as a timeserie, it continuously refreshes, which ruins my timelines, so the only data available to see in a way is the latest “pulse” or “reading” from MQTT… I suspected I could sort it with Prometheus and HiveMQ, but this was more set-up so left it for another day!