Skip to content

Instantly share code, notes, and snippets.

@andyspicer
Forked from dweeber/gist:3748975
Created October 30, 2016 00:00
Show Gist options
  • Save andyspicer/209635a1869a957c72e16ae1d5b4b9a5 to your computer and use it in GitHub Desktop.
Save andyspicer/209635a1869a957c72e16ae1d5b4b9a5 to your computer and use it in GitHub Desktop.
Bash script uses vcgencmd on Raspberry Pi with bc to calculate F value of Temp
#!/bin/bash
######################################################################
# Raspberry Pi
#
# Gross Script by Dweeber (Kevin Reed) <dweeber.dweebs@gmail.com>
# 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\)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment