RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Power switch without powerblock?

    Scheduled Pinned Locked Moved Projects and Themes
    power buttonpower offpower helppower switch
    12 Posts 5 Posters 2.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mituM
      mitu Global Moderator @ayekaye
      last edited by

      @ayekaye Sure, you can do it yourself by connecting the button to 2 GPIO pins, there are plenty of resources for how to do it - for instance https://gilyes.com/pi-shutdown-button/ on how to use 1 button for shutdown/start using a simple script and wiring the button to the 5 and 6 pins.

      ayekayeA 1 Reply Last reply Reply Quote 0
      • DougAD
        DougA
        last edited by

        Your power button LED is designed for 12V, so just wiring it straight to the GPIO pins, and using the 5V pins to power the LED may not give you enough voltage to illuminate it. I certainly agree with you about trying to avoid $27 for a power switch on a $35 computer though.

        1 Reply Last reply Reply Quote 0
        • ayekayeA
          ayekaye @mitu
          last edited by

          @mitu Looks like this is for a momentary button and not a latching button?

          -AK

          mituM 1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @ayekaye
            last edited by

            @ayekaye Yes, but I think the script can be adapted so it reads when the button is pressed/depressed. In your case, press=on, depressed=off (initiate shutdown).

            cyperghostC 1 Reply Last reply Reply Quote 1
            • cyperghostC
              cyperghost @mitu
              last edited by cyperghost

              @mitu @ayekaye
              I will include this solution also in the multi switch script here.. Then I will add option to use momentary and/or latching button. That's no problem! It will be written in bash and we will need just raspi-gpio installed via sudo apt install raspi-gpio

              Then I think the script can be pushed to version 1.0, as three or five people tested and it works as it should.

              Save shutdown with all metadata saved ;)

              And yes you are right @mitu... Take a look at line 260 here - I once used this for handling these two types of buttons.

              ayekayeA 1 Reply Last reply Reply Quote 1
              • ayekayeA
                ayekaye @cyperghost
                last edited by

                @cyperghost said in Power switch without powerblock?:

                @mitu @ayekaye
                I will include this solution also in the multi switch script here.. Then I will add option to use momentary and/or latching button. That's no problem! It will be written in bash and we will need just raspi-gpio installed via sudo apt install raspi-gpio

                Then I think the script can be pushed to version 1.0, as three or five people tested and it works as it should.

                Save shutdown with all metadata saved ;)

                And yes you are right @mitu... Take a look at line 260 here - I once used this for handling these two types of buttons.

                Is there a step-by-step guide on how I could accomplish adding a latching switch to the pi with programming needed? I apologize I am not technical enough for that thread I do not think.

                -AK

                1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost
                  last edited by

                  @ayekaye No there is a step by step guide and there will no programming skills needed as the script automatically detects the right button. You need just a SSH connection or a keyboard conntected to the Pie (prefer SSH because you'll copy and paste some lines of code). So don't be hostile to technics ;)

                  cyperghostC 1 Reply Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @cyperghost
                    last edited by cyperghost

                    @mitu @ayekaye
                    Okay done ... Multi Switch Shutdown Script v 0.50 released
                    I introduced --generic command. You can use latching and momentary switch with this script both work fine. I used GPIO3 as default button. All you need it to connect switch to GPIO3 and common ground (Physical Pin 5 and 6). Connection shema can be taken from here....

                    How to install

                    1. Login with SSH
                    2. Install raspi-gpio with sudo apt install raspi-gpio
                    3. Type in command mkdir /home/pi/RetroPie/scripts && cd /home/pi/RetroPie/scripts
                    4. DL: wget https://raw.githubusercontent.com/crcerror/ES-generic-shutdown/master/multi_switch.sh && chmod +x multi_switch.sh
                    5. Now edit ES autostart with nano /opt/retropie/configs/all/autostart.sh and add script to like ....
                    6. /home/pi/RetroPie/scripts/multi_switch.sh --generic & but BEFORE the last line emulationstatio #auto
                    7. Give me some feedback ;)

                    Please remove/disable other shutdown scripts before installing this!

                    mituM 1 Reply Last reply Reply Quote 2
                    • mituM
                      mitu Global Moderator @cyperghost
                      last edited by

                      @cyperghost Nice work ! Now all you need is a proper service (systemd) to get rid of this hacks with the autostart file. Bonus: it will run as root directly so no more sudo this & that.

                      cyperghostC 1 Reply Last reply Reply Quote 1
                      • cyperghostC
                        cyperghost @mitu
                        last edited by cyperghost

                        @mitu Hehe ;) Well I don't like services ... therefore I exposed OnOff SHIM
                        No, really this tool is intended to work from command line with it's --es-pid --closeemu commands so it's just a script that might get into autostart somehow.....
                        Besides: You can use parameters --es-pid and --rc-pid to detect if ES is running or if runcommand (= emulator) is running. Then you can use python for further handling.

                        EDIT:
                        I like the autostart that ES provides! It's a good entrypoint for adding some scripts easily. So why not make use of them? I wasn't aware that the raspi-gpio tool does not need sudo right so out 3 of the 5 devices do not need root rights ;)

                        Keltron3030K 1 Reply Last reply Reply Quote 0
                        • Keltron3030K
                          Keltron3030 @cyperghost
                          last edited by

                          @cyperghost

                          Just made use of your mult_switch.sh script.

                          I'm using it for a momentary switch on a 3B running retropie 4.4.1

                          Worked great thanks.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.