Back to Blog

Safe Off Switch to Power Down Your Raspberry Pi

Some time it is hard to find solution for raspberry pi.

This time we are solving issue : how to Power Down Your Raspberry Pi using GPIO.


copy script from


sudo apt install python3-gpiozero

#connect button GPIO 21 and GND

#run below command to test


# hold button(gpio21 and GND) for 2 second . your pi will be shutdown.

If it is ok then power on your pi3 again


Now execute your script ,when raspberry pi power on every time.

sudo nano /etc/rc.local

in rc.local file at the end your code must be look like this

python3 /home/pi/ &

exit 0 - 1

Thats it now . restart your pi again and test it….

Share this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Blog