202103251635 - 获取树莓派温度

202103251635 - 获取树莓派温度

cat /sys/class/thermal/thermal_zone0/temp

取出值后除以 1000

Pasted image 20210325163653.png

写个脚本获取

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import commands
​
def main():
# 查看GPU温度
    gpu = commands.getoutput( '/opt/vc/bin/vcgencmd measure_temp' ).replace( 'temp=', '' ).replace( '\'C', '' )
    gpu = float(gpu)
    print('gpu Temp: %.2f ' % gpu)
	
# 查看CPU温度
    file = open("/sys/class/thermal/thermal_zone0/temp")
    cpu = float(file.read()) / 1000
    file.close()
    print('cpu Temp: %2.2f' % cpu)
​
if __name__ == '__main__':
    main()

https://my.oschina.net/zhenggao/blog/4336898


本站总访问量次 本站访客数人次 本文总阅读量