Nice tutorial. If you use pins 5 and 6 instead then once the pi has shut down, if you push your button again, it will start up again. No need to remove and re-apply power.
Andy Powell That's something I will definitely have to try. How does it work? Does one of these pins function as a kind of reset pin when the pi has been shutdown?
Luc Small It's a gpio interrupt. Works well, I only have one button to startup and shutdown my Pi. ( dl.dropboxusercontent.com/u/188253/pifi-button.png )
+Andy Powell I was thinking in implementing your solution for my project, but pin 5 is the SCL signal for the i2c port which I use a lot, so for my case it wouldn't work, right?
Hi great video!. Question .. So all you need is just a push button? Nothing else? What is that little board on the right in the beginning of the video? Im just asking because other videos have small circuit boards and this seems too easy. Any information would be greatly appreciated
Juan Rodriguez Yep - just a push button. The board on the right is a wifi dongle that's been stripped of its casing and soldered directly to the raspberry pi. Check out my earlier video on the raspberry pi camera rig for more details about the wifi dongle. I assume the solutions that have boards are doing some hardware switch debouncing and a hardware pull up resistor. They also probably have the capacity to reset the raspberry pi once it's shut down. By contrast, I use the raspberry pi's built in pull up resistor and once it looks like the button is pressed, I sample 20 times over 2 seconds to verify it really has been intentionally pressed to avoid a spurious current spike or accidental short press from shutting down the raspberry pi.
I would recommend the one with the 2 resistor voltage divider just for good measure, but directly putting 3.3 to grip shouldn't pose problem, neither should grounding the gpio pin.
Hello good afternoon. can you help me? Studs for raspberry pi 2 are the same? What would be the script and how where I should put in recalbox could help me? I'm trying to put a button to turn off within the SNES but without success. Thnks! Beto.
Depends what you want it for, you could also use sudo reboot if that's what you need, halt and shutdown are almost identical but I believe halt can be interrupted and started back again also I think any displays stay connected
@@CoolAsFreya So all the button does is issue a `halt`? You leave power on the board? So you will need to pull the USB power jack & re-insert it to re-start the PI? Is that it?
Can you provide a link to that button that you used by chance? I need to know how deep it is as I am trying to put together a custom retropie build and want to use the existing push button built into the casing of the old console. Thanks!
i followed these steps and when i go to boot it runs all the normal stuff and then says now halting and shuts down. i assume i have a typo in the file but now i cant boot up to edit the file. can anyone help!!
Not 100% sure if this will work because of permissions, etc. But if you have another Linux computer, you might be able to mount the main partition on the SD card, edit the mistake, unmount the partition, and then try to boot the raspberry pi again.
Hey for anyone who might have made a similar mistake I fixed it by using an sd card reader. I would recommend for anyone to just edit the bash (.sh) file itself but since I was stupid I put it in a mounted directory that was linked somehow with the boot partition not the root partition so I wasn't able to access the file from anything but the pi. Luckily I looked up where the crontab are located and found the one then modified the code, to remove the invading script from starting at boot. Another issue I had was that i could read the Linux partition on the card with a card reader and a windows computer with a simple free program but I couldn't write to it so I actually used the raspberry pi with a blank raspbian os on it, the card reader (it is USB 3.0 but it worked) and a USB drive with the fixed crontab, I then removed the old one from the sd (wouldn't reccomend this but it was that or nothing) with rm and copied the new one over with cp (make sure you use sudo for both commands)
+QuadCopter Uploads basically I found the crontab file on the sd card and edited it in the end, and now I have a 30 second emergency delay on the shutdown button script before it enables so if another error occurs I can disable it without the pi shutting down as soon a it boots
CoolAsFinnBro sadly im attempting a fresh format as I couldnt keep the pi on to ssh with it to change anything and having a windows pc i couldnt edit anything. Thanks anyways
Your change should work just fine. To be completely safe, I would recommend taking an image of your SD card before making the change; then make the change and test ... that way you can restore from the image if for some reason the change causes issues. But I'd say that if the script is working with sudo halt already then changing to shutdown -h now is a pretty safe move.
did it work? and why not just do both first sudo halt and then sudo shutdown-h now also will this work on the zero 1.3 and zero w running lite builds like jessie and stretch lite? and do those lite builds have anything already built in that does the same thing as this?
Exactly what I was looking for: a simple shutdown button. Thanks!
Nice tutorial. If you use pins 5 and 6 instead then once the pi has shut down, if you push your button again, it will start up again. No need to remove and re-apply power.
Andy Powell That's something I will definitely have to try. How does it work? Does one of these pins function as a kind of reset pin when the pi has been shutdown?
Luc Small It's a gpio interrupt. Works well, I only have one button to startup and shutdown my Pi. ( dl.dropboxusercontent.com/u/188253/pifi-button.png )
+Andy Powell Mind showing your schematics and the script for that one? Would be great for the mini retro system I am building into an old SNES case.
For shutdown, yes. No code is needed for just starting. I just wrote a small c progam for the shutdown part
+Andy Powell I was thinking in implementing your solution for my project, but pin 5 is the SCL signal for the i2c port which I use a lot, so for my case it wouldn't work, right?
Is there any way to make this work with a non-momentary on/off switch?
Hi great video!. Question .. So all you need is just a push button? Nothing else? What is that little board on the right in the beginning of the video? Im just asking because other videos have small circuit boards and this seems too easy. Any information would be greatly appreciated
Juan Rodriguez Yep - just a push button. The board on the right is a wifi dongle that's been stripped of its casing and soldered directly to the raspberry pi. Check out my earlier video on the raspberry pi camera rig for more details about the wifi dongle.
I assume the solutions that have boards are doing some hardware switch debouncing and a hardware pull up resistor. They also probably have the capacity to reset the raspberry pi once it's shut down. By contrast, I use the raspberry pi's built in pull up resistor and once it looks like the button is pressed, I sample 20 times over 2 seconds to verify it really has been intentionally pressed to avoid a spurious current spike or accidental short press from shutting down the raspberry pi.
Where to buy push button and gpio header pins?
Is there any reason why this wouldn't work for a Pi 4B?
good stuff. I am going to apply this on my rpi b v1. fingers crossed. I am new to python.
I don't know how to set up the directory for the files. Do I simply create a folder and drop that file in there? Is there a more novice walk-thru?
I don't understand the button 7 link you talk about. Is that a physical connection via soldering?
Is there a variation on this that would also work with the Pi Zero without a secondary power board?
does this not need a resistor to work? im afraid of messing up the pi with too big of a current
I would recommend the one with the 2 resistor voltage divider just for good measure, but directly putting 3.3 to grip shouldn't pose problem, neither should grounding the gpio pin.
Very useful Thanks.
Hello good afternoon.
can you help me? Studs for raspberry pi 2 are the same?
What would be the script and how where I should put in recalbox could help me?
I'm trying to put a button to turn off within the SNES but without success.
Thnks! Beto.
hi great video but how to i do it just copy the Raspberry-Pi-Shutdown-Button/wait-for-power-off-button.sh from your link?
why sudo halt not sudo shutdown?
Depends what you want it for, you could also use sudo reboot if that's what you need, halt and shutdown are almost identical but I believe halt can be interrupted and started back again also I think any displays stay connected
@@CoolAsFreya So all the button does is issue a `halt`? You leave power on the board? So you will need to pull the USB power jack & re-insert it to re-start the PI? Is that it?
Can you provide a link to that button that you used by chance? I need to know how deep it is as I am trying to put together a custom retropie build and want to use the existing push button built into the casing of the old console. Thanks!
I would also love to know which button you are using and where I can find it on the web ;-) thanks a lot in advance!
It's a standard momentary switch. Can pick them up at any electronic/ computer store for 2-4$
www.BangGood.com
code link?? plsssss
i followed these steps and when i go to boot it runs all the normal stuff and then says now halting and shuts down. i assume i have a typo in the file but now i cant boot up to edit the file. can anyone help!!
Not 100% sure if this will work because of permissions, etc. But if you have another Linux computer, you might be able to mount the main partition on the SD card, edit the mistake, unmount the partition, and then try to boot the raspberry pi again.
Can u make it s
Can someone help I made an error in the script and now the Pi shuts down every time it boots
Hey for anyone who might have made a similar mistake I fixed it by using an sd card reader. I would recommend for anyone to just edit the bash (.sh) file itself but since I was stupid I put it in a mounted directory that was linked somehow with the boot partition not the root partition so I wasn't able to access the file from anything but the pi. Luckily I looked up where the crontab are located and found the one then modified the code, to remove the invading script from starting at boot. Another issue I had was that i could read the Linux partition on the card with a card reader and a windows computer with a simple free program but I couldn't write to it so I actually used the raspberry pi with a blank raspbian os on it, the card reader (it is USB 3.0 but it worked) and a USB drive with the fixed crontab, I then removed the old one from the sd (wouldn't reccomend this but it was that or nothing) with rm and copied the new one over with cp (make sure you use sudo for both commands)
+CoolAsFinnBro i am having the same problems, but cant follow what you said
+QuadCopter Uploads basically I found the crontab file on the sd card and edited it in the end, and now I have a 30 second emergency delay on the shutdown button script before it enables so if another error occurs I can disable it without the pi shutting down as soon a it boots
CoolAsFinnBro sadly im attempting a fresh format as I couldnt keep the pi on to ssh with it to change anything and having a windows pc i couldnt edit anything. Thanks anyways
Will this code work if I exchange sudo halt with sudo shutdown -h now ?
Your change should work just fine. To be completely safe, I would recommend taking an image of your SD card before making the change; then make the change and test ... that way you can restore from the image if for some reason the change causes issues. But I'd say that if the script is working with sudo halt already then changing to shutdown -h now is a pretty safe move.
Excellent! Thanks so much Luc for the comprehensive guide. I will try your script asap with that slight modification!
did it work?
and why not just do both
first sudo halt and then
sudo shutdown-h now
also will this work on the zero 1.3 and zero w running lite builds like jessie and stretch lite?
and do those lite builds have anything already built in that does the same thing as this?
where u buy button
www.BangGood.com
WHAT?