Created
September 19, 2012 10:49
-
-
Save dweeber/3748975 to your computer and use it in GitHub Desktop.
Bash script uses vcgencmd on Raspberry Pi with bc to calculate F value of Temp
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
#!/bin/bash | |
###################################################################### | |
# Raspberry Pi | |
# | |
# Gross Script by Dweeber (Kevin Reed) <[email protected]> | |
# V1.0 2012-09-19 | |
# | |
# Use the vcgencmd to obtain the Temp of the SOC | |
# then calculates the F value using bc. | |
# | |
# Requires bc to be loaded. If not then | |
# apt-get install bc | |
# | |
###################################################################### | |
tm=`/opt/vc/bin/vcgencmd measure_temp` | |
tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'` | |
tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc) | |
echo temp = $tf\'F \($tc\'C\) |
Tried to use markdown in the last comment which obviously didn't work. Just disregard the stars and backticks.
without relying on vcgencmd
or bc
:
awk '{printf("%.1f\n",$1/1e3)}' /sys/class/thermal/thermal_zone0/temp
or even
awk '{printf("%.1f °F\n",$1*1.8/1e3)}' /sys/class/thermal/thermal_zone0/temp
in the colonies.
You left out a constant:
awk '{printf("%.1f°F\n",(($1*1.8)/1e3)+32)}' /sys/class/thermal/thermal_zone0/temp
That will get you the temperature in degrees Fahrenheit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a) Why use 4 steps if you can do it in two:
b) degrees temperature is abbreviated as "°'" and not "'*"