Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xd547
Created November 6, 2018 17:08
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 xd547/fb91b834085923321dbbf7b73cb20349 to your computer and use it in GitHub Desktop.
Save xd547/fb91b834085923321dbbf7b73cb20349 to your computer and use it in GitHub Desktop.
Get Raspberry Pi temperature
#!/bin/sh
GetCPUTemp() {
value=`cat /sys/class/thermal/thermal_zone0/temp | tr -d '\n'`
cpu_temp=`awk "BEGIN {print $value/1000.0}"`
echo "$cpu_temp"
}
GetGPUTemp() {
gpu_temp=`vcgencmd measure_temp |sed -e "s/temp=//g" | sed -e "s/'C//g"`
echo "$gpu_temp"
}
printf "CPU %.1fC GPU %.1fC\n" $(GetCPUTemp) $(GetGPUTemp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment