The NEW Build Your Own Arcade Controls

Main => Raspberry Pi & Dev Board => Topic started by: GrizzlyThunder on May 01, 2017, 08:24:02 am

Title: Power button for retropie
Post by: GrizzlyThunder on May 01, 2017, 08:24:02 am
Hey all,

Is there a script for the retropie to hook up an arcade button to the gpio for the power function. My cocktail cabinet currently is out of range of the wireless router therefore I believe I would need to directly write to the pie.
Title: Re: Power button for retropie
Post by: Titchgamer on May 01, 2017, 08:30:51 am
There are scripts out there that will turn the pi off.

I use a mausberry circuits power switch to turn my pi on and off though.
Title: Re: Power button for retropie
Post by: 1500points on May 01, 2017, 09:17:23 am
ETA Prime on YT shares a python script that works great for powering off the pi with a momentary push button.


The scripts here work equally well and give you a few more options, like an LED light and a game reset button, too.
http://www.westaby.net/nespi/assembly2.html (http://www.westaby.net/nespi/assembly2.html)
doesn't require the pcbs you see in the pic, just-->
put a latching switch across gpio pin 5 to gnd.
put a momentary switch across gpio pin 7 to gnd.
put an LED+resistory across gpio pin 8 to gnd.
gpio pinout- http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg (http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg)

when i was first getting started with this stuff i bought an expensive powerblock. never could get it to install properly, so tossed it in a box.
Title: Re: Power button for retropie
Post by: chito on May 11, 2017, 12:03:08 am
Posts like these that contain stuff that everyone has issues with should be a sticky! awesome find. I knew about ETA primes solution and even Daft Mikes.. but this other guy Westaby seems very easy to follow and has made improvements. awesome!
Title: Re: Power button for retropie
Post by: GrizzlyThunder on May 12, 2017, 05:29:45 pm
ETA Prime on YT shares a python script that works great for powering off the pi with a momentary push button.


The scripts here work equally well and give you a few more options, like an LED light and a game reset button, too.
http://www.westaby.net/nespi/assembly2.html (http://www.westaby.net/nespi/assembly2.html)
doesn't require the pcbs you see in the pic, just-->
put a latching switch across gpio pin 5 to gnd.
put a momentary switch across gpio pin 7 to gnd.
put an LED+resistory across gpio pin 8 to gnd.
gpio pinout- http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg (http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg)

when i was first getting started with this stuff i bought an expensive powerblock. never could get it to install properly, so tossed it in a box.

I tried following those guides but the problem I'm having is that my workshop is out in BFE and there's no internet out there. Therefore I have to connect with Ethernet, which I cannot successfully connect. I found a few scripts that I can manually enter but the pi is not recognizing the language change and won't run it.

I figured this part of the project would be difficult, but even the dang language is hassling me.


Sent from my iPhone using Tapatalk
Title: Re: Power button for retropie
Post by: 1500points on May 12, 2017, 08:59:20 pm
ETA Prime on YT shares a python script that works great for powering off the pi with a momentary push button.


The scripts here work equally well and give you a few more options, like an LED light and a game reset button, too.
http://www.westaby.net/nespi/assembly2.html (http://www.westaby.net/nespi/assembly2.html)
doesn't require the pcbs you see in the pic, just-->
put a latching switch across gpio pin 5 to gnd.
put a momentary switch across gpio pin 7 to gnd.
put an LED+resistory across gpio pin 8 to gnd.
gpio pinout- http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg (http://www.westaby.net/nespi/images/electronics/RP2_Pinout.jpg)

when i was first getting started with this stuff i bought an expensive powerblock. never could get it to install properly, so tossed it in a box.

I tried following those guides but the problem I'm having is that my workshop is out in BFE and there's no internet out there. Therefore I have to connect with Ethernet, which I cannot successfully connect. I found a few scripts that I can manually enter but the pi is not recognizing the language change and won't run it.

I figured this part of the project would be difficult, but even the dang language is hassling me.


Sent from my iPhone using Tapatalk

I suppose you could type everything from the prompt but putty sure is good with the ability to right click and paste the entries.

Can you hotspot your phone then wifi?   Bfe..and we all know where that is.  He he, i haven't heard that in ages.


Sent from my iPhone using Tapatalk
Title: Re: Power button for retropie
Post by: GrizzlyThunder on May 12, 2017, 09:28:39 pm
Quote

I suppose you could type everything from the prompt but putty sure is good with the ability to right click and paste the entries.

Can you hotspot your phone then wifi?   Bfe..and we all know where that is.  He he, i haven't heard that in ages.


When I typed everything from the prompt the dang thing still used the British pound sign even though it's been changed to English. That shouldn't be a problem and I wrote it word for word but it still gets an error.

I will have to use my hotspot on my phone.. if I get signal lol.

I'm moving to the big city in July and will be moving the cabinet as well. Fingers crossed something will work then.
Title: Re: Power button for retropie
Post by: chito on May 12, 2017, 10:15:24 pm
... the dang thing still used the British pound sign even though it's been changed to English...

British pound is English... Americans just don't use it often
Title: Re: Power button for retropie
Post by: mahuti on May 13, 2017, 09:58:35 am
I think he meant he attempted to change his keyboard to US English from UK english. That threw  me at first too... the keyboard assignment being set just slightly different out of the box.
Title: Re: Power button for retropie
Post by: mahuti on June 13, 2017, 01:36:23 am
For future reference, this is how i do it on my Pi3

I use a momentary with the input wire on 21 (the last one next to the usb ports, closes to the edge) and the ground on it's mate (next to usb ports, closer to one of the processors, just next to 21) . In my retropie autostart.sh script I call a script (/home/pi/.off-button.py).

Autostart:
/opt/retropie/configs/all/autostart.sh

Code: [Select]
python /home/pi/.off-button.py &
emulationstation


.off-button.py script:
 
Code: [Select]
#!/bin/python

import RPi.GPIO as GPIO
import os

gpio_pin_number=21
# number may be different in other Pi versions. This is for Pi3
# pin must be an input so as to not short the Pi

GPIO.setmode(GPIO.BCM)

GPIO.setup(gpio_pin_number, GPIO.IN, pull_up_down=GPIO.PUD_UP)

try:
    GPIO.wait_for_edge(gpio_pin_number, GPIO.FALLING)
    #Use falling edge detection to see if pin is pulled low to avoid repeated polling
    os.system("sudo shutdown -h now")
except:
    pass

GPIO.cleanup()

That's the cleanest way I've figured out to setup a power switch. You can do something similar for resets. I don't have a reset button though, so it's not in the script. If anyone needs reference on that I can look it up. I think there are some dedicated pins for power and reset without programming these days, but It's just not what I  have set up at the moment  :)  There have been a few times where I wanted to disable the power button (kids)... this way lets me do it from a script instead of disabling hardware.
Title: Re: Power button for retropie
Post by: GrizzlyThunder on June 13, 2017, 08:39:38 am
This is great! Thank you.


WeChat: GrizzlyThunder
Title: Re: Power button for retropie
Post by: DaOld Man on June 18, 2017, 09:32:59 am
I have used the mausberry switch circuit on all my builds so far. It has connections for power and reset buttons, and powers down the RPi after shutdown.
Though it's not real expensive (around 17 US bucks), I would still like to "build my own" shutdown circuit. Im thinking a relay that is held on by a GPIO output until shutdown, then relay turns off power to the RPi, but after all is said and done, the mausberry switch is a lot simpler and easier.
Title: Re: Power button for retropie
Post by: chito on June 18, 2017, 10:20:55 am
simpler than 1 switch and 1 script?
have you looked at the Solution presented by ETA prime? doesn't need a circuit board... just 1 gpio
Title: Re: Power button for retropie
Post by: DaOld Man on June 18, 2017, 05:49:39 pm
Yes that does look promising, but does it kill power to the pi after shutdown?
Title: Re: Power button for retropie
Post by: Sparkoids on June 26, 2017, 05:32:20 pm
We have a new product for the Raspberry Pi called the Pi-Safe. What it does is provide power for long enough to allow the Pi to shutdown on power off.

Basically you just switch the arcade machine using a Pi off as normal and it uses a rechargeable battery to keep the power on whilst running a script to shut the Pi down. The user doesn't know that is happening they just use an arcade machine with a Pi as if it's a Jamma board.

There is a script for shutdown that anyone is welcome to use. The links to the script and the info are here: http://www.ekey-solutions.com/page-5/index.html (http://www.ekey-solutions.com/page-5/index.html)
Title: Re: Power button for retropie
Post by: DeLuSioNal29 on July 03, 2017, 10:40:50 am
So I've finally jumped in head first to the Raspberry Pi3 scene.  I've done some research and figured I'd post the power button stuff here.

I stumbled across this great video on Youtube with a script (I've pasted the txt file below with the instructions and script).
! No longer available (http://www.youtube.com/watch?v=4nTuzIY0i3k#)

DeL
Title: Re: Power button for retropie
Post by: chito on July 03, 2017, 06:53:53 pm
I stumbled across this great video on Youtube with a script (I've pasted the txt file below with the instructions and script).
youtube (http://www.youtube.com/watch?v=4nTuzIY0i3k#)

ETA prime's video are already mention above. he also has a few power videos for the Pi all essentially work the same way

so i have a few mausberry circuits and was going to use 1 for another build. I started a thread about the power issue amd someone pointed out that the Pi doesnt need to be powered off, in fact it functions better left on. it draws such little power (turn other hardware off but). i looked into it an totally agree. so ive adjusted my plans to work this way
Title: Re: Power button for retropie
Post by: DeLuSioNal29 on July 03, 2017, 08:42:45 pm
I need to shut mine off. It's a portable bartop. :-)
Title: Re: Power button for retropie
Post by: stigzler on August 01, 2017, 06:39:49 pm
I'm new to Pis and recently came across this scenario. I wanted a way to:

- Turn Pi on and off with momentary switch
- Have a 'Pi On' light
- Control a small 5V fan for CPU cooling - on/off via gpio and software to regulate to cpu temp
- Have an additional pad for the 5V supply - essentially meaning could run an LED to it if I wanted to show power being supplied to the Pi.

Dead simple with 2 resistors and one transistor. You can know one together quite easy. Schematic:

(http://www.niftymonkey.uk/HPServerPublic/Forums/BYOAC/Piminator.png)

Knocking together some boards to:

(http://www.niftymonkey.uk/HPServerPublic/Forums/BYOAC/board.png)

Can give pin outs if anyone needs them.
Title: Re: Power button for retropie
Post by: petrockblog on November 01, 2017, 06:55:48 am
Since many RetroPie users asked us in the forums, we designed the PowerBlock (https://blog.petrockblock.com/powerblock/ (https://blog.petrockblock.com/powerblock/)) exactly for that use case. In the meantime, the installation of the driver has become a one-line command.

@1500points: If you ran into any problems, I would be happy to support you with troubleshooting!