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.
A ridiculous amount of coffee was consumed in the process of building this post/project. Add some fuel if you'd like to keep me going!