Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start and Stop work. Shutdown does not #14

Open
matt-benett opened this issue Jan 18, 2019 · 10 comments
Open

Start and Stop work. Shutdown does not #14

matt-benett opened this issue Jan 18, 2019 · 10 comments

Comments

@matt-benett
Copy link

Hello, I have 1.1 on a RPi 3 B+. Latest version of Retropi. All updated.

Start works - when on Pi Supply LED is on.
Hard Stop works - when off Pi Supply LED is off.

My issues is:
Soft shutdown does nothing on the Pi or the screen output. The Pi Supply it turns the LED off/on when I press it. It does not even kill power after 2 minutes.

piswitch service is running.

I am plugged into Pin 7 and 11.

Any ideas please?
thanks

@tvoverbeek
Copy link
Contributor

@matt-benett Are you using any GPIO based controllers with Retropie?
Looking at https://github.com/RetroPie/RetroPie-Setup/wiki/GPIO-Modules
It seems some of those modules use pins 7 and 11 which will interfere with the piswitch service.

@matt-benett
Copy link
Author

@matt-benett Are you using any GPIO based controllers with Retropie?
Looking at https://github.com/RetroPie/RetroPie-Setup/wiki/GPIO-Modules
It seems some of those modules use pins 7 and 11 which will interfere with the piswitch service.

no, using USB controller

@tvoverbeek
Copy link
Contributor

@matt-benett Do you have wiringpi installed?
If not install it with sudo apt-get install wiringpi.
Then please provide the output of gpio readall
The interesting items are the ones for physical pins 7 and 11

@matt-benett
Copy link
Author

Output

image

Image to preserve formatting

@tvoverbeek
Copy link
Contributor

RPi GPIO pins 7 (BCM 4) and 11 (BCM17) have the correct state and level.
you wrote earlier the piswitch service is running.
What is the output from systemctl status piswitch.service?
Double check the connections from Pi-Switch pins 7 and 8 to RPI GPIO pins 7 and 11 respectively.
See the assembly guide (I guess you did this already).
To get a soft shutdown the press the soft button less than 2 seconds (again, I guess you know this).
Note the warning in the assembly guide about Pi3B and 3B+.

@matt-benett
Copy link
Author

ta.

I am looking at the new and old pin images, and they look the same to me. Am I missing something?

https://i0.wp.com/learn.pi-supply.com/wp-content/uploads/2013/06/Pins-New-Soft.jpg?w=1000&ssl=1

https://i2.wp.com/learn.pi-supply.com/wp-content/uploads/2018/12/20181218_164817.jpg?w=1000&ssl=1

I will check output of systemctl status piswitch.service tonight, but I recall it looking all ok.

@shawaj
Copy link
Member

shawaj commented Jan 22, 2019

The options as shown in the two pictures here are pins 2 and 6 or pins 7 and 11 - https://learn.pi-supply.com/pi-supply-switch-v1-1-assembly-instructions/

But with the Pin 7 / 11 you need the software running on the pi for it to work correctly

@LDDill
Copy link

LDDill commented Jan 31, 2020

Hi @tvoverbeek @shawaj I am having the same issue as @matt-benett. The ON and Off buttons work but not the Soft Off button. Show below is what I get when I run "systemctl status piswitch.service". Any suggestions?

pi@raspberrypi:~ $ systemctl status piswitch.service
● piswitch.service - Starts softshut for Pi Switch
Loaded: loaded (/etc/systemd/system/piswitch.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Fri 2020-01-31 16:57:53 CST; 13min a
Process: 348 ExecStart=/opt/piswitch/softshut.py (code=exited, status=1/FAILUR
Main PID: 348 (code=exited, status=1/FAILURE)

Jan 31 16:57:52 raspberrypi systemd[1]: Started Starts softshut for Pi Switch.
Jan 31 16:57:53 raspberrypi softshut.py[348]: Traceback (most recent call last):
Jan 31 16:57:53 raspberrypi softshut.py[348]: File "/opt/piswitch/softshut.py"
Jan 31 16:57:53 raspberrypi softshut.py[348]: GPIO.wait_for_edge(PinSeven, G
Jan 31 16:57:53 raspberrypi softshut.py[348]: RuntimeError: Error waiting for ed
Jan 31 16:57:53 raspberrypi systemd[1]: piswitch.service: Main process exited, c
Jan 31 16:57:53 raspberrypi systemd[1]: piswitch.service: Unit entered failed st
Jan 31 16:57:53 raspberrypi systemd[1]: piswitch.service: Failed with result 'ex
lines 1-14/14 (END)

Thanks

@Velocity2018
Copy link

Did you remember to edit the Python script to change the pin numbers?

@LDDill
Copy link

LDDill commented Feb 1, 2020

@Velocity2018 I opened the code to edit it, but it appeared to already be correct.

GNU nano 2.7.4 File: /opt/piswitch/softshut.py

#!/usr/bin/env python

Import the modules to send commands to the system and access GPIO pins
from subprocess import call
import RPi.GPIO as GPIO
from time import sleep

Map pin seven and eight on the Pi Switch PCB to chosen pins on the Raspberry Pi header
The PCB numbering is a legacy with the original design of the board
PinSeven = 7
PinEight = 11
GPIO.setmode(GPIO.BOARD) # Set pin numbering to board numbering
GPIO.setup(PinSeven, GPIO.IN) # Set up PinSeven as an input
GPIO.setup(PinEight, GPIO.OUT, initial=1) # Setup PinEight as output

while (GPIO.input(PinSeven) == False): # While button not pressed
GPIO.wait_for_edge(PinSeven, GPIO.RISING) # Wait for a rising edge on PinSeven
sleep(0.1); # Sleep 100ms to avoid triggering a shutdown when a spike occured

sleep(2); # Sleep 2s to distinguish a long press from a short press

if (GPIO.input(PinSeven) == False):
GPIO.output(PinEight,0) # Bring down PinEight so that the capacitor can discharge and remove power to the Pi
call('poweroff', shell=False) # Initiate OS Poweroff
else:
call('reboot', shell=False) # Initiate OS Reboot

Is there something I need to edit in this file?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants