Main > Raspberry Pi & Dev Board

Power button for retropie

<< < (2/4) > >>

1500points:

--- Quote from: GrizzlyThunder on May 12, 2017, 05:29:45 pm ---
--- Quote from: 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
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

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.

--- End quote ---

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

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


Sent from my iPhone using Tapatalk

GrizzlyThunder:

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


--- End quote ---

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.

chito:

--- Quote from: GrizzlyThunder on May 12, 2017, 09:28:39 pm ---... the dang thing still used the British pound sign even though it's been changed to English...

--- End quote ---

British pound is English... Americans just don't use it often

mahuti:
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.

mahuti:
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: ---python /home/pi/.off-button.py &
emulationstation

--- End code ---


.off-button.py script:
 
--- Code: ---#!/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()

--- End code ---

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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version