How to Find the Temperature of a Raspberry Pi

Published December 21, 2024

This blog post will show you how to find the temperature of a Raspberry Pi.

Find the temperature of Raspberry Pi

Why do we need to check the CPU temperature of a Raspberry Pi?

A Raspberry Pi can heat up fast, especially if it has CPU-intensive or long-running programs. If the temperatures cross a certain threshold, it can permanently damage your Raspberry Pi and do more harm to the surroundings.

🥵

It is a good idea to monitor the CPU temperature. It is also very beneficial to add heat sinks and fans to keep the temperature below 50 degrees Celsius.

Read file /sys/devices/virtual/thermal/thermal_zone0/temp

The simplest way is to read the text file /sys/devices/virtual/thermal/thermal_zone0/temp.

I am testing this with my very first Raspberry Pi model B, ordered in February 2012.

pi@firstrpi:~ $ cat /sys/devices/virtual/thermal/thermal_zone0/temp
44388

The temperature is 44.388 Celsius.

To convert it to Fahrenheit, use the expression (C × 9/5) + 32.

(44.388 × 9/5) + 32 gives us 111.898°F.

vcgencmd measure_temp

The utility vcgencmd is installed under /usr/bin and you can verify it here:

pi@firstrpi:~ $ whereis vcgencmd
vcgencmd: /usr/bin/vcgencmd /usr/share/man/man1/vcgencmd.1.gz

To find the temperature using the vcgencmd tool, run this:

pi@firstrpi:~ $ vcgencmd measure_temp 
temp=44.9'C

Displaying the temperature as a decimal number using grep

If you want just the temperature as a decimal number, we can use grep with regex to filter out the rest:

vcgencmd measure_temp | grep -E -o '[0-9]{,3}\.[0-9]{,3}'

Output:

pi@firstrpi:~ $ /usr/bin/vcgencmd measure_temp | grep -E -o '[0-9]{,3}\.[0-9]{,3}'
44.4

Displaying the temperature as a decimal number using awk

You can also strip out the excess text using awk.

vcgencmd measure_temp|awk -F '=' '{print $2}'|awk -F "'" '{print $1}'

Output:

pi@firstrpi:~ $ vcgencmd measure_temp|awk -F '=' '{print $2}'|awk -F "'" '{print $1}'
43.3

Monitor your Raspberry Pi temperature every 20 seconds

If you want to monitor your Raspberry Pi temperature every x seconds and update the value in the terminal, use the watch command.

watch -n 20 vcgencmd measure_temp

My Raspberry Pi is too hot. What can I do to reduce the temperature?

With Raspberry Pi 3, 4 and 5, it is a good idea to add heat sinks and a fan. If possible, invest in good brands with highly rated reviews.

On my kids' Raspberry Pi 3 and 4, I have heat sinks and fans running. That is just to keep everything safe.

Conclusion

If you have other ways to find the temperature of your Raspberry Pi, please add your comment in the comment section below. Thanks for reading.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Last Updated: December 21, 2024.     This post was originally written on December 20, 2024.