RPi CPU Temperature monitoring - simple but informative

I have, just like many of us, several RPi's scattered around. Some are placed outdoor, indoor, in the ground and up in the attic. In total I counted to 10, crazy, really tried to re-think, well some got eventually be merged but I need at least 8. So, decided to keep it as is.
I really wanted to check if they all are working in an acceptable environment. Up here in the North the seasonal conditions can vary a bit, from cold winter to hot summer, especially in our attic

So I decided to throw some simple stuff together. In each RPi I have this little minimalistic flow (in addition to all the many other flows), reporting the CPU temperature every minute via MQTT. Please note, for each RPi I set a unique topic (basically the RPi name or main function)

[{"id":"cc61ba3e.287248","type":"inject","z":"9d2e48e4.b9a108","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":80,"wires":[["fd25ffe9.ce945"]]},{"id":"fd25ffe9.ce945","type":"exec","z":"9d2e48e4.b9a108","command":"vcgencmd","addpay":false,"append":"measure_temp","useSpawn":"false","timer":"","oldrc":false,"name":"","x":390,"y":80,"wires":[["d4ad47cb.fd87b8"],[],[]]},{"id":"d4ad47cb.fd87b8","type":"change","z":"9d2e48e4.b9a108","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"pitemp/video","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":80,"wires":[["846ef75c.484818"]]},{"id":"846ef75c.484818","type":"mqtt out","z":"9d2e48e4.b9a108","name":"","topic":"","qos":"","retain":"","broker":"3e8f923b.c168be","x":940,"y":80,"wires":[]},{"id":"d1207303.f6b73","type":"comment","z":"9d2e48e4.b9a108","name":"CPU Temperature","info":"","x":170,"y":40,"wires":[]},{"id":"3e8f923b.c168be","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.240","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Next is to collect & present all those MQTT messages. I decided to make a simple GUI view using the dashboard. It will definitely not win a beauty contest but it serves it's purpose. Please note you have to edit the switch node fitting the topic names you used earlier in each RPi

This is how it looks like when monitoring my 10 RPi's

This is the flow:

[{"id":"6858b37c.01ff9c","type":"mqtt in","z":"7a8a9447.6244fc","name":"","topic":"pitemp/#","qos":"2","datatype":"auto","broker":"3e8f923b.c168be","x":140,"y":90,"wires":[["897db7c5.182918"]]},{"id":"bf7c8aa8.0d36f8","type":"switch","z":"7a8a9447.6244fc","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"nodered","vt":"str"},{"t":"eq","v":"automation","vt":"str"},{"t":"eq","v":"CE50","vt":"str"},{"t":"eq","v":"hass","vt":"str"},{"t":"eq","v":"motion1","vt":"str"},{"t":"eq","v":"motion2","vt":"str"},{"t":"eq","v":"motion3","vt":"str"},{"t":"eq","v":"motion4","vt":"str"},{"t":"eq","v":"video","vt":"str"},{"t":"eq","v":"vpn","vt":"str"}],"checkall":"true","repair":false,"outputs":10,"x":570,"y":590,"wires":[["7662ff31.a1bef","c4a4293a.3f9958"],["7e17c7cb.525418","7b0d0939.e915c8"],["30f31b47.9ba184","41683b32.c552e4"],["6d71dffc.7752e","efc4fe8d.897fe"],["9a5e8bd0.5b0498","70b1baf1.aeec84"],["41b83de.a98d8c4","7c812fc6.50766"],["b7246981.03ac38","9616682b.7e4e48"],["7339b65e.07ace8","dd100ecb.99be"],["52790f3f.9179e","fccf0c27.9ae49"],["479c96af.cae618","9d8db8c0.c57d38"]]},{"id":"24715fe.910fba","type":"debug","z":"7a8a9447.6244fc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":820,"y":90,"wires":[]},{"id":"c4a4293a.3f9958","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":1,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}}  &deg</font>","layout":"row-spread","x":820,"y":160,"wires":[]},{"id":"897db7c5.182918","type":"function","z":"7a8a9447.6244fc","name":"","func":"let t = msg.payload.split('=')[1].split(\"'\")[0];\nlet tp = msg.topic.split('/')[1];\nmsg.topic = tp;\nt = parseFloat(t);\nmsg.payload = t;\nmsg.color = 'green';\nif(t>62.0){\n    msg.color = 'red';\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":90,"wires":[["bf7c8aa8.0d36f8","24715fe.910fba","2dd60503.d0f94a"]]},{"id":"7662ff31.a1bef","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":210,"wires":[["a4a54673.59ba68"]]},{"id":"a4a54673.59ba68","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":210,"wires":[["c4a4293a.3f9958"]]},{"id":"7e17c7cb.525418","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":3,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}}  &deg</font>","layout":"row-spread","x":820,"y":250,"wires":[]},{"id":"7b0d0939.e915c8","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":300,"wires":[["e89811db.1d236"]]},{"id":"e89811db.1d236","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":300,"wires":[["7e17c7cb.525418"]]},{"id":"30f31b47.9ba184","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":5,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":340,"wires":[]},{"id":"41683b32.c552e4","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":390,"wires":[["548a224a.cdeb9c"]]},{"id":"548a224a.cdeb9c","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":390,"wires":[["30f31b47.9ba184"]]},{"id":"6d71dffc.7752e","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":7,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":430,"wires":[]},{"id":"efc4fe8d.897fe","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":480,"wires":[["9260fa22.18d368"]]},{"id":"9260fa22.18d368","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":480,"wires":[["6d71dffc.7752e"]]},{"id":"9a5e8bd0.5b0498","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":9,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":520,"wires":[]},{"id":"70b1baf1.aeec84","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":570,"wires":[["9a7c98e1.8d3cc8"]]},{"id":"9a7c98e1.8d3cc8","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":570,"wires":[["9a5e8bd0.5b0498"]]},{"id":"41b83de.a98d8c4","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":11,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":610,"wires":[]},{"id":"7c812fc6.50766","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":660,"wires":[["43c14877.73ef28"]]},{"id":"43c14877.73ef28","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":660,"wires":[["41b83de.a98d8c4"]]},{"id":"b7246981.03ac38","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":13,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":700,"wires":[]},{"id":"9616682b.7e4e48","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":750,"wires":[["cb9283d5.7593"]]},{"id":"cb9283d5.7593","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":750,"wires":[["b7246981.03ac38"]]},{"id":"7339b65e.07ace8","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":15,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":790,"wires":[]},{"id":"dd100ecb.99be","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":840,"wires":[["370575b.b00178a"]]},{"id":"370575b.b00178a","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":840,"wires":[["7339b65e.07ace8"]]},{"id":"52790f3f.9179e","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":17,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":880,"wires":[]},{"id":"fccf0c27.9ae49","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":930,"wires":[["aa350a09.5c87d8"]]},{"id":"aa350a09.5c87d8","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":930,"wires":[["52790f3f.9179e"]]},{"id":"479c96af.cae618","type":"ui_text","z":"7a8a9447.6244fc","group":"d4fdb2d8.a04b5","order":19,"width":6,"height":1,"name":"","label":"{{msg.topic}}","format":"<font color= {{msg.color}} > {{msg.payload}} &deg</font>","layout":"row-spread","x":820,"y":970,"wires":[]},{"id":"9d8db8c0.c57d38","type":"trigger","z":"7a8a9447.6244fc","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"2","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":840,"y":1020,"wires":[["f159e056.9fec4"]]},{"id":"f159e056.9fec4","type":"change","z":"7a8a9447.6244fc","name":"Set colors","rules":[{"t":"set","p":"color","pt":"msg","to":"yellow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":1020,"wires":[["479c96af.cae618"]]},{"id":"a7ae1654.c6eb18","type":"ui_chart","z":"7a8a9447.6244fc","name":"","group":"3fe1048d.ab47bc","order":1,"width":0,"height":0,"label":"{{msg.topic}}","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":570,"y":390,"wires":[[]]},{"id":"2dd60503.d0f94a","type":"smooth","z":"7a8a9447.6244fc","name":"","property":"payload","action":"mean","count":"10","round":"","mult":"multi","reduce":false,"x":570,"y":340,"wires":[["a7ae1654.c6eb18"]]},{"id":"3e8f923b.c168be","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.240","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d4fdb2d8.a04b5","type":"ui_group","z":"","name":"Pi Temperature monitoring","tab":"9d47adbb.46b33","order":1,"disp":false,"width":8,"collapse":false},{"id":"3fe1048d.ab47bc","type":"ui_group","z":"","name":"Chart","tab":"9d47adbb.46b33","order":2,"disp":false,"width":18,"collapse":false},{"id":"9d47adbb.46b33","type":"ui_tab","z":"","name":"Pi Temperature monitoring","icon":"dashboard","disabled":false,"hidden":false}]
7 Likes

Brilliant project, so simple but so very useful.

1 Like

Thank you very much David!
Actually interesting to see the cpu temp changes depending on tasks currently active. I notice for instance that when my ip cameras (via Motion) is providing images with "suspicious movements" during night, there is something more than usual for the RPi's to digest. But they are all doing great!

Nice use of @BartButenaers's node-red-contrib-vcgencmd
Its a very useful node to monitor system health. I am using it, together with a pushover node to send alerts to my phone.

out of curiosity, why do you need 10 raspberries?

10 is quite a reasonable number to have around a house - I have 3 in my kitchen alone :slight_smile:

7 Likes

So you have node-red install on every Pi? Does that not seem like over kill? Why not a small python script or such to drive MQTT messages back to your single, main, node-red instance?

1 Like

Note that you can do something rather similar on other platforms (i.e. not RPI only), by using my node-red-contrib-cpu node. Because as you can see here, that node also can output the cpu temperature.

Nice,
I have made myself something similar with you also can monitor used ram and free disk space.

@Nodi.Rubrum, that's what I did also. On the Pi's other then where Node-red is running I have a python script that will publish the data to the mqtt broker, no need for node-red on these pi's.

@cymplecy, 10 !, what are you running on all those pi's then? Crypto coin mining or something like that :wink:

4 Likes

As an alternative for monitoring, I can also recommend Telegraf.
I have it installed on most of my hosts, and also works nice on Pis.

The cool thing about it is its plug-in based configuration. So you can select which data to collect, and where to send it.
It also has an MQTT output, so I don't have to store everything in InfluxDB, if I just want some live data for my dashboard.

1 Like

Why bother? It is easier to do it with node-red.

1 Like

Not sure who you were replying to to but in my case, yes - I have Node-RED installed on all my house #Iot Pi (which are all PiZero with WiFi dongle or PiZeroW)

Got 3 in kitchen - two controlling plinth/work surface illumination - one with IR Send/Receive and a PIR sensor on it)
1 in Living room receiving messages from Pi in the kitchen or Alexa and controlling my SkyQ box via IR
1 in bedroom just being used to send 433Mhz signals out to a mains socket/plug
1 in computer/playroom sending 433Mhz to all other mains sockets in the house
1 outside controlling water feature lighting
And 1 Pi4 running the browser sessions to administer them all plus testing out flows/nodes

I'll have a lot soon, the bees have been pollinating the bushes like crazy. :pie: :rofl:

2 Likes

Hi,
node-red-contrib-cpu can read the temperature from raspi core too.
Holger

ps: i seen that answer above too.

@cymplecy
Good to know. I have been thinking about putting node-red on every data collection Pi I have as well. I have quite a bit of Python scripting that works well right now, feeding various sensors per Pi into a remote database. But have been thinking about do more with node-red recently.

I need to write nodes for some of the python based stuff I have now, looking forward to doing that, as well as drive I2C devices via node-red, driving various relays and even using RPITX to emulate fan controllers using 303.875 mhz.

That is the really great news of today!!! Then there will be a day also after tomorrow! Sadly read that 50 million bees just died in Croatia, thats really a disaster. Being a bee fan!

Same for me, I do the same. But I use Node-RED in addition to monitor them and that they are working correctly. If they would fail/crash (never happens but anyway...) Node-RED sends an alert to my phone via Telegram and restarts the script. Works very elegant

Just an idea, if you want to reduce cost and overkill, you could try using arduino's instead of RPi's when you just need to turn something on/off. I use a central RPi and several arduino nano's around the house. They talk using MQTT. You can get wifi or ethernet shields - I think there are some arduino's with the wifi built-in. I feel like this setup is also easier to maintain code-wise.

Or an even cheaper solution is the Wemos D1 Mini (ESP8266 based microcontroller) with built-in WiFi.
It talks via MQTT to Node-RED really easily (if flashed with ESP Easy or Tasmota).

how do you power those if you have many of them at different locations?