Giter Site home page Giter Site logo

pi-supply-switch's Introduction

pisupply-switch-banner

Pi-Supply-Switch

Pi Supply Switch On/Off Switch for Raspberry Pi

Remember to install the code before connecting the switch to the Pi.

Installation

  1. Login via SSH or via the console.
  2. Run the following command and Pi Switch will be setup and installed:
curl -sSL https://pisupp.ly/piswitchcode | sudo bash

For OctoPrint run the following:

curl -sSL https://pisupp.ly/piswitchoctoprint | bash

With this new script any standard pin can be chosen to provide the function previously covered by pins 7 and 8. Within softshut.py you can change the assignment which by default is

PinSeven = 7
PinEight = 11

This means that pin 7 coming from the Pi Switch goes to pin 7 on the Raspberry Pi and that pin 8 from the Pi Switch goes to pin 11 on the Raspberry Pi.

PiSwitch 7 <---> RPi 7
PiSwitch 8 <---> RPi 11

Remember that the notation used is the physical notation only.

Note that the file to be changed once the installation has been carried out is located under /opt/piswitch/softshut.py and will need to be edited as root

sudo nano /opt/piswitch/softshut.py

Usage

  • Press the On button to power on the Raspberry Pi.
  • Press the Off button to remove power to the Raspberry Pi. This is not a graceful shutdown!
  • Press briefly the Soft button to gracefully shutdown the operating system. After 2 minutes the power is also cut off.
  • Press the Soft button and keep pressed for a reboot.

FAQ

My Pi switches off before fully booting

To avoid this condition always use the Pi Switch in conjunction with the script above. Neither the switch nor the script will work on their own and will result in the powering off of the Raspberry Pi shortly after booting. As previously pointed out you need to install the code before connecting the switch. To remove the switch run the uninstall.sh script before returning to powering the Raspberry Pi only with a traditional PSU. Should you not have been able to run the uninstall.sh in order to be able to access your OS without it prematurely powering off you can use the following workaround. Use the jumper cable provided with the switch and connect pin 7 on the Raspberry Pi to pin 9 (GND) and boot normally. This will trick the script into behaving as if the Pi Switch was connected. At this point you can run the uninstall.sh, power off the system and unplug the jumper cable.

Where can I find an assembly guide?

A text guide can be found on our website alternative you can also find a steb by step video.

I am still running Wheezy where can I find compatible code?

The original code for the Pi Switch can be found on our website.

Raspbian shows under-voltage warnings

The problem can be solved by using shorter, thicker USB cables. With Pi Switch we are now shipping 30cm 22AWG USB cables which solve the problem entirely.

How do I know if the service is running properly?

Run the following command

systemctl status piswitch.service

which should return something like

● piswitch.service - Starts softshut for Pi Switch
   Loaded: loaded (/etc/systemd/system/piswitch.service; enabled)
   Active: active (running) since Thu 2017-06-29 09:56:13 UTC; 6min ago
 Main PID: 427 (python)
   CGroup: /system.slice/piswitch.service
           └─427 python /opt/piswitch/softshut.py

Open Source Hardware

We are proud to say that the Pi Supply Switch is certified by the Open Source Hardware Association with UID number UK000019. Our certification mark is below:

OSHW_mark_UK000019

pi-supply-switch's People

Contributors

christopherrush avatar coconut147 avatar francesco-vannini avatar shawaj avatar tvoverbeek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-supply-switch's Issues

Use GPIO14 instead?

I found this comment on another forum about GPIO.

"The one exception might be your pin 15, which looks like it must be GPIO14. However, this pin isn't a GPIO at startup - it's TxD, the serial transmit line - which may well be pulled high for normal TX operation. The TxD line won't become GPIO14 (and therefore go low) until you run your script that enables all 17 lines as GPIOs."

"As I learned from the forums, I use an LED hooked up to GPIO14 and mounted on my chassis to notify me when the pi has completely shut down (The LED is lit at boot and is turned off at shutdown after the files systems have been unmounted."

That being the case wouldn't it be better to use the GPIO14 (TxD) pin which appears to remain high during boot, then initialize it in the script as a GPIO line and immediately pull it high in the script?

That way if the user is NOT running the script but has connected the board to GPIO14, they will not experience shutdowns during or after the boot sequence...

Would that work?

Thanks.

Shutdown after a few minutes

Hi there,

I have some problem with my Py-Supply On/Off Switch. On and Off work perfectly fine but the soft shutdown does not. That's not much of a problem since my main goal is to cut the power off.

Secondly, the Pi shuts down after a few minutes when used with the Pi-Supply. It's a hard shutdown. I installed the scripts from Github so I think the problem is with the hardware. Have you ever heard of the board acting like that?
Thank you in advance, best
Martin

Pi Supply Runeaudio

Not sure if this is the right place for this but I cannot get this to install in Runeaudio.
on inputting curl -sSL https://pisupp.ly/piswitchcode | sudo bash
I get
bash: line 12: apt-get: command not found
bash: line 16: whiptail: command not found

Start up using pins ( from another pi)

I understand that this can be used to cut the power off but is there a way to start up pi using Pins and not a button? My intention is to use another pay to control "main" pi both cutting power and starting it up (cold reset).

Script not working on Jessie

The softshut.py script is not working in Jessie. I and Russel Davis come up with a new version that so far seemed to have worked. I have created a pull request.

Softshut reboots after a while

I have a raspberry pi 3B+, it was running ok both ON and OFF buttons were working perfect. A couple of weeks ago the OFF button started to reboot itself after approximately 3 min., it does a soft shutdown and after 3 min. reboot the PI, when pressed as second time is does a soft shutdown and stays shutdown, could it be a corrupt file? , I’m running Octopi.

Start and Stop work. Shutdown does not

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

power off after two minutes

Hello!

I have an issue where the Pi (Arm 6 Model A rev2) using Dietpi 8.02 OS which I understand is based on Bullseye Debian.

Switch LED doesn't light up when Pi fully booted, then powers off after about 2 minutes (sudden off no gentle shutdown - so risk of card corruption).

I installed the code and switch as per instructions and it has worked fine previously on raspberry OS lite (headless)

Keen to use DietPi however, and like its functionality.

I used the default pins 7 and 11, and tried again changing to pins 11,15 (editing the script) same result. Also tried changing the power lead and have a good 2A supply which is ample for model A.

Ran the service status diagnostic (with switch attached) :-

● piswitch.service - Starts softshut for Pi Switch
Loaded: loaded (/etc/systemd/system/piswitch.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-01-23 09:32:20 GMT; 3min 34s ago
Process: 182 ExecStart=/opt/piswitch/softshut.py (code=exited, status=127)
Main PID: 182 (code=exited, status=127)
CPU: 33ms

Jan 23 09:32:19 RPi1PV systemd[1]: Started Starts softshut for Pi Switch.
Jan 23 09:32:20 RPi1PV softshut.py[182]: /usr/bin/env: ‘python’: No such file or directory
Jan 23 09:32:20 RPi1PV systemd[1]: piswitch.service: Main process exited, code=exited, status=127/n/a
Jan 23 09:32:20 RPi1PV systemd[1]: piswitch.service: Failed with result 'exit-code'.

Then I tested it without the switch and the OS remains stable and on for a long time.

Looking at above - perhaps python hasn't been installed correctly by default in Dietpi? Any ideas? Thanks!

Link for the text-guide not working

Hello,

Is it possible to get all the related files, guides and programs in this repository? It would be more handy and links seems to disappear over time.

Hendrie

Softshut Not working

Hi I followed all of the instructions step-by-step. I am using a raspberry pi 3B+ running raspbian stretch. The ON and Off buttons work, but not the Softshut Off button. Shown 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)

This is what my softshut.py file looks like.

#!/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

Thanks!

Unexpected shutdown without pressing the button

I recognized some unexpected shutdowns with my PiSupply Board.

First I thought it is an hardware issue and started to measure with an oscilloscope but everything looked fine.
I recognized that touching mass the raspberry can invoke the shutdown.

It seems that spikes will produce rising edges on the GPIO.

I already created a proof of concept on my fork at the branch "coconut147_RetroPi"

https://github.com/coconut147/Pi-Supply-Switch/tree/coconut147_RetroPi

If you have a look at commit
coconut147@e24678b

you'll find my approach I'm testing right now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.