How to find out Raspberry Pi GPU and ARM CPU temperature on Linux

See all Raspberry Pi releated tutorials
I am using a Raspberry PI 2/3 credit size computer. How do I find out my Raspberry PI GPU or CPU temperature from Linux operating system command line option? How do I monitor the core temperature of my Raspberry Pi 3 or 4 device?

The Raspberry Pi is a small and affordable computer for student and hobbyist. You can us it to learn programming, Linux, sysadmin and devops stuff. This page explains Linux comamnd for the Raspberry Pi to find out GPU and ARM CPU core temperature.
Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux terminal
Category Raspberry Pi
OS compatibility AlmaLinux Alpine Arch Debian Fedora Linux Mint openSUSE Pop!_OS Raspberry Pi OS, RHEL Rocky Stream SUSE Ubuntu
Est. reading time 2 minutes

How to show Raspberry Pi GPU temperature

Open the Terminal application and type the following command to view GPU (Graphics Processing Unit) temperature:
$ vcgencmd measure_temp
OR
$ /opt/vc/bin/vcgencmd measure_temp
Sample output:

Fig.01: Find Raspberry pi GPU temperature

Fig.01: Find Raspberry pi GPU temperature

If you get an error that reads as “-bash: /opt/vc/bin/vcgencmd: No such file or directory“, try using the type command or find command to locate the path to the vcgencmd command in Linux. For example:
$ type vcgencmd
Outputs:
/usr/bin/vcgencmd
$ sudo find / -type f -name vcgencmd -ls
Outputs:
12303 16 -rwxr-xr-x 1 root root 13948 Mar 22 23:03 /usr/bin/vcgencmd

Parsing the GPU temperature outputs

Use the grep command or egerp command as follows to get only digits:

vcgencmd measure_temp | grep  -o -E '[[:digit:]].*'
vcgencmd measure_temp | egrep  -o  '[[:digit:]].*'

We can combine with the printf command or echo command as follows:

echo "The GPU temp: $(vcgencmd measure_temp | grep  -o -E '[[:digit:]].*')"
gpu_temp="$(vcgencmd measure_temp | grep  -o -E '[[:digit:]].*')"
printf "The GPU temp: %s\n" "$gpu_temp"

Display Raspberry Pi ARM CPU temperature

Type the following “cat“, “less“, “more“, or “bat command“. For example:
$ cat /sys/class/thermal/thermal_zone0/temp
Divide it by 1000 to get the ARM CPU temperature in more human readable format:

cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((cpu/1000)) c"

Sample outputs:

Fig.02: Check on the ARM CPU temperature of Raspberry Pi

Fig.02: Check on the ARM CPU temperature of Raspberry Pi

Raspberry Pi temperature monitor made easy

Want to measure the temperature of Raspberry Pi SBC continuously on your device? Try the watch command:

watch -- 'vcgencmd measure_temp'
watch -c -b -d  -n 1 -- 'vcgencmd measure_temp'
Where,

  • -c : Display output in color if possible
  • -b : Make a beep if command has a non-zero exit status (error)
  • -d : Highlight changes between updates
  • -n 1 : By defaults, updates are made every 2 seconds. Pass the -n 1 option to get wait between updates to 1 second.
  • -- : The double dash “--” means “end of command line flags.” See, “What Does ‐‐ (double dash) Mean In SSH Shell Command?” for more info.

Raspberry Pi get CPU temperature – Putting it all together

Create a simple bash script called my-pi-temp.sh to see both ARM CPU and GPU temperature of Raspberry Pi. Type the following command:
$ nano my-pi-temp.sh
OR
$ vi my-pi-temp.sh
Append the following code:

#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3 
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
## ******************************************* ##
## NOTE : ADJUST " /opt/vc/bin/vcgencmd " path ##
## ******************************************* ##
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"
Save and close the file by pressing the Esc+:x+[Enter] when using vi/vim as text editor. Set permission using the chmod command:
$ chmod -v +x my-pi-temp.sh
Run .sh shell script code as follows:
$ ./my-pi-temp.sh
Sample outputs:

Thu 10 Mar 01:02:19 IST 2016 @ raspberrypi
-------------------------------------------
GPU => temp=44.4'C
CPU => 44'C

Conclusion

This page explained how to monitor the CPU and CPU core temperature of your Raspberry Pi. For more info see this VideoCore-Tools page. You can read help page offline too. Use the help command or man command:
$ man vcgencmd
$ vcgencmd --help

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

22 comments… add one
  • Devilholk Feb 28, 2017 @ 11:51


    def get_temp():
    with open('/sys/class/thermal/thermal_zone0/temp', 'r') as infile:
    return float(infile.read()) * 1e-3

    • Bald Feb 4, 2022 @ 17:32

      Raspios temperature cpu command and your work helped me too.

  • canuck Nov 21, 2020 @ 0:41

    To WATCH cpu temp:
    watch -n 1 vcgencmd measure_temp
    To WATCH clock speed in hertz:
    watch -n 1 vcgencmd measure_clock arm

  • CogRaok Dec 29, 2020 @ 22:52

    Three and a half year later…

  • alex Mar 22, 2021 @ 18:42

    Thank you for the scrip. Nicely done

  • vopro May 29, 2021 @ 21:41

    Good job
    Thank you

  • Mister Tim Feb 4, 2022 @ 17:32

    I wanted raspberry temperature cpu and your command helped me.

  • 10basetom Aug 27, 2023 @ 0:42

    Cool! Thanks for the article. My slightly revised code:

    cpu=$(</sys/class/thermal/thermal_zone0/temp)
    echo "$(date) @ $(hostname)"
    echo "-------------------------------------------"
    printf "CPU: %.1f'C\n" $((cpu/1000))
    echo "GPU: $(vcgencmd measure_temp | cut -d = -f2)"
    

    Changes:
    – Changed order (CPU first)
    – Added decimal precision to CPU to be consistent with GPU
    – Removed “temp=” from GPU

  • antti rytsola Mar 26, 2024 @ 18:34

    Works in Pi4. vcgencmd is no longer in /opt, so change

    echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"

    with

    echo "GPU => $(vcgencmd measure_temp)"

    Needs of course root or sudo.

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.