• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
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 1.9k 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.
  • A
    ayekaye
    last edited by 1 May 2018, 16:40

    Raspberry Pi 3b+
    RetroPie 4.4

    Is there a good way to connect a power switch to my pi without a powerblock, Mausberry or other third party devices? I have looked high and low and there are a lot of different videos and ideas out there. What is the best/easiest solution that people have had luck with.

    I have this latching 5 prong power button and was hoping to not spend another $27 just to power the thing on/off. Looking to use a cabinet mounted button and not one that is built into the power cable

    Any help/links are appreciated.

    -AK

    M 1 Reply Last reply 1 May 2018, 17:09 Reply Quote 0
    • M
      mitu Global Moderator @ayekaye
      last edited by 1 May 2018, 17:09

      @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.

      A 1 Reply Last reply 1 May 2018, 17:16 Reply Quote 0
      • D
        DougA
        last edited by 1 May 2018, 17:16

        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
        • A
          ayekaye @mitu
          last edited by 1 May 2018, 17:16

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

          -AK

          M 1 Reply Last reply 1 May 2018, 17:53 Reply Quote 0
          • M
            mitu Global Moderator @ayekaye
            last edited by 1 May 2018, 17:53

            @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).

            C 1 Reply Last reply 1 May 2018, 17:59 Reply Quote 1
            • C
              cyperghost @mitu
              last edited by cyperghost 5 Jan 2018, 19:01 1 May 2018, 17:59

              @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.

              A 1 Reply Last reply 1 May 2018, 19:39 Reply Quote 1
              • A
                ayekaye @cyperghost
                last edited by 1 May 2018, 19:39

                @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
                • C
                  cyperghost
                  last edited by 1 May 2018, 20:38

                  @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 ;)

                  C 1 Reply Last reply 2 May 2018, 18:20 Reply Quote 0
                  • C
                    cyperghost @cyperghost
                    last edited by cyperghost 5 Feb 2018, 21:35 2 May 2018, 18:20

                    @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!

                    M 1 Reply Last reply 2 May 2018, 18:41 Reply Quote 2
                    • M
                      mitu Global Moderator @cyperghost
                      last edited by 2 May 2018, 18:41

                      @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.

                      C 1 Reply Last reply 2 May 2018, 19:03 Reply Quote 1
                      • C
                        cyperghost @mitu
                        last edited by cyperghost 5 Feb 2018, 20:08 2 May 2018, 19:03

                        @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 ;)

                        K 1 Reply Last reply 17 May 2018, 03:47 Reply Quote 0
                        • K
                          Keltron3030 @cyperghost
                          last edited by 17 May 2018, 03:47

                          @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.

                            This community forum collects and processes your personal information.
                            consent.not_received