Posts Tagged: Raspberry Pi

Sep 20

RPi Temperature Monitor

I wanted a way to track temperature changes on my Raspberry Pis, especially the one that was acting as a Touch Screen for my Bitfocus Companion host. It is in a small case, and I had recently installed a heatsink and fan to aid with heat disipation and so wanted to see how much of a difference it made over time. (Spoiler: The cooling is keeping the cpu core about 20ÂșC less than it would have been without it!)

The button as it appears on the stream deck

I already had Node Red in my network which is monitroing all sorts of things including temperature sensors, and it does this in tandem with an MQTT broker. So all I needed to be able to monitor my Raspberry Pis temperature and have it display anywhere I wanted, was to send the temperature value to MQTT and then have various clients subscribe to it.

I adapted a small python script from thingsmatic which I am using to monitor the CPU temperature on two of my suit of RPis. I say adapted – I just had to make sure I was using the full path for all executables used by the script and also make sure that the python module for sending the MQTT message was installed.

CPU Temperature over time, from a cold start, with heatsink and fans.

Architecturally it looks like this:

  • The Raspberry Pi runs a script via the cron. I am monitoring every 5 mins.
  • The script calls the vcgencmd to get the temperature and publishes this to an MQTT broker on the network.
  • Node Red is subscribing to the topic and adds updates to a line chart in the dashboard as they arrive.
  • Bitfocus Companion has an MQTT plugin which means I can subscribe to the topic that will contain the CPU temperature and update a variable when that value is seen on the network. I also added an action to the buton that would run the temperature check script on the Pi at an arbitrary point.

Main disavantages are that this solution will not work when I leave my home network. But it’s rare that I do that anyway these days!!