Created
May 6, 2014 02:07
-
-
Save lsongdev/b9ad406b52c5e99d98c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import commands | |
def get_cpu_temp(): | |
tempFile = open( "/sys/class/thermal/thermal_zone0/temp" ) | |
cpu_temp = tempFile.read() | |
tempFile.close() | |
return float(cpu_temp)/1000 | |
# Uncomment the next line if you want the temp in Fahrenheit | |
#return float(1.8*cpu_temp)+32 | |
def get_gpu_temp(): | |
gpu_temp = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' ) | |
return float(gpu_temp) | |
# Uncomment the next line if you want the temp in Fahrenheit | |
# return float(1.8* gpu_temp)+32 | |
def main(): | |
print "CPU temp: ", str(get_cpu_temp()) | |
print "GPU temp: ", str(get_gpu_temp()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment