Pi Supply Switch v1.1 Code Examples
Raspberry Pi
The code on this page has been superseded, you can find the new scripts on our GitHub repository. Use the code below only if you are using Wheezy.
Python
There are two ways to implement this in Python…with a while loop, or using interrupts. Below can be found some code examples to use the soft shutdown switch functionality using a Python script.
Before you choose either of the code methods below, you first need to open the Python IDE. Once you have this ready, you then need to type in the code from either the interrupts or while loop section below. After you have completed that you then need to move on to the section about loading a Python file during the boot up process.
Interrupts
The best way to enable the soft shutdown feature of the Pi Supply Switch in terms of efficiency of the code and load on the CPU is using an interrupt based script, rather than the following one which uses a while loop. The code for the interrupt method is posted below.
# Import the modules to send commands to the system and access GPIO pins from subprocess import call import RPi.GPIO as gpio # Define a function to keep script running def loop(): raw_input() # Define a function to run when an interrupt is called def shutdown(pin): call('halt', shell=False) gpio.setmode(gpio.BOARD) # Set pin numbering to board numbering gpio.setup(7, gpio.IN) # Set up pin 7 as an input gpio.add_event_detect(7, gpio.RISING, callback=shutdown, bouncetime=200) # Set up an interrupt to look for button presses loop() # Run the loop function to keep script running
While loop
A while loop is a basic fundemental of almost every programming language in existence, and is a very useful tool as well. The following code has the same end result as the interrupt based script above – it allows the safe shutdown of your Raspberry Pi – but it does so in a significantly more resource hungry way.
It is a more basic piece of code in terms of actually understanding the operation of the code and what is going on, but like with a lot of things this does not mean it is the best way to do it. Whilst we recommend using the interrupt based code above, we have added the while loop based code here for inclusion, as it works fine and some people might prefer to use this code (or at least have a play with it and try to get their head round how it works).
# Import the libraries to use time delays, send os commands and access GPIO pins import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BOARD) # Set pin numbering to board numbering GPIO.setup(7, GPIO.IN) # Setup pin 7 as an input while True: # Setup a while loop to wait for a button press if(GPIO.input(7)): # Setup an if loop to run a shutdown command when button press sensed os.system("sudo shutdown -h now") # Send shutdown command to os break time.sleep(1) # Allow a sleep time of 1 second to reduce CPU usage
Loading a Python file during boot process
Once you have entered either the interrupt based or while loop based code above into the Python IDE, you then need to create a folder called PiSupply in the /home/pi directory. Save the above code (whichever you choose) in the newly created folder at /home/pi/PiSupply – naming the file softshut.py or similar.
Then open an LXTerminal session, and use the Nano text editor to add some code to enable the Python script we just created to run when the Pi boots up. Type in:
sudo nano /etc/rc.local
and then add in the following code:
python /home/pi/PiSupply/softshut.py &
before the line that says:
exit 0
Press Ctrl+X to exit the Nano editor and when prompted press Y and then Enter in order to save the file you just edited.
Obviously the file name softshut.py that we used above can be whatever you want it to be, and the folder names and locations are all up to you as well…you just need to make sure that you maintain these throughout the above locations to make sure this code will function correctly on boot. In the above example we have used physical pin 7 on the GPIO header, which as you can see corresponds to the 4th pin from the right, on the top row (when looking down on the Pi from above, with the RCA video connector socket facing towards you). You can change this to use any different GPIO pin, we just chose pin 7 as it is next to physical pin 8 which is the required pin to use for the automatic power supply switching without any additional code.
It is additionally possible to add some code to the above to change to a pin other than physical pin 8 for the main automatic power off functionality…more on this soon.
That’s a nasty piece of code! I don’t understand why you would use a while loop for this, as the CPU is very underpowered. Check my script in the kickstarter comments for a Python script that uses interrupts. I with also be writing a script in C/C++ as this will give the best performance.
Not sure I agree that it is “nasty” – more basic and resource hungry for sure, but functionally it is less complex and therefore easier for beginners to understand what is actually happening in the code in my opinion. After all, a while loop is a basic functionality of Python, and learning programming on the whole.
Have the interrupts code too which will be posted, just formatting it up ready to upload to the site. Thanks for posting yours too – feel free to post a link to it here if you would like to as every bit of code available to people can only help.
Have some Bash code to test and working on C/C++ also…if you get there first I would again be delighted if you posted it here.
As always – thanks for your helpful support!
Its ok and it works.
I am using a very similar piece of code to what InveSandwich wrote.
Nice, simple, does the job well and pretty failsafe.
Its all about personal preference I think,
I wrote my little script quickly using the guts from another script I had running on one of my other pi’s that is connected to a mini receipt printer, it was set up so a quick button push printed time/date hold for 2 secs for weather report 4 secs for last 3 twitter posts matching my search critera for the twitter API (currently fixing to make it work with twitter API v2.0 then held for 8 secs would run “sudo shutdown -h now”. It is hooked up to one of these funky (but expensive) 2 leg RGB led with an auto sequence that starts on button press and stops when released, it changes and mixes colours every 2 secs so really handy for timing holds.
I just butchered it out and have it set so a single button tap shuts down the pi.
Am going to edit the Pi Supply script to add a reboot option – press for reboot and hold for 2secs for shutdown,
ANYWAY, main thing is that it is working and the system works well, its a simple but really usefull little power controller. I have my beta model up and running again now too (with a less powerfull 5v 1.5A PSU) running on a Pi that is just a data logging device.
I want to get another v1.1 so I can have it running on my BeagleBone Black
Great job getting this posted, it will help those who havent gone down the coding path yet!
Cheers for the update Nial – it is useful both for me and for others to hear of different implementations of the code. Each person will have their own personal preference – and I guess that is the whole idea of the Raspberry Pi really – to tailor it EXACTLY to your specification with cool bits of hardware and software.
So my thought was to post some basic scripts in various languages here, with the hope that a large number of people will take those, read up about what they are actually doing and then use them to make even cooler scripts…and then post them right back here for everyone to see. The more minds the better! Obviously this kind of stuff is a lot more useful for beginners exploring things for the first time and learning, but funnily enough I find myself on a regular basis thinking “why didn’t I think of that” so it is a useful source of inspiration for intermediates and seasoned pros as well.
Can I just suggest a slight modification to the simple script above for a slight improvement in performance.
When you call;
import time
import os
you are loading every function of os and time into the RAM, when we only use one function from each. A better, more efficient way to do this would be;
from time import sleep
from os import system
Then further down the script replace;
os.system(“sudo shutdown -h now”)
time.sleep(1)
with;
system(“sudo shutdown -h now”)
sleep(1)
Thanks for that – that never crossed my mind actually, will add that above if you don’t mind?
Actually you aren’t. If you were doing this instead:
from time import *
from os import *
then you would be importing all the _definitions_ into your current namespace (messy); but by doing:
import time
import os
you create only two definitions (“time” and “os”) in your namespace, and you access any time or os definitions through those two names.
Just nitpicking, I know.
Hi folks,
i dont think about deep or long … but what about DBus?
With http://sourceforge.net/projects/raspdbusgpiopy/ there is a pice of software that connects the GPIOs with DBus … now i can listen on the message handler to shutdown … or do whatever i want …
But -as i said previously – i had not thinked profound about it.
Hi,
Thanks for the info – never heard of DBus yet so will take a look at it.
Have you used this before?
Thanks again
Hi,
the DBus itself I have used on my Nokia N900 to change the frequency of the CPU when the charger is connected or disconnected.
On the RasPi I hadn’t use it at this moment.
I will learn something on how to safely lay a current on a GPIO of the RasPi and play a little bit with DBus …
I let you know when I have something to tell 🙂
Regards
Olli
Thanks Olli! I will have a look too and see if I can come up with anything as well.
After some reading at http://sourceforge.net/p/raspdbusgpiopy/wiki/Home/ i have figured out that raspdbusgpiopy use the same library as your scripts …
RPi.GPIO/raspberry-gpio-python
What will happen when we will work with DBus?
A messagehandler will listen on a defined channel … with the support of python. So there is no improvement to work with DBus – it will only adds a additional interface.
Actual you use Python. Sure – with an endless-loop … but i think raspdbusgpiopy use the same technique to listen on the GPIOs.
Maybe i find more time tomorrow to look at the code from raspdbusgpiopy to check if it will look with an endlessloop on the GPIOs.
Regards
Couldn’t you just set the edge to rising ?
Hi Eric,
Guessing you were suggesting what we have done in the interrupt based code we have just added?
Thanks
Not really, it was still based on the simple `while` loop script, but I thought you could just add something like `GPIO.setEdge(7, GPIO.RISING)` just after the `setup()` so that `input()` only returns when the value goes from `0` to `1`.
I haven’t done any GPIO in Python nor on the RPi, so I have no idea what the `RPi.GPIO` Python lib allows, but it I have used this ‘rising edge’ thing in C to avoid active waiting, so I know it can be done.
After doing a little research, this function in RPi.GPIO is named `wait_for_edge` (https://code.google.com/p/raspberry-gpio-python/wiki/Inputs#wait_for_edge()_function).
The full code, so you can feature it if you want, would be:
# Import the libraries to send os commands and access GPIO pins
import RPi.GPIO as GPIO
from os import system
GPIO.setmode(GPIO.BOARD) # Set pin numbering to board numbering
GPIO.setup(7, GPIO.IN) # Setup pin 7 as an input
GPIO.wait_for_edge(7, GPIO.RISING) # Wait for pin 7’s value to go from 0 to 1
system(“sudo shutdown -h now”) # Send shutdown command to OS
(Note that I haven’t tested this code as I don’t have anything currently connected on my RPi.)
As an added bonus, this solution avoids any active code while waiting for the shutdown signal, even if in your ‘interrupt’ solution the only active code reads the user input, which in turn blocks if the script is run without an input tty.
Thanks Eric – that is really helpful. I will test it out shortly and then can add it above as another alternative if all goes well!
That might work better, rather than using raw_input to keep the script running. I’ll have a go at refining it soon.
I have updated the code. It now waits for the button input.
http://pastebin.com/dczbWQ0T
Thanks Nathan, looks good!
We have some code as well that allows you to do a system reset or shutdown from the same button – using interrupt method like you have posted in that link and a button press time. Will test it and get it uploaded shortly.
Then will move on to code in other languages.
Regarding the “while loop version” of the code – as the script is being run from /etc/rc.local then it’s already being run as the root user, so there’s no need for the ‘sudo’ 😉
And for the sake of consistency it might be worth having both the interrupt version and the while loop version calling the same system command.
And finally where you’ve written “python /home/pi/PiSupply” above I think what you actually meant is “python /home/pi/PiSupply/softshut.py”
with the first bit – we were trying to show two different ways of doing it really, hence the difference. it might be worth mentioning this to people though so I will add a note about it. and true about the sudo bit – didn’t really think about that at the time I put it up!
As for the second bit – you are correct I made a bit of a mistake there. Thanks for the heads up!
Hmmm, does it _actually_ save memory though? I thought it just changed the way things are setup in the namespace to save you from typing extra characters later on in your script (Python probably still has to load the whole time module, because it can’t know if time.sleep will call other methods in the time module).
*shrug* Either way, I suspect the difference in terms of memory usage will be negligible, so it’s more of a coding-style thing really.
Feel free to prove me wrong with benchmarks… 😉
Doh, that was supposed to be in reply to https://learn.pi-supply.com/pi-supply-switch-v1-1-code-examples/#comment-266
Yeah, any difference would almost certainly be minimal. Most people would probably not notice either way.
I too would be keen to see benchmarks – wish I had the time to give these a go myself but just a little bit too busy right now!
Thanks
Hi. Any update on some additional code that allows us to not use Pin 8? I have a serial terminal connected to the GPIO pins 6, 8 and 10 with 8 being the serial TX. Is it just a case of pulling the pin high when the RPi boots up?
Cheers,
Steve
Hi Steve,
We will post the code shortly – thanks for the “poke”! Anyway, as you say all that needs to be done is setting a pin to a high output when the RPi boots up. As long as this is done within about a minute or two after you press the on button on the switch then the connection should be maintained. However it should be much quicker than this if done during boot up!
Hope that helps.
Thanks
Thanks for the reply. I shall try and have a look at that soon and post the code if I get anything working. My Pi Supply seems to time out after about 1 minute, which is much longer than the Pi takes to boot, so I shouldn’t have any problems.
Should the red LED on the Pi Supply light up when the pin 8 connection goes high? And presumably, as long as it remains high, the supply will maintain power?
Thanks,
Steve
I updated Nathan Bookham’s script to allow you to define an alternative to pin 8. It also uses “shutdown -hP +1” to shutdown in 1 minute rather than halt immediately, since that’s my preference.
http://pastebin.com/AAFHwFLr
Thanks for the excellent bit of kit. I enjoyed soldering it together and it’s really useful.
Steve
Hi again Steve,
Thanks for the update – your code looks great.
Would you mind if I use this code in the main text of this post above?
Thanks a lot in advance, and glad to hear you like the product!
No, not at all, please use it any way you like, I only added a couple of lines from InverseSandwich’s previous revision anyway. Glad it of some use:-)
When can we expect the promised the “full picture guide”?
Hi Jimmy,
It is coming soon – we are super busy with lots of things right now so has taken longer than we had hoped.
Also, we need to get our hands on some decent photography gear to get some good pictures.
Thanks a lot
Hi,
I have enjoyed all the comments and clearly many are tweaking and improving the script for the pi-supply.
Alas, as a newbie, I still don’t understand where I put this code, how I get it ‘into’ the raspberry pi, etc.
I only use my pi to run openelec (xbmc) so when I turn it on, it immediately boots into xbmc. to turn off, I ‘shutdown’ fromthe xbmc menu.
Exactly how I integrate the code to make my pi-supply switch functional is still a mystery to me.
I understand how to edit files and I have used putty to help set up the openelec/xbmc system, beyond that not much else.
I would be really grateful if someone could provide a simple set of instructions to explain what to do with the above scripts (perhaps the one from InverseSandwich?) to allow me to turn on/off/soft-reset my pi with the pi-supply.
Many thanks in advance.
Conor
Hi Conor,
So you are familiar with using Putty to SSH in to your Pi?
Thanks
Yes, just a little.
I have managed to follow various posts on other forums to set up the pi, set up NFS on my Synology 213j NAS box, and set up openelec (XBMC) on the pi.
But I was concerned that pulling the power lead and re-inserting it would damage the SD card, so the pi-supply looked ideal.
I just don’t know what to do to make it work for me.
Can you assist at all, please?
Thanks.
Conor
Hi Conor,
Once you are in the command line using SSH, do you know how to edit/create files using nano text editor?
If so then you can just type/copy the code from our code examples page into a text file, save it as softshut.py (or whatever you want) and then just follow the rest of instructions on our code examples page.
Thanks
I’ll give it a go!
I can’t work out which of the various scripts to use, given that so many comments have added tweaks and improvements!
Your code at the top of the page is not like the one posted by InverseSandwich – http://pastebin.com/dczbWQ0T – should I use his, and will it make all 3 buttons functional (Power off, soft reset/reboot, power on)?
Apologies for so many questions, but with so much code flying around I’m a little confused as to which to use, particularly since I boot directly into OpenElec/XBMC. Will the softshut.py script still work for my setup?
Thanks for advice and patience thus far.
Conor
Hi Conor,
You should just be able to use the code we have pasted in either the interrupts or while loop section on this page. Or you can use the one posted by InverseSandwich…they all do the same thing really (although the while loop one uses a bit more resources – so I would recommend either the interrupts one we have listed or the one from InverseSandwich).
The code is only needed for the soft shutdown button. The other buttons will work without the code, but you will still need pin 8 on the Pi Supply switch connected to pin 8 on the Raspberry Pi.
Thanks
I’ve created the softshut script in bash. So don’t require python or python-gpio installed. Here you are:
http://pastebin.com/SRJUFJ0q
Uses GPIO7 (!) which is gpio4 in this dialect.
Fantastic, thank you very much. Do you mind if we post this above?
Cheers
Hi! I just wrote a C++ program that handles this: https://github.com/kr15h/PiSupply. Tested and working.
Some comments about the product itself:
– Shipping is away too slow. It took more than 3 weeks to get to Latvia and that was a week past a project deadline. Fortunately I found another solution to the problem.
– Otherwise it’s great! Design-wise I think the Soft Shutdown button should be emphasised somehow as this is the main benefit of such a circuit.
Hi,
Thank you very much for the link to the C++ program. Would you be happy for us to post the code on this page?
Also, apologies if it took longer than expected on delivery. Unfortunately once in the hands of Royal Mail there is not a lot we can do on the timeframe and shipping to some countries can take a while…especially around this time of year!
Glad you like the design though, and thanks for the product feedback. Much appreciated.
Cheers
This calls “sudo halt”
Can that command be simply replaced by “sudo shutdown -h now” and it all run?
Why, well the Raspbmc builds tends not to shutdown fully with a halt, as it doesn’t close the mount points.
It’s taken me a good three weeks to work this out since I emailed Pi-Supply over it a few weeks ago. I’ve finally worked out my Pi Supply switch works fine, pushing the soft off triggers the code, its just the HALT command on Raspbmc does not let the system not to fully shutdown so Pin 8 never goes low to allow the soft shutdown to actually cut the power.
Hi Gavin,
Yes sudo halt and sudo shutdown -h now should do the exact same thing in raspbian. By the sounds of it you are saying that in raspbmc they do not! I wasn’t aware of this so thanks for the heads up!
Cheers
I’m not an Linux expert, and so this is my understanding.
Halt calls an unconditional halt
Shutdown calls shutdown scripts then halts.
RaspBMC must keep some files open on the SD card as its running and so the HALT doesn’t allow them to close correctly.
My guess is the HALT closes the RaspBMC software and tries to unmount the SD then power down. However the RASPBMC is HALTED before it’s correctly closed the files so the system gets stuck in the shutdown process, it can’t unmount the SD card as its got files open, but RaspBMC can’t close the files as the software has already closed, As a result the system never enters the low power mode, Pin 8 remains high and the power not cut, and so it sits there.
The SHUTDOWN command gracefully closes the Raspbmc which allows it to close the files BEFORE demounting the card, so shutdown proceeds as you would expect and the soft off then cuts the power after 2 mins as expected
For completeness if anyone else is following the GITHUB script above I’ve requested a change, but replace “sudo halt” with “sudo shutdown -h now” before you run the line gcc -o PiSupply….
If you’ve already compiled it you’ll need to remove the PiSupply directory and re-clone it, edit it with nano, then re-compile it. There may be other ways to do that but tht was the easiest for me, just editing the file and re-compiling gave me lots of errors.
Yes, feel free to post the code. And the “sudo halt” is replaced with “sudo shutdown -a now” now. Sp there should be no problems with it on other Pi OS’s
Krisjanis – many thanks for posting your program, I was having some issues getting PiSupply working reliably with the Python scripts but your program seems to be working like clockwork!
Aaron – thanks for an excellent piece of kit.
I’m struggling to get this working on raspbmc. Python script fails saying no module named RPI.GPIO.
So thought I’d try Krisjanis program and managed to install wiringPi with these installed:
sudo apt-get install -y gcc make
However I’m stuck after entering this to compile pisupply:
gcc -o PiSupply -I/usr/local/include -L/usr/local/lib -lwiringPi main.cpp
I get this:
gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
Hi,
It sounds like you have not got the RPi.GPIO module installed.
Once you install that, the python script should work perfectly.
Thanks
Ok I was referring to the c++ program but I’ve tried again with the python script with instructions here:
http://learn.adafruit.com/send-raspberry-pi-data-to-cosm/necessary-packages
Did:
sudo apt-get install python-dev
sudo easy_install -U distribute
sudo apt-get install python-pip
sudo pip install rpi.gpio
now I get:
Traceback (most recent call last):
File “softshut.py”, line 15, in
gpio.add_event_detect(7, gpio.RISING, callback=shutdown, bouncetime=200) # Set up an interrupt to look for button presses
AttributeError: ‘module’ object has no attribute ‘add_event_detect’
Hmmm. I am thinking that you have possibly installed an old version of RPi.GPIO which did not yet include the interrupts. Does the while loop code work for you?
Are you able to make sure that you have installed the latest version of RPi.GPIO please – https://pypi.python.org/pypi/RPi.GPIO
Thanks
Also, any way to implement a reboot function on this program? Thanks for the code
Hi,
When you say you want to implement a reboot function, do you mean instead of shutting down? Or as well as?
Thanks
I meant as well as. As in someone mentioned on here to adjust the soft shutdown press for more than 2 secs to reboot?
Hi,
Yes, this is definitely possible. You should actually be able to make it so that pressing for 3 seconds would cause a reboot, and for 7 seconds would cause a shutdown.
I will have a play with some code as soon as I can and try to get something working. Maybe you can do the same and between us we can hopefully come up with something useful 🙂
Thanks
hi guys.
New to the RPi as I am using it to run an incar system to a touch screen based on openELEC. Building the kit was very simple and it worked first time with the on/off buttons but I cant get the softshutdown to work. I have followed everything on here to the letter but it just doesnt do anything.
Whilst I am new to linux in general I have an understanding of SHH etc (trying to calibrate the screen) but this has me stumped!
Does the LED on the Pi Supply Switch light OK? And which bit of code did you use?
Thanks
Hi guys.
Now I use “while loop” which works without problems.
But I can’t make “interrupts” to work.
I got runtime error: Failed to add edge detection
Any help is appreciated, thanks.
Hi,
What operating system are you using?
Thanks
Raspbian
Thenks
Did you copy the code exactly? Including the relevant capitalisations on letters?
Do you have the full error message? It is likely just a small error in the code somewhere.
Thanks
After reading your code examples, I understand how the script reads input on pin 7 to detect a button press. But what is pin 8 used for?? I did not see that mentioned anywhere. Does pin 8 somehow send a signal when the Pi is shut off? When does the capacitor begin discharging? My point is, what happens if the Pi takes an unusually long time to shutdown because of some software?
Hi there,
Yes, pin 8 under Raspbian operating system is high when the Pi is on, and low when the Pi is off. This is the default functionality.
The switch will only start to shutdown once the Pi has put pin 8 low, which will be after all of the software has shutdown on the Pi. Which means you have nothing to worry about 🙂
Thanks
Hi,
everything else is working fine right now with the switch, but the soft_off script hangs the whole boot:
I power up the Pi with On button, the kernel loading texts etc come to the screen and after it says “My IP is…” it hangs there. This point is after which the soft_off python code is loaded from the home directory.
The soft_off script works when I press the button, but any help on how not to get halted and boot correctly? I can’t get to the login point anymore.
Cheers!
Never mind, I solved my problem:
in rc.local in added “&” at the end of the python command so it runs in the background.
I’m using the latest (wheezy) Raspbian from Noobz.
Hi again,
There must have been a change in something on Raspbian, as the code was verified working from a fresh Raspbian install before without the & sign.
Anyway, we have now updated the page to include the & sign at the end…so we really appreciate your investigation work here!
Thanks a lot
Hi,
i am a programing noob, im looking to use this with my rpi XBMC center.
i understand the wiring and the way it works, im just looking for a step by step guide as to how to get it to shutdown,
im running raspBMC
Many thanks
simon
Hi Simon,
Have you seen the code examples?
All you have to do is enter a terminal session, create a python file (using the nano text editor or similar), and either copy and paste or type the code into the file, save it, and then follow the instructions to get it to run at boot.
Let me know how you get on.
Thanks
Hi,
I bought the PiSupply, but im having a slight issue, the on and straight off works. but when i use the soft off, nothing happens, i am using the interrupts code on a Pi b+.
Im using pins 7 & 8,
If i run python /home/pi/PiSupply/softshut.py , it shuts down the system. this is without pressing the soft button, which i wouldnt have thought should happen
thanks in advance
Hi Carl,
Does the while loop code work for you?
Will look into why the interrupts code is shutting down Pi without keypress.
Thanks
Thanks for your post on our product!
OK, thanks for that.
As I have already built the pi-supply as per the instructions, I have soldered in the little jumpers onto 7 and 8 on the pi-supply. I have a small 2-pin jumper lead that came with the pi-supply as well. Is this what I use? And do I connect both the pins (7 & 8) from the pi-supply to somewhere on the raspberry pi itself? If so, where? and how? (I’ve got my pi in a colourful plastic case, do I need to remove the case to connect the lead?).
Thanks again.
Conor
Hi Conor,
You need to connect pins 7 and 8 on the Pi Supply switch to pins 7 and 8 on the Raspberry Pi using the female to female jumper cable that came with your Pi Supply switch. These are the 4th pins from the edge on both the top and bottom rows…see here for more info – http://elinux.org/RPi_Low-level_peripherals. Make sure pin 7 on the Pi is connected to pin 7 on the switch, and the same for pin 8.
You will then need the code set up in order to get the safe shutdown functionality working, but the on and off buttons will work with just pin 8 connected.
Thanks
OK. That’s clear now.
I’ll try that soon and report back.
Thanks for your continued support.
Conor
Hi Conor,
Ok great – let me know how you get on.
Always happy to help!
Thanks
Epic fail!
Completely failed at the first hurdle – header pin connectors so long on the supplied cable that I cannot close my Pi case (the very lovely pibow rainbow box that the kids chose).
No idea what to do now. Have wasted time and money (and learning to solder and de-solder!) on incompatible switch.
Do they make smaller push-on connectors for the header pins?
Help!
Conor
Aaron,
I let you know how I got on (above).
Any suggestions as to how I solve my new problem?
Thanks
Conor
Hi Connor.
I too have a Pibow and I can fit the jumper wires in the case. Your Pibow has a slot near the pin header. Loop the jumpers a little then slot through the hole.
Hope that helps!
I soldered up the pi-switch and it worked first time! So did the soft-switch code! (I used the interrupt one) I know nothing about Python but used ssh and nano to input the code; it was simple. Thanks for your clear instructions. Some of these sites can be as clear as mud to us newbies.
Hi Alan,
Glad to hear you are up and running and that you found everything easy to understand.
If you would be kind enough to leave a product review on the product page, we would be very grateful – https://learn.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/
Thanks again