RPi4 GPIO using in LibreELEC

  • Da Flex

    Just been to the local shop to get the switch.

    So after some research managed to get it sorted..

    Led,Start,Restart and Shutdown all in one..

    short press is restart..long press is shutdown..press from off will switch on..

    Now gonna test it for a few days...happy to share script if anyone wanna test..

  • Well although power button works as intended..unfortunately it doesn't work if system is for some reason frozen..so it might still need a dirty power shutdown once in a while..

    Led On - Start - Quick Press Restart - Long Press Shutdown

    • Official Post

    Yes, a frozen system will probably stop script execution, and soft-reset will not work anymore. If you can accept the risk of a hard-reset, you can add another button for that purpose. Hard-reset pins are not part of GPIO, you have to use the P6 header instead: Click!

  • Mario77, Da Flex,


    Your explanations are very useful. I was thinking to implement such a button on my Pi4 BUT I was thinking... What if the power button is with IR for the regular TV or Bluetooth from the phone. Is this possible to be done? I think this will be just a bit better for usage


    Thanks again for your explanations!

  • Mario77, Da Flex,


    Your explanations are very useful. I was thinking to implement such a button on my Pi4 BUT I was thinking... What if the power button is with IR for the regular TV or Bluetooth from the phone. Is this possible to be done? I think this will be just a bit better for usage


    Thanks again for your explanations!

    That will be usefull just for startup if it works...basically reboot and shut down are the same as the ones you r using now from Kodi power menu..so you can set the remote buttons even without switch..

    Just a quick idea is a transistor between pin 5 and 6 and an ir receiver connected to it...basically if you short pin 5 and 6 rpi will start.

  • That will be usefull just for startup if it works...basically reboot and shut down are the same as the ones you r using now from Kodi power menu..so you can set the remote buttons even without switch..

    Just a quick idea is a transistor between pin 5 and 6 and an ir receiver connected to it...basically if you short pin 5 and 6 rpi will start.

    True for the reboot and shutdown. In fact I am using the Kodi app on the phone as a remote control but for the activation I can not use it

    So you said just shorting pin 5 and 6 will start rpi( you mean GPIO3 and GND)??? Directly shorting them with nothing else?

  • True for the reboot and shutdown. In fact I am using the Kodi app on the phone as a remote control but for the activation I can not use it

    So you said just shorting pin 5 and 6 will start rpi( you mean GPIO3 and GND)??? Directly shorting them with nothing else?

    Yeah thats what I mean gpio3 and the gnd across it...you add dtoverlay=gpio-shutdown to config.txt..

  • Yeah thats what I mean gpio3 and the gnd across it...you add dtoverlay=gpio-shutdown to config.txt..


    If I want just to start rpi only do I need to add the dtoverlay=gpio-shutdown to config.txt. and 1 maybe stupid question - where is this config.txt file on pri4

  • If I want just to start rpi only do I need to add the dtoverlay=gpio-shutdown to config.txt. and 1 maybe stupid question - where is this config.txt file on pri4

    To power up, all that’s required is to connect physical pin 5 (BCM 3) to the ground next to it. This functionality is enabled by default.

    To shut down with the same button, just add the line dtoverlay=gpio-shutdown to /flash/config.txt

    config.txt is read only

    to edit ssh

    Code
    mount -o remount,rw /flash

    then to make it read only again

    Code
    mount -o remount,ro /flash
  • To power up, all that’s required is to connect physical pin 5 (BCM 3) to the ground next to it. This functionality is enabled by default.

    To shut down with the same button, just add the line dtoverlay=gpio-shutdown to /flash/config.txt

    config.txt is read only

    to edit ssh

    Code
    mount -o remount,rw /flash

    then to make it read only again

    Code
    mount -o remount,ro /flash

    Millions of Thanks!!!

  • Create this /storage/scripts/status_led.py :


    Thank you very much for the guide!

    I came up with a problem that after I changed the led GPIO to 4 (BCM Mode), the LED was blinking slightly when Pi shutdown. But GPIO 13 works well. I can hardly find anything about the GPIO state after Pi shutdown. Is there any way to solve it cause I want to make the wires more concentrated.

    Thank a lot!

    • Official Post

    Thank you very much for the guide!

    I came up with a problem that after I changed the led GPIO to 4 (BCM Mode), the LED was blinking slightly when Pi shutdown. But GPIO 13 works well. I can hardly find anything about the GPIO state after Pi shutdown. Is there any way to solve it cause I want to make the wires more concentrated.

    Thank a lot!

    The "Raspberry Pi Tools" GPIO library seems to be broken right now. I also have LED problems (switches off after some time while RPi is still on). I think we have to wait for an update.

  • It's strange. I am running the LE 10 Nightly (currently 20210703) on RPi 4B, using output GPIOs 4, 6 and 27 for relays and LED, also in BCM mode and did not encounter any issue so far.

    There's a difference between GPIO pins so it may play a role... For instance, GPIO 13 supports hardware PWM while GPIO 4 does not.

    GPIO - Raspberry Pi Documentation