1

I am new to gpiozero. I successfully managed to make some LEDs blink, but I am struggling reading out the CPU temperature as described in the example at gpiozero.readthedocs.io.

My code is pretty short:

from gpiozero import CPUTemperature
from gpiozero.pins.pigpio import PiGPIOFactory
from time import sleep

factory = PiGPIOFactory(host='192.168.1.103')
myRes = CPUTemperature(min_temp=30, max_temp=90,pin_factory=factory)

print('Initial Raspberry Pi temperature: ' + str(myRes.temperature))
print('READY and waiting 10s')
sleep(2)

The error I receive is

[Errno 2] No such file or directory: '/sys/class/thermal/thermal_zone0/temp'

However, on the RasPi itself, I can see the mentioned device (and temperature):

pi@raspberrypi:~ $  cat /sys/class/thermal/thermal_zone0/temp
50464

What do I do wrong? How can I fix that issue? Does GPIO maybe require some additional parameter?

References

B--rian
  • 125
  • 5

1 Answers1

4

Unfortunately the CPUTemperature class does not support reading from a remote Pi, even if you provide a remote pin factory.

There's an issue to add it but it's probably not a priority: https://github.com/gpiozero/gpiozero/issues/581

For now you can try doing it with pigpio itself: http://abyz.me.uk/rpi/pigpio/python.html#file_open

ben_nuttall
  • 2,451
  • 12
  • 15