Easily Add A Shutdown Switch To A Raspberry Pi

The Raspberry Pi doesn’t have a power switch, which means you have to remember to actually properly shut it down every time you want to turn it off. If you don’t feel like running those extra commands, Instructables user AndrewH7 shows you how to easily add a shutdown switch.

Basically, you’ll just add a small wire to a GPIO and wrap a piece of electrical tape around it. Then, you’ll install a bit of software so that when you tap the switch, it will run the proper shut down commands for the Pi. This isn’t the most elegant-looking solution in the world, but it’s easy to do. It’s especially handy if you’re using the Pi as a headless machine but still want to safely shut it down now and then.

Simple Raspberry Pi Shutdown Button [Instructables]


  • Unfortunately, like several others, for me entering this code absolutely hard crashes the pi (B+) on the first reboot. NO keys or key combinations do anything, except the old 3-finger salute, which reboots again, into the same problem. As far as I can see there is NO WAY to recover except by reinstalling os and going thru all the reinstalls of software (ugh).

    The problem is, in my opinion, that the code hangs because the process is NOT in the background. Perhaps if an “&” were inserted (on the same line) after the python call, it MIGHT work. I actually thought about it while reading his mod to the ‘rc.local’ script, but then forgot to enter that into the script. I’m not willing to reinstall again/again just to continue trying this flaky code.

    I note that several others pointed out this problem on Andrew’s instructable page, with exactly NO HELPFUL RESPONSES from anyone. One person had the wrong connections; but all the others received no informative response at all. Just the standard ‘post the message’, which they already had done:

    The code crashes the Pi (in the boot process) just after it prints out the IP address. (This is the last line in the ‘rc.local’ script PRIOR to the python call.)

    I know the code was entered correctly, because running it from a normal terminal (and yes, it hangs, for the same reason), but then making the programmed contacts on the GPIO does initiate the script and performs the shutdown perfectly.

    I think it’s obvious why, as explained above. For obvious reasons, I (and many others) am/are not willing to ‘join’ this ‘instructables’ operation, just to post comments on the frequently nonworking projects which are accepted there with apparently little quality control or review.

Log in to comment on this story!