Skip to content

Instantly share code, notes, and snippets.

@ouyi
Created June 16, 2020 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouyi/295805fbd1d05e9c4cdb1ba50746724f to your computer and use it in GitHub Desktop.
Save ouyi/295805fbd1d05e9c4cdb1ba50746724f to your computer and use it in GitHub Desktop.
Bash script for displaying the CPU and GPU temperatures of Raspberry Pi 3B+
#!/usr/bin/env bash
# Display the CPU and GPU temperatures of Raspberry Pi 3B+
set -e
cpu_temp=$(</sys/class/thermal/thermal_zone0/temp)
cpu_temp=$(printf %.1f $((10 * cpu_temp/1000))e-1)
gpu_temp=$(vcgencmd measure_temp)
gpu_temp=${gpu_temp%"'C"}
gpu_temp=${gpu_temp#temp=}
celsius_sign=$'\xc2\xb0'C
echo "CPU temperature: $cpu_temp $celsius_sign"
echo "GPU temperature: $gpu_temp $celsius_sign"
@ouyi
Copy link
Author

ouyi commented Jun 20, 2020

On retropie, the default .bashrc file already defines a function retropie_welcome which provides key system metrics including the temperatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment