Monitoring Raspberry Pi temperature over mqtt

Hello, My dear fellow Raspberry Pi fan! hope your Pi-iot-hacking is going well.

Here is one from my side, read on…

I run so many things on my poor little raspberry pies and they often get heated up with all the burden I put on them. Since they are running headless, I don’t really know if it is on the verge of getting fried till it is too late. so after a couple of overheating instances, I started thinking, … How do I solve this issue?

As a first step, I came up with this simple hack which is a short nodejs script to monitor raspberry pi CPU temperature remotely.

Here is the link : pi_temp_logger

This runs as an autostarting Linux(Raspbian) service on raspberry pi which measures CPU temperature and posts to a configured MQTT broker topic Note: you can configure your broker and topic in

I use mqtt-spy to monitor and generate the graphs. feel free to get in touch with me if you are having any issues with using this by opening an issue.

Here is a screenshot of my Pi temperature increasing because of the dd command I used to stress the CPU [ awesome plots you see here are the courtesy of mqtt-spy ].

For detailed instructions on how to install the project, you can head to the git repo.

But it is not enough to know that it is heating up. We need to act on it, so for that part, I am planning to attach a fan to the raspberry pi and run it when the temperature goes beyond a particular threshold. Apart from the temperature, I believe knowing which process is loading the CPU is might help so I am thinking it might be a good idea to add the top 3 processes by CPU usage to the MQTT message. which might look something like this …

   "temperature" : "32.2",
   "units" : "celsius",
   "processes": [
               "command":"/usr/bin/dd ...",

what do you think? any suggestions? feel free to use the comments section to let me know. thanks for stopping by.

One thought on “Monitoring Raspberry Pi temperature over mqtt

Leave a Reply

Your email address will not be published. Required fields are marked *