Saturday, March 28, 2015

Python to get core temperature of Raspberry Pi

On Raspberry Pi/Raspbian, the command "vcgencmd measure_temp" shows core temperature. It's a Python example to get current temperature.


import os 

#Get CPU temperature using 'vcgencmd measure_temp'                                      
def measure_temp():
    temp = os.popen('vcgencmd measure_temp').readline()
    return(temp.replace("temp=","").replace("'C\n",""))

print(measure_temp())



more:
- Display Raspberry Pi CPU temperature graphically, using Python 2 with Matplotlib

No comments: