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

2
  • 1
    The two paths you show are not the same, are you aware of this?
    – PMF
    Mar 4, 2020 at 15:13
  • 1
    @PMF: That was a copy'n'paste error, I edited my question. Thanks for the hint.
    – B--rian
    Mar 4, 2020 at 15:18

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.