How to Add a Power Button to Your Raspberry Pi (+ FLIRC Case Install!)
Vložit
- čas přidán 17. 08. 2019
- In this video, I'll teach you how to build your own Raspberry Pi power button, allowing you to shut your Pi down safely! I'll also show you how to install it in a FLIRC (or other Raspberry Pi) case. This will work with any Raspberry Pi model (Raspberry Pi 4, 3, Zero, etc.)
---
● View the full text/photo guide on howchoo:
howchoo.io/raspberry-pi-power...
● Everything you'll need (direct links):
1. Premade button: howchoo.io/pi-power-button-yt
- OR -
1. Normally Open (NO) momentary button: amzn.to/2HdRlq4
2. Jumper wires: amzn.to/33GlsQH
3. Soldering iron: amzn.to/2KGN7JC
4. Solder: amzn.to/2HcB3xP
5. Raspberry Pi 3 FLIRC case (optional): amzn.to/31NC873
6. Raspberry Pi 4 FLIRC case (optional): amzn.to/328YOQw
● Or, see all products in our Amazon List:
www.amazon.com/shop/howchoo?l...
● Build your own 3D-printed soldering fume extractor:
howchoo.io/diy-solder-fume-ex...
● Raspberry Pi 4 EEPROM/bootloader:
Download link: drive.google.com/file/d/1hrnz...
Release notes: www.raspberrypi.org/forums/vi...
● Theme song:
"Microchip" by Jason Farnham from the CZcams Audio Library.
● Affiliate link/advertising notice:
I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to AMAZON Sites. When you click on an Amazon link above and buy something through Amazon, Amazon may give me a small commission. - Věda a technologie
Simple , straight forward, like that. Thanks for this video it actually was more helpful than I first imagine.
Wow! 100% on my Pi 4. This was an awesome little project.
This is by far the best tutorial for a power button. Very easy to do thanks very much
Thank you for the tutorial! Very easy to follow along and it worked just like a charm.
Aw man. Seeing those RadioShack switches brings back memories. That was my first job right out of high school!
Aww yeah. I miss being able to run there to pick up a quick component or switch last minute-worth paying 5X the price :)
Radio shack was called Tandy in Australia back in the day.. Gone now.. Jaycar is my shop now when I need something right then.
Worked Great, I ran the code ahead of time, Thanks for the howto Video
Awesome!! Thanks so much for your scripting, your video and the detailed write up on your site. I just wired and installed on my Pi4 which is in vehicular use. Now, so much easier to shut down gracefully, with a physical button, instead of the GUI (or worse, turning off ignition key and hard-crashing the pi). I was prepared to copy and paste the code, run it at boot up etc etc. But your script did all the heavy lifting. Cheers!!!
Great instructive video howchoo! I've been looking for this to add to my Pi 4B for days. Works great. Thanks much for making this video.
No problem! Stay tuned for more :)
WOOOOOOWW! THANK YOU VERY MUUUUUCH! Worked on first try :)
Man that worked like a charm! Thanks for saving me from pulling my hair out🤣.
Tried older diys with no luck, then finally found this! Thank you sooooo much!!
No problem!
Thanks for the nice tutorial, now i was easily able to add the power button and status led to some pi3 and a pi4! thank you!
Great video, as the guy below stated, easy to follow and worked like a charm
Excellent video!!! I just bought the premade button from your website, and will complete the project!!! Also liked and subscribed!!!
M. Hannis Awesome! Glad you liked it, we’ll ship your buttons out today :)
Awesome work, man. Thank you a lot :D
Works on PI 4 in March 2023. Many thanks for all the hard work saving me loads....
You legend. Thanks so much - this worked first go - super fast - super easy - THANKS SO MUCH
Super easy and it worked on my Pi4! Thanks so much
Great video! I tried it on raspberry zero W and it worked on first try!
Nice!! Thanks for share!!
Excellent tutorial! Simple to follow and no bs!
Aw, thanks so much! Glad you enjoyed it :)
simple and worked without any extra hassle......great ! Thanks to you....
You're welcome!
Thank you! This works really well.
Worked perfectly thanks!
Nice work, thank you! Works fine with my new Pi-Hole. 👍
Thanks you so much. This video helped me a lot.
No problem! Glad it helped :)
clean and nice work!
Thanks!
Obrigado! Fiz e deu super certo.
Great video, thanks for sharing this. Is there an easy way to add a delay for shutdown? I’m using this in my vehicle and it has some interference. I figured if I add a .5 sec shutdown delay (hold the button for .5 sec) it will keep the noise from shutting down my PI.
This video should have a ton more views. Great video.
Thanks! All in good time ;)
Thank you so much!!
Thanks working great!
just one question, I've tried to change the script from PIN 3 to PIN 21,
now it only shuts down the pi and not waking it up.
any suggestions?
thanks helped a lot :)
Can I use different pins? The ones you showed are occupied by a display I'm using.
Perfect!! My bartop is now 100% finished. Thank you 🙏🏼
No problem! Sounds like a cool project :)
@@Howchoo is usb3 speed still shafted on the 'new' firmware - I'm holding off on updates as All of the ones released so far have had other issues. I know it's a small risk but I'd reticent about bricking another one - having had one dev machine blowing it's hdmi 0 socket off from under-powering
Power Button: "Burrrrrrpp!!!!"
Me: I'm cutting you off!
Great video, thx
I think i will add a led if i do that, idk if it worth i but i like having visual that its "on" when using button like that
Hello,
Running Buster on a Pi 3b+, your script is the only one I got to work, thank you.
Question, is possible to add a "Hold" time in the script so the button has to be held down for x number seconds before shutting down. Many thanks.
This worked great for my arcade cabinet power button until I needed to add a fan in 5v mode using pins 2 and 6. Can I use any other pins for a power button?
What kind of wire stripper do you use? I really liked that one
Which pins should I use when doing this with a 7" pi touch screen? Pin 6 is used as part of the wiring for that so are there alternatives I could use instead?
Hello can I connect 2 wires in the same gpio for the screen and the buttons ?
Awesome video I got my rpi 4b on dec 25 and it worked no problem no need to get the latest version. Btw recommend turning off the pi through the interface like you would a regular laptop or pc but turning ot on worked no problem.
Great, thanks for the info!
great, thank you
Thank you!!!!!
CRACKING I love it I now if have my raspberry pi 4 in a *" fractal pc case "*
Using the cases power button to boot it up I will upload a video to my channel of it running off a power bank on my Sony 43 TV I LOVE IT with only 1 cable out of it witch is the HDMI cable
Thanks for this wonderful howto video. I did it to my RPi3B and it works. I have a question though. Do you have a tutorial on how to add a serial (RS232) port on a RPi3B+? I need a communication port to control a serial modem.
Thank you for your script. Works great even on a Raspi 1 :)
hi, thanks for showing. I have a question, can you do this with a touch (capacitive) button? By touching the button for 3 seconds? that would work and if so, how?
looking to add an LED on my Raspberry Pi 4b. Can I also add a raspberry pi fan as well? Or are the pins taken up by the button?
Can I use pins 5 and 9 if I'm already using 4 and 6 for a fan etc?
Great video - very clear and easy to follow. Thank you for sharing..
Is the button a momentary button..
Hey quick question, so if I am supplying power from an OBD2 adapter in my car, stepped down from 12v to 5v and then plugged directly into the usb port, if I run this script will it still shut down the pi? I am trying to think of ways around splicing a toggle into the obd cable. thanks!
does ground need to be pin 6 or can it be any ground pin on the board? because 6 is already populated by a pwm cooling fan on mine.
Hey I have octoprint on my pi3b+ I was wondering if this will work with my instance of octoprint or it will corrupt my pi
Managed to make it work with a switch rather than a button. followed your instructions carefully and it works! now I need to figure out how to turn off the fan
Hi! May I ask what type of switch did you use on your end? Will a rocker switch work?
@@kurtroyales2659 yes a 2 way rocker switch with 3 connection points
Hi, nice video, I am using the 7 inch touchscreen which utilises pins 5 and 6 already, is there an alternative pin out location i can use for the button?? TIA. Ian
The only two pins actually required for the touchscreen are 5V and GND - consider if your use case actually requires you to use any others - it might not.
awesome, works!
Good to hear!
How do you do the software if you have a different operating system installed on the raspberry pi? I have Emteria OS installed on mine
Hi! Good work!
Unfortunately, however, although following all the steps indicated, this scheme does not work on my Raspberry Pi B+ V1.2 (2014) either with regard to the led or the on/off button (cf. the other video). Do you have any suggestions that can help me?
Thanks in advance.
Thanks for this, very helpful. My PI ws turning on and off fine but all of a sudden it only turns it off. It won't turn back on and a reboot command is the same, shuts off but won't come back on.
I have implemented this on a Raspberry Pi 3 and it works very well. Kudos to you for very clear instructions. I have a question that perhaps you can help answer. Will this solution work to power down the pi running on battery power when the battery is running low? I am guessing that pin 5 will go logic low as battery runs out, effectively same as shorting with pin 6 (GND). Thank you 🙏
Hey can someone tell me if after I turn of the raspberry pie can I leave the power still plugged into it or should I take that out?
Does this work with a regular non monetary NO switch? The pi is in a setup with a few other things that require a latching switch.
That's a 3d printed coffee cup!! :D nice vid.
Can you please provide me instructions to make it work on libreelec
This works on osmc, but after the wake (power on by switch) does not play videos and rpi4 is slow, Need to reboot it to work properly
It looks like the I/O connectors are too tall to clear the case. Did you shorten them somehow?
many manual have open leafpad shutdown.py. my new raspi 4 bulsseye not have leafpad what hell leafpad have. i not has newer hear this. and i not understand how thonny python used, write scipts and were save trhis. and how make main start run.
Great tutorial, thanks a lot. I was wondering how can I keep the host connection active even if I shut down the pi. PS. I am using Putty on Windows
What if the power button had an LED light built-in with 4 pins, and all the pins are the same length? Where would place the resister? I have an + /- pin. I know where they go, but I'm not sure about the LED.
Will the raspberry also turn on when you re insert the power (usb) cable or can you just insert it and need to press the power button? Because I don’t want it to unnecessarily turn on when inserting power cable. Just like a normal computer for instance.
Bist der beste ;-)
I have a question. If we are already using Pin 5 for another thing like a controller, is there any way to change the pin settings for the button? Also great video!
2:38 Can I use Male to female jumper cables and tape/hook in the male ends to the button's pins?
So does the button only work on sd cards that you have written this code to? So if you reflash your sd card with another software, you'd have to redo all these steps?
Does this work with other OS's like retropie, OSMC, or Kodi?
Don't have a soldering iron? Get a pre-soldered button here! howchoo.io/pi-power-button-pinned
See the full guide on howchoo: howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi
Thanks for the video. I have a pi4 and would like to do this with a touch power button.. is this possible. it has gnd / io / vcc ?
yes this should be possible if you wire the gnd to gnd, vcc to 5v available on the board, and io to pin 5
Using this on PI 4 with OctoPi and OctoDash cause a random stop job to be sent during prints. I am not sure how or why this is happening but it did not happen before installing and doesn't happen after uninstalling.
Hey Zach! Love you channel, and appreciate all of your work.
Download link says "Sorry, the file you have requested does not exist."
my pi4 will shutdown but the CPU Cooler is still spinning and LED on NIC flashing like crazy. How to set it to kill all power on the 5v completely?.
Got it, i made a type fault, works perfect thank you👍👍👍👍👍
Excellent!
@@Howchoo does it switch the negative wire? Open and close
@@lucbisschops What do you mean? It doesn't matter which order the wires go; there's no polarity here.
@@Howchoo ahhh ok, thats my problem than i have a psu relais controle for my 3d printer on my raspberry aswel, and the ground was pluged in on the same place your ground for the killswitch was programed in your script, thats why, when i shut down my psu relais, the raspberry pi shuts down aswell, is there a way to rewrite the script for a different position of the gpio.
I have an error even though I have installed the rpi.gpio library.
pi@raspberrypi:~ $ Traceback (most recent call last):
File "/usr/local/bin/listen-for-shutdown.py", line 4, in
import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO
I appreciate any help from you, thanks
I'm having an issue on a 3b+ where after about 15 minutes the device will power back on automatically. Is anyone still monitoring this thread that might be able to lend a hand? Thanks
Is there a way to start different video in a loop with different pushbuttons?
I am vollanteer in a museum and want to show short video in different languages beginning with a info video to ask to push the button off there choice. The Pi starts with a pir. Sorry, english is not my native language.
Has anyone else had an issue of the pi powering down when a usb cable is plugged into one of the usb ports? Whenever I try to plug a cable into the Pi, it will act as if I had pushed the button to turn it off. Once the cable is plugged in at both ends the Pi will start up and run as normal (octopi).
Hey will it only work in raspbian os......
I use the SCL pin with an I2C lCD. Can I still use the same pin to make the shutdown button?
Unfortunately not; you could make a button that simply shuts down, but the WAKE functionality (to turn it back on) requires SCL. You could always disconnect and reconnect the AC adapter to turn it back on, however.
strange? im getting this error yet i am using a raspberry pi 4gb
Traceback (most recent call last):
File "/usr/local/bin/listen-for-shutdown.py", line 4, in
import RPi.GPIO as GPIO
RuntimeError: This module can only be run on a Raspberry Pi!
Can someone help me with this please? Ive been using this for weeks and I did a sudo update on my pi the other day and the restart button wont work. Ive tried reinstalling and i always get the same message at the end: Import error: No module named RPi.GPIO.
I have a raspberry pi 4 and the pi 7 inch touchscreen. it uses the same pins is there a way to add a power button to that setup?
I was able to get a power button installed on my setup
Hi,
I'd like to execute the script on my Raspberry Pi 2 with SMBShare installed on it.
The issue is : I can't use WiFi with it. I tried to install it offline : I managed to download the GitHub files on my PC and placed them in a folder "pi-power-button" on the SD Card.
But then I can't find a way to execute the install file using the path in the video (./pi-power-button/script/install).
Anybody could help me on this ? Thank you
Hi @Howchoo, can you post the updated google drive location for the bootloader files please. Currently link no longer works
If I have a small case fan ground going into pin 6, can I just move it to another ground on the pi? Does it matter which ground?
You can use any other ground pin as well
when I run the script I get this error /usr/bin/env: ‘python’: No such file or directory
Quality.
:D same third hand , same soldering machine :D i just have blue one :D awesome one for its price
Hi guys,,do anybody knows or it's familiar with my problem?please help,, OK for some reason when I turn on the system start normally until just go straight to my favorites games and get freeze and there's nothing I can do with my controller,,there's any way to do like an update or restart it but this one cut be worse cuz I'm not to good with this Cain of stuffs and I don't want to make it worse,,someone with the same problem? Thanks
Hi when I run ./pi-power-button/script/install I get file "/usr/local/bin/listen-for-shutdown.py", line 4, in import RPi.GPIO as GPIO ImportError: no module named RPi.GPIO
Is there a way to fix this? I have tried pip3 install RPi.GPIO and it says requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (0.7.0) but when I press the button nothing happens, I'm using an early Rpi4 4gb with updated eeprom and os
Hello! I'm currently planning out my first RPi project ever and I'm curious whether or not you know if there's a way to have it where you have to hold the button to shut down. With the project I'm planning, I'd imagine there's a chance of the button getting accidentally hit during use, so I want to mitigate this problem before it even begins. You wouldn't happy to have any thoughts regarding this, would you?
This could be done by forking and modifying the code-would require some knowledge of Python, but it can definitely be done :)
For a raspberry pi 4 you can now update from the Terminal so no need for the boot loader, but once you install everything do a reboot first and then the button turns off and on. Thanks for the tut 👍
with sudo apt update?
i not understand anythink what speakl and need do after shutdown-listeninig and test. and this shutdown my raspi good,then plug power of and back on start raspi again good. what then need do i not understand lot speak but what. i not know anythink. but after shutdown i bush button and not do anythink after re start raspi ??? what hell thisa need do run start boot this script ????