首页 > 其他 > 详细

树莓派-获取CPU和GPU温度

时间:2015-02-04 21:56:25      阅读:563      评论:0      收藏:0      [点我收藏+]



CPU的温度可以从一个系统临时文件中读取:/sys/class/thermal/thermal_zone0/temp

GPU温度也可以从一个文件中读取:/opt/vc/bin/vcgencmd measure_temp

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
  
def get_gpu_temp():
    gpu_temp = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' )
    return  float(gpu_temp)
  
def main():
    print "CPU temp: ", str(get_cpu_temp())
    print "GPU temp: ", str(get_gpu_temp())
  
if __name__ == '__main__':
    main()


树莓派-获取CPU和GPU温度

原文:http://blog.csdn.net/bnanoou/article/details/43489235

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!