Monitoring temperatures with ruby and XRF
The hardware setup hasn't changed: a battery powered XRF + thermistor periodically sending LLAP messages with current temperature over radio to Raspberry Pi, where they get logged and processed. Previous software approach was to have a node.js application listen to messages, process them, log them, as well as act as a web server presenting the data to clients. However I was having a hard time making logging work the way I wanted, and figuring out how to make graphs was even more daunting. Another slightly annoying fact was that running a full node server with websockets and all was a bit of an overkill, and it resulted in not so fast (a couple of seconds) response times.
So, I tried a different approach that I like a lot so far. Different programs handling different parts of the task:
- A ruby script for listening on the serial port for messages (using serialport gem). The temperatures and voltages are logged to RRD database.
- Another ruby script that runs periodically to generate a static html page and refresh the graphs. It is extremely easy to generate nice graphs with rrdtool.
- A webserver to serve the generated static pages (at the moment lighttpd).
The project can be found on
github (UPDATE 2018-06-12T23:40:08 has been long gone - there are much better alternatives now). If you want to "deploy" this on your machine, you'll undoubtedly need to edit the scripts a little (adjust directories and such). The scripts are relatively straightforward though.