


To read the temperature from within a Bash script you can use: temp=$(('cat /sys/class/thermal/thermal_zone0/temp'/1000)) Once you have the temperature value in the variable you print it to the screen, log to a file or send to a database. If you want to round the value to one decimal place you can add the line: cpu_temp = round(cpu_temp, 1) Simply import the library at the top of your script: import gpiozero as gzĪnd then read the temperature into a variable: cpu_temp = gz.CPUTemperature().temperature It’s fairly easy to read the Pi CPU temperature in Python using the Gpiozero library. You can change the values at which the warning colours are triggered. Right click on the Temperature in the top panel.You can change the thresholds and the colours used by: I used Spacers with a size of 10 to provide a sensible gap between the temperature reading and the surrounding panel items. Use the “Preferences” button to set the size of the spacer.Use the “Up” or “Down” buttons to position the spacer.Scroll down the list and select “Spacer”.If you want to add some space between the panel items you can: Use the “Up” button to position the monitor above the “Digital Clock”.Scroll down the list and select “Temperature Monitor”.In this example the temperature of my Pi is 35 degrees Celsius. This makes it really easy to keep an eye on the value as you perform different tasks: If you are using the Raspberry Pi OS desktop you can add a temperature gauge to the top panel where the clock is displayed. Add Temperature Display to Raspberry Pi OS Desktop This will show the temperature and update the value every 2 seconds. If you want to constantly monitor the temperature you can use the watch command: watch -n 2 vcgencmd measure_temp

This then outputs only the characters that are numbers surrounding a full stop (period) character. This feeds the output of vcgenmd to egrep. To extract the number you can use: vcgencmd measure_temp | egrep -o '*\.*' This will display the temperature in degrees Celsius: temp=31.0'C The easiest way to determine the temperature of your Raspberry Pi is by using the following command in a terminal window : vcgencmd measure_temp The Pi 4 will start to throttle the performance if the temperature exceeds 80 degrees so it is wise to keep an eye on your system temperature. This article aims to provide some easy techniques to monitor the temperature of your Pi.

As the Raspberry Pi has become more powerful temperature management has become more important.
