Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to display cpu temperature with Python for raspberry pie

Shulou Source: shulou.com Published: 2022-06-01 22:57:11 10月25日 Update

This article will explain in detail how to use Python to display cpu temperature in raspberry pie. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Raspberry pie shows cpu temperature

You can view the cpu temperature through cat / sys/class/thermal/thermal_zone0/temp in the linux system terminal

View the gpu temperature through the command / 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 # 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=' Str (get_gpu_temp ()) if _ _ name__ = ='_ _ main__': main () about "how raspberry pie displays cpu temperature with Python" ends here. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Temperature raspberry article more good practical content available through command article knowledge system terminal reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Shulou Technology MySQL Microsoft