RPi-Tools, gpiozero and a rPi5

  • Hey all! I'll preface this by saying I'm not a coder, I just copy/paste whatever code I find and fiddle with it until it works πŸ˜†

    Hopefully a quick Q; is there a trick to getting gpiozero working on a Pi5?

    I'm running LibreELEC-RPi5.arm-11.0.6 with the RPi-Tools addon and I'm trying to get a PWM fan script to work. However, I'm getting a "RuntimeError: Cannot determine SOC peripheral base address" error anytime I try to run a script that references gpiozero (there are also Tracebacks, but I figured the Runtime error is the important one).

    I know that with the rPi5 they changed stuff with the GPIO so things like RPI.GPIO no longer works, but I was under the assumption gpiozero should be ok?

  • You need to force gpiozero to initialize lgpio with the correct chip. For this you need LE12 nightly, because lgpio is only part of the RPi tools from LibreELEC 12. This combination is currently the only one that supports RPi5 out of the box.

    To initialize the RP1 at the RPi5:

    Python
    from gpiozero.pins.lgpio import LGPIOFactory
    from gpiozero import Device, PWMLED
    Device.pin_factory = LGPIOFactory(chip=4)

    Additionally you have to circumstand this lgpio bug:

    Edited 3 times, last by HarryH (February 24, 2024 at 4:03 PM).