from gpiozero import CPUTemperature
# get the temperature of the CPU of the Raspberry
def getRaspiCpuTemperature():
tempFile = open("/sys/class/thermal/thermal_zone0/temp")
cpu_temp = tempFile.read()
tempFile.close()
return (float(cpu_temp) / 1000)
# get the temperature of the CPU of the Raspberry
# with gpiozero
def getRaspiCpuTemperature02():
gpiozero_cpu = CPUTemperature()
return (gpiozero_cpu.temperature)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter