[RPi] Reboot with GPIO 3 pins

  • Hello!


    First of all, my goal is to make a button connected to GPIO 3 reboot the system.


    To give you the overall picture, I have about 4 Pi2s in a network rack running libreelec 11.0.6 that plays my entire video library constantly. Randomly it will stop playing or get hung up at a black screen. I wanted to add a button to the panel for each pi so that it will just reboot the system instead of needing to get inside the rack to power them off and back on.


    I've followed a few random threads I've found here about adding dtoverlay=gpio-shutdown or dtoverlay=gpio-reboot with and without gpio_pin=3 to the config.txt but, that still only powers it down.


    I've tried adding a keyboard.xml and gen.xml to /storage/.kodi/userdata/keymaps, replacing shutdown with reboot and still getting a shutdown no matter what, and sometimes not even that.


    keyboard.xml

    Code
    <keymap>
       <global>
           <keyboard>
               <power>reboot</power>
           </keyboard>
       </global>
    </keymap>

    gen.xml

    Code
    <keymap>
    <global>
    <keyboard>
    <key id="61662">Shutdown</key>
    </keyboard>
    </global>
    </keymap>

    I've double checked the physical layer too. Multiple different buttons, wires, ect. No luck.

    Its weird because one out of the 4 pi's it works, and the only difference that I can see is just that I haven't updated it to 11.0.6, its currently on 11.0.3.

    The holy grail would be something where a press would reboot, a hold would shut it down. I've seen threads with scripts and whatnot in them but they were always along with some LED indicator which I don't need.

    I am a novice when it comes to all of this stuff, and by pure luck I've managed to get this far into creating essentially my own TV station. I don't know any code so please be easy on me if I ask any dumb questions.

    Any ideas?

  • Randomly it will stop playing or get hung up at a black screen.

    That means probably the system is frozen, so a software reboot solution, like reading a GPIO (button) status or SSH command, probably can't be used. As the RPi doesn't have hardware reset button option, remains only the "power them off and back on" as a solution. If you want to use a button, could try a button with "normally closed" contact to interrupt the power of the non working RPi when is pressed...

  • Or just use SSH and tell it to reboot.

    Girlfriend doesn't know how to SSH. Simple option is to just have a button.

    That means probably the system is frozen, so a software reboot solution, like reading a GPIO (button) status or SSH command, probably can't be used. As the RPi doesn't have hardware reset button option, remains only the "power them off and back on" as a solution. If you want to use a button, could try a button with "normally closed" contact to interrupt the power of the non working RPi when is pressed...

    Either way, I'd still like this feature even if it doesn't work when it black screens.

  • Girlfriend doesn't know how to SSH. Simple option is to just have a button.

    Either way, I'd still like this feature even if it doesn't work when it black screens.

    Don't forget, the RPi isn't a PC. Doesn't have the same (hardware) reset button. So in the case of the RPi, some kind of the software should "process" the signal from a GPIO in. I didn't know how is your RPi, when you want to reboot it, only the Kodi or the media player is frozen or the entire system... But if the whole system halted, isn't able to process any commands (including the one from GPIO3).

    If don't want to use SSH, you should try a Kodi remote app like the "Kore" to check if the RPi can to reboot yourself. If isn't working, no other way, you need to use a button to interrupt the power...

    Just got a random black screen, button worked to power it down, but still no reboot.

    Did you tried to press again the button after shut down? The original purpose should be to shut down and power up too.

  • Don't forget, the RPi isn't a PC. Doesn't have the same (hardware) reset button. So in the case of the RPi, some kind of the software should "process" the signal from a GPIO in. I didn't know how is your RPi, when you want to reboot it, only the Kodi or the media player is frozen or the entire system... But if the whole system halted, isn't able to process any commands (including the one from GPIO3).

    If don't want to use SSH, you should try a Kodi remote app like the "Kore" to check if the RPi can to reboot yourself. If isn't working, no other way, you need to use a button to interrupt the power...

    Did you tried to press again the button after shut down? The original purpose should be to shut down and power up too.

    Yeah, after the first button press, it shut down. Then I had to press it again and it powered back up.

    I don't want any other apps or anything like that. I want it to be physical. I know its possible but I don't know why one will work and the others don't.

    Here are the other threads I got most of my information from.

    2469
    December 23, 2021 at 3:14 PM
    Foxbiker
    August 16, 2019 at 10:23 PM

  • Run this Python script from autostart.sh:

  • Run this Python script from autostart.sh:

    How would I do that? I'm assuming i need to create an add-on that runs this?

  • Nah. You only need the RPi Tools add-on, because it contains the Python GPIO library.

    1. Create the Python script inside of your /storage folder (e.g. /storage/scripts/gpio-reboot.py).
    2. Make it executable: chmod +x /storage/scripts/gpio-reboot.py
    3. Create /storage/.config/autostart.sh.
    4. Write the Python call into autostart.sh.: python /storage/scripts/gpio-reboot.py &

    Then the script will run on every boot sequence.