Raspberry Pi shutdown button Rev.b



After finally getting round to making a shut down button I thought I would see if I could do one better and improve on my current design. I have been trying to move into using more and more SMD parts in my projects. The good thing about SMD parts is that it saves space on your board but they are trickier to solder but not impossible.



Old (left) vs new (right)



One thing I learn from my last shut down button was that the raspberry pi has internal pull up resistors so I didn’t need a 10k and a 1k pull up resistor on this design. This would save me a lot of space and pins on the new revision.

  • 2 pin button
  • Red LED 1206 SMD
  • 220 ohm 1206 SMD resistor
  • 2 x 2 female header

The reason I have decided to use these pins is that it doesn’t block any important pins you might be wanting to use during prototype of your project. All the other shut down buttons cover over the pins at the top of the header which include the SPI pins and most of the power pins. I have to admit mine doesn’t seam to be a bit more difficult to place in the correct place but I think that its a small price to pay for not having the important pins covered.

When I first designed this board it was just 2 pin headers wide and a little longer, When I sent it off to oshpark.com to get spun they wouldn’t accept the board because it was too small. That is the reason it a little wider at the top and curves back to just 2 pin headers wide. That way it would be wide enough for oshpark but still only take up 2 pin heads on the GPIO.



If you are running raspbian wheezy follow these steps below

First download the files needed from my Github

1. Place pishutdown.py in ‘/home/pi/shutdown/’

2. Edit ‘/etc/rc.local’ as root aka ‘sudo vi /etc/rc.local’

3. Add ‘sudo python /home/pi/shutdown/pishutdown.py’ before the ‘exit 0’ line

4. Save file and reboot pi


#import the modules to send commands to the system and access GPIO pins
from subprocess import call
import RPi.GPIO as GPIO
import os</pre>
# Define a function to keep script running
def loop():

# Define a function to run when an interrupt is called
def shutdown(pin):
    GPIO.setup(16, GPIO.OUT) # Set up pin 16 as an output
    GPIO.output(16, True) # Turn on pin 16 (LED)
    os.system("sudo shutdown -h now") # Shutdown command

GPIO.setmode(GPIO.BOARD) # Set pin numbering to board numbering
#gpio.setup(15, gpio.IN) # Set up pin 15 as an input
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(15, GPIO.RISING, callback=shutdown, bouncetime=200) #Set up an interrupt to look for button presses

loop() # Run the loop function to keep script running


ExecStart=/usr/bin/python /home/pi/pullup_shutdown_jessie_pi/pishutdown.py


If you are running raspbian jessie follow these steps below

First download the files needed from my Github

1. Move pullup_shutdown_jessie_pi folder to the your home directory

2. Move pishutdown.service to /etc/systemd/system/

3. Enable service ‘sudo systemctl enable pishutdown.service’

4. Run service at boot ‘sudo systemctl start pishutdown.service’


# shutdown/reboot(/power on) Raspberry Pi with pushbutton
# Button connected to pin 15
# LED connected to pin 16

import RPi.GPIO as GPIO
from subprocess import call
import time

#shutdownPin = 15 

#GPIO.setup(shutdownPin, GPIO.IN)
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(16, GPIO.OUT) # Set up pin 16 as an output

def buttonStateChanged(pin):

    if not (GPIO.input(pin)):
        #print"button press"
        GPIO.output(16, True) # Turn on pin 16 (LED)
        call(['shutdown', '-h', 'now'], shell=False)

GPIO.add_event_detect(15, GPIO.BOTH, callback=buttonStateChanged)

while True:
    # sleep to reduce unnecessary CPU usage


Gruber files – Here

Python scrips – Here

Oshpark – Here





7 responses to “Raspberry Pi shutdown button Rev.b

  1. Can you edit gerber files in Eagle? KiCAD? I haven’t started in on any board or schematic programs yet. Not sure where to begin.

      • Thanks a lot for posting an editable version on gitHub!

        I’ve got a KiCAD course on Udemy by Peter Dalmaris. I’ll run through that and come back if I need to bug you about anything.

        I’ve got something a little crazy I want to prototype using your design as a starting point. Essentially, I want to mount a board flat against the back of the Pi, and connect to the run pins as well. Two push buttons.

        That allows you to initiate the shutdown as well as reboot the device without unplugging or re-plugging anything.

        Maybe using pin 36, 37, and 39? Maybe drop the LED and just use 36 and 37 for the buttons? (The Pi LEDs should begin to indicate shutting down is occurring.)

        I tested and your Rev.A board can fit on the underside of the pin headers, there’s just one side that’s too fat to fit in between that would need to be shaved as thin as the other.

      • Once you learn KiCAD that sky’s the limit plus it makes your projects look a lot more professional.

        That sounds like a cool project and it would work too. I think all the parts would have to be SMD so it would sit flush. Have you got a raspi 2?

        Have you got a blog yourself?

      • Yea, I just reactivated it. It’s fairly old and I haven’t started blogging about electronics yet. Will now though!


        I have a rpi3. I’ll use SMD buttons. It’ll still stick up a bit, but the thing doesn’t have to be flush anyway, it’s always just bobbing around wherever anyway.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s