Using munin to visualize your arduino sensor data

ESP32 Development Board WiFi+Bluetooth Ultra-Low Power Consumption Dual Cores ESP-32 ESP-32S Board
Integrated antenna and RF balun, power amplifier, low-noise amplifiers, filters, and power management module. The entire solution takes up the least amount of printed circuit board area. This board is used with 2.4 GHz dual-mode Wi-Fi and Bluetooth chips by TSMC 40nm low power technology, power and RF properties best, which is safe, reliable, and scalable to a variety of applications.
I was looking for the easiest way to visualize the sensor data my arduino in the basement is sending to the linux server. The server receives a data triple every few seconds which I write to a log file using cat:

cat /dev/ttyUSB0 > /var/log/datalogger.log

and the result looks like this:

...
0.10 58.60 23.00
0.25 58.60 23.00
0.22 58.60 23.00
0.21 58.60 23.00
...

The first value is the power consumption of my drying machine, the second is the humidity and the third the temperature in the basement. You could use Processing to do wonderful visual presentations of your data, but I was afraid of the learning curve to handle Processing. So I looked for an easier solution, one that would let me access the data even from abroad. Munin seemd to be the perfect solution. After installing munin I had to add a plugin that would read the data triple from the file. For each of the values I created a little script in /etc/munin/plugins:

#!/bin/sh

case $1 in
   config)
        cat <<'EOM'
graph_title Humidity 
graph_vlabel humidity 
humidity.label humidity
EOM
        exit 0;;
esac

echo -n "humidity.value "
tail -n 1 /var/log/datalogger.log |  cut -d' ' -f2

Explanation: The config block defines titles and labels for the graph. The echo -n “humidity.value” defines the label for the current value. The tail command reads the last line from the data file and the cut command splits the line at every space. “-f2” takes the second value. And this is the resulting graph:

Munin sensor data – weekly view

Note: there are some gaps in the graph, because I’m using a log mover, that moves the file whenever it becomes bigger than 1MB. Now the cat command doesn’t know about the moving and keeps writing into the old file until I restart the cat command.

Posted by squix78

Leave a Reply