Using munin to visualize your arduino sensor data

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:


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

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.

Related:  RTL-SDR: Quick Guide to Software Defined Radio on Mac OS X Yosemite

Now a beer! Did you like this post? It often takes me several hours of my free time to write one. If I was your neighbour would you offer me a beer for the hard work I did for you? The beauty is: beers can be teletransported with a painless donation using Paypal. A beer in a Swiss bar costs about USD $4.80. Or use this affiliate link if you order something on Banggood and I'll get a small kickback. Thank you!