Created
June 16, 2020 20:28
-
-
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+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On retropie, the default
.bashrc
file already defines a functionretropie_welcome
which provides key system metrics including the temperatures.