Control GPIO pins On raspberry pi 5

  • I am trying to set a gpio pin to true while my system is running. The porpuse is that I have an external controller that boots is when my tv is turned on but I need to know if the pi is allready on because otherwise it will do a shutdown.

    I have installed the add on raspberry pi tools but I cant get the gpio to work.

    I have the script.

    Python
    import sys
    sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
    from gpiozero import LED
    led = LED(17)
    led.on()


    This produces the error


    I Understand that this is because the hardware for rp5 is different but is there a possible method for doing this on the rp5.

    Any help would be greatly appriciated :)

  • Known issue:

    LuRu
    July 20, 2024 at 9:55 AM

    Pro tip: Always use the search function from the forums main page before posting anything.

  • It looks to me, that you are using LibreELEC 11. For RPi5 support, LE12 and the corresponding rpi-tools are needed. With a recent version of gpiozero the SoC detection should work automatically, but you can force that:

    Python
    # workaround for lgpio issue
    # https://github.com/gpiozero/gpiozero/issues/1106
    os.environ['LG_WD'] = '/tmp'
    from gpiozero.pins.lgpio import LGPIOFactory
    from gpiozero import Device, LED
    Device.pin_factory = LGPIOFactory(chip=4)

    Alternatively, this should do the same, like your python script.

    Bash
    #!/bin/bash
    /usr/bin/pinctrl -p GPIO17 op dh pn