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

    Finished: Retropie case with on/off switch and power LED

    Scheduled Pinned Locked Moved General Discussion and Gaming
    caseswitchpower ledmomentaryheatsink
    24 Posts 6 Posters 6.1k 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.
    • coldnpaleC
      coldnpale
      last edited by coldnpale

      Hey guys,

      Just got the heatsink (adafruit rpi3 heatsink 15x15x15mm) I was waiting for to finish this little retropie box. I believe it looks elegant enough for a livingroom and it functions perfectly!!
      0_1516639006657_1.jpg 0_1516639012896_rsz_dsc_9210.jpg 0_1516639017870_rsz_dsc_9212.jpg

      1 Reply Last reply Reply Quote 1
      • jebbettJ
        jebbett
        last edited by jebbett

        That's pretty cool! one of the nicer Pi boxes I've seen and not too expensive either... How are you managing power on? I didn't think this was possible without a more complicated circuit, but looks like you just have a switch to the header?

        P.S. It has a bit of a HAL feel to it :)

        coldnpaleC 1 Reply Last reply Reply Quote 1
        • coldnpaleC
          coldnpale @jebbett
          last edited by coldnpale

          @jebbett Thanks for the feedback! Box costed me 10e, so i'd say it's on the cheap side.

          For the switch:
          I wired a momentary button on pins 5 and 6. With this I was able to only turn on the pi. Then I used the script from a tutorial I found on 8bitjunkie to make it also perform a safe shut down. For the shutdown it feels like you have to hold the button for about half a second, maybe a bit less. I believe it was programmed to worked like that to avoid accidental shudowns from unwanted electrical behaviour. For example, I read that some people had some sudden shutdowns when inserting a usb device, but with this script I am not experiencing any issues.

          1 Reply Last reply Reply Quote 0
          • coldnpaleC
            coldnpale
            last edited by

            And in order to keep the wiring clean and not block the airflow from the mesh alu on the sides I organised my wires like that:
            0_1516642476579_cir.jpg

            1 Reply Last reply Reply Quote 1
            • ?
              A Former User
              last edited by

              Didn't know you could use pins 5 & 6 like this.

              Could you share the script? Might order a button and try this this weekend.

              jebbettJ 1 Reply Last reply Reply Quote 0
              • jebbettJ
                jebbett @A Former User
                last edited by

                @livefastcyyoung

                I didn’t think so either, but see the link below..

                https://www.raspberrypi.org/forums/viewtopic.php?t=191145

                Everyday is a school day!

                1 Reply Last reply Reply Quote 1
                • coldnpaleC
                  coldnpale
                  last edited by coldnpale

                  8bitjunkie button script

                  Scroll down to keyboard method (uk). That's what I did.

                  Just make sure it is a momentary push button and not an on/off switch.

                  Can't imagine using a pi without a button now. I can't stand unpluging and repluging the adaptor.

                  1 Reply Last reply Reply Quote 0
                  • caver01C
                    caver01
                    last edited by caver01

                    This technique has been around for a while. It relies on the fact that a Pi can be "awakened" from deep sleep by shorting pin 5 to ground. That is what the momentary switch does.

                    Then, once booted, you have the python script loaded that basically sets up the same pin as GPIO input, sets it to HIGH and watches the pin to go low (the script sleeps and loops until it sees this happen). When this happens, it issues a safe shutdown command.

                    There are a bunch of ways to write the script. You could do it in BASH too if you wanted. The looping aspect is not the best method. With python you could just as easily setup edge detection so that it is not wasting CPU cycles looping every half second. The .5 delay is also probably why you need to hold the button for a moment. Depending on when in the sleep loop you press the button, it would take, on average, a quarter second (but as much as a half second) for the script to loop and check the status of the pin.

                    Before using a Mausberry circuit, I used this method for safe shutdown. It is definitely the easiest/cheapest way to go. However, after the shutdown, the Pi is not actually turned off. It is still consuming power which may be a problem for portables. Also, if power cycles, it will boot right up. LEDs may also still stay lit, etc. However, for the cost of a simple momentary switch, a few wires and a script, you get a power switch that works well enough for most purposes, and certainly better than pulling the micro USB every time.

                    The more complex circuits out there like the Mausberry have the added ability to monitor the Pi, and when the circuit detects a shutdown, it really cuts the power. These circuits also don't turn power back on until the user presses the button/switch (a power outage/cycle won't inadvertently turn on the Pi). This behavior is more aligned with expectations people have with modern electronics. The question is whether this final step is worth the investment for you.

                    The 8bitjunkie link above is nice because it sets up everything. If I made one improvement, however, it would be to adjust the logic in the python script in favor of GPIO edge detection to get out of the looping.

                    My 4-player cocktail style cabinet built as a custom "roadcase"

                    ? coldnpaleC 2 Replies Last reply Reply Quote 1
                    • ?
                      A Former User @caver01
                      last edited by

                      @caver01 Thanks for all of this! With all of that said, I think I'll pass on using this method. The only reason I really want to be able to shut down the Pi is because of the fan installed in the case. I don't want it running when I'm not using it. Since this method wouldn't truly cut power, that fan would continue to run.

                      Back to the drawing board for me.

                      caver01C coldnpaleC 2 Replies Last reply Reply Quote 0
                      • coldnpaleC
                        coldnpale @caver01
                        last edited by

                        @caver01
                        Thanks for the information! I believe this answers many questions!!

                        1 Reply Last reply Reply Quote 0
                        • caver01C
                          caver01 @A Former User
                          last edited by

                          @livefastcyyoung
                          You might do some tests. Depending on how you power the fan it might still work. If you are pulling power from the GPIO header, it might cut power on that while in deep sleep. I don’t recall.

                          My 4-player cocktail style cabinet built as a custom "roadcase"

                          1 Reply Last reply Reply Quote 0
                          • coldnpaleC
                            coldnpale @A Former User
                            last edited by coldnpale

                            @livefastcyyoung
                            I also have a feeling the fan will stop.
                            My LED turns off when I power the system down from the switch. I am not seeing any difference when I am performing the shutdown from emulation station or the switch. Both ways leave some small board leds on, but the power from the pins should be cut off. You could install the script and short the 2 pins with a screwdrver or a jumper to test it.

                            1 Reply Last reply Reply Quote 1
                            • caver01C
                              caver01
                              last edited by caver01

                              The nice thing is that this is such a simple way to setup a basic power switch that you can test it by just doing the software script alone, then carefully shorting pins 5 and 6 with anything conductive to test. In other words, you don’t really need to wire up a switch to do a test.

                              Actually, forget that, you just need to issue a shutdown command at the command prompt and see if your fan powers down. Simple.

                              My 4-player cocktail style cabinet built as a custom "roadcase"

                              coldnpaleC ? 2 Replies Last reply Reply Quote 2
                              • coldnpaleC
                                coldnpale @caver01
                                last edited by coldnpale

                                @caver01
                                I believe I know the answer but since you probably know better i thought i'd ask.

                                1. After performing a shutdown from switch or emulationstation, is it safe to unplug the power adaptor?

                                2. Is the shutdown enough to remove the microsd card? Or should I also unplug the adaptor before removing it?

                                Thanks again for all the information, it really is schoolday today. :)

                                jebbettJ 1 Reply Last reply Reply Quote 0
                                • jebbettJ
                                  jebbett
                                  last edited by

                                  I suspect it drops the power too, but if not you could just hook up a transistor for a few pence and connect to another gpio..

                                  Example here providing automatic fan control also :)

                                  Just google "use a transistor to control a fan on the raspberry pi", I would post a link but the forum thinks it's spam :)

                                  1 Reply Last reply Reply Quote 0
                                  • jebbettJ
                                    jebbett @coldnpale
                                    last edited by

                                    @coldnpale said in Finished: Retropie case with on/off switch and power LED:

                                    @caver01
                                    I believe I know the answer but since you probably know better i thought i'd ask.

                                    1. After performing a shutdown from switch or emulationstation, is it safe to unplug the power adaptor?

                                    2. Is the shutdown enough to remove the microsd card? Or should I also unplug the adaptor before removing it?

                                    Thanks again for all the information, it really is schoolday today. :)

                                    The answer is yes to both, removal of the SD card is fine as long as it's not writing to the card at the time, in this case it wont be running at a software level, it's basically like standby on your computer..

                                    coldnpaleC 1 Reply Last reply Reply Quote 2
                                    • coldnpaleC
                                      coldnpale @jebbett
                                      last edited by

                                      @jebbett
                                      Thanks!

                                      1 Reply Last reply Reply Quote 0
                                      • ?
                                        A Former User @caver01
                                        last edited by

                                        @caver01 said in Finished: Retropie case with on/off switch and power LED:

                                        Actually, forget that, you just need to issue a shutdown command at the command prompt and see if your fan powers down. Simple.

                                        When I run sudo shutdown now from the command prompt and my Pi still shuts down but the fan still goes.

                                        The fan runs off pins 2 & 4 if that changes the equation at all.

                                        caver01C 1 Reply Last reply Reply Quote 0
                                        • caver01C
                                          caver01 @A Former User
                                          last edited by

                                          @livefastcyyoung strange. Pins 2 and 4 are both 5v as far as I can tell. Are you sure you are not using 4 and 6 (5v and ground)? Another thought is that since you might be using 5v, you could see if the USB ports power down during a shutdown. If so, you could pull 5v from a USB port by hacking a cable and borrowing the red and black wires.

                                          My 4-player cocktail style cabinet built as a custom "roadcase"

                                          ? 1 Reply Last reply Reply Quote 1
                                          • ?
                                            A Former User @caver01
                                            last edited by A Former User

                                            @caver01 I’m sorry, it’s definitely 4 and 6.

                                            Unfortunately, I don’t have a free USB port. :(

                                            Edit: is it possible in a shutdown script, to tell the Pi to kill all power for certain pins in the GPIO?

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