Raspberry Pi

Measure the Core Temperature of Your Raspberry Pi

Raspberry Pi is a single-board computer that can effectively run most applications on the system. However, with the passage of time, it’s performance may suffer once you put heavy load on it as this increases the core temperature of the device. In that case, shutting down the device once it cools down is an ideal way to protect your device from overheating.

In this article, we will show you different ways to measure core temperature of Raspberry Pi as this will help you keep a check on your device performance.

Measure the Core Temperature of Raspberry Pi

There are multiple methods to measure temperature on Raspberry Pi:

Method 1: Measuring Core Temperature Through Terminal

The “vcgencmd” is a command-line tool that is mostly used to measure the core temperature on Raspberry Pi: Typing the command in the following way will show you the core temperature of Raspberry Pi on the terminal:

$ vcgencmd measure_temp

If you want to see continuously monitor the temperature after some specific time, you can use the following

$ watch -n <time> vcgencmd measure_temp

This will display a window, where temperature changes can be monitored after every three seconds.

Method 2: Measure Temperature Through GUI

A temperature panel can also be added to the top right corner of the task bar on Raspberry Pi desktop to measure the core temperature of the device. In this way, the value of temperature can easily be viewed.

To add a temperature panel, Right Click on the taskbar and go to “Add/Remove Panel Items”.

Now Click on “Add” button.

Graphical user interface, website Description automatically generated

A new window will pop out, there you can scroll down and find the “Temperature Monitor”. Click on it and press “Add”.

After adding, you will see a temperature panel on the most top right corner of the taskbar. You can check through the below-given screenshot. This is a perfect way to continuously monitor Raspberry Pi core temperature on your system.

Method 3: Measuring Temperature Through Python Script

Measuring the temperature using Python is another useful way that requires few steps, which are given below:

Step 1: First you need to create a Python file with any name.

$ nano <file name>.py

A meas_temp.py file will be created in the root directory of Raspberry Pi, where you need to put the following lines.

import os

import time

def measure_temp():

temp = os.popen("vcgencmd measure_temp").readline()

return (temp.replace("temp=",""))

while True:

print(measure_temp())

time.sleep(<time delay>)

After writing the code in the file, use “CTRL + X” and “Y” to save the file.

Once the file is saved, you can run it using the following command:

$ python3 <file-name>.py

Text Description automatically generated with medium confidence

As code in the Python file was based on some time delay. In our case, we used 1 second time delay in our code that displays the core temperature of Raspberry Pi every 1 second.

Conclusion

To run Raspberry Pi at optimum performance, you must monitor the core temperature of the Raspberry Pi device, because most of the operations performed on the device through the CPU core. The above guide will help you measure the core temperature on Raspberry Pi through terminal, GUI, and Python script. You can choose any method you want as all are pretty easy to follow.

About the author

Muhammad Nasir

Hi! I am an engineer and technical blogger by profession and I enjoy getting things done with electronics. I am using this platform to share my knowledge in the field of Raspberry Pi, Linux, and Embedded Systems with others.