Pi Shutdown Module

by SethB62 in Circuits > Raspberry Pi

2868 Views, 22 Favorites, 0 Comments

Pi Shutdown Module

PiPowerCloseup.jpg

This module gives you a great way to properly shutdown a Raspberry Pi. Then it can be powered off with a button on the power adapter or unplugged. The light will turn off when it is safe to power off. If you decide to boot up after it has shutdown (while it still has power), hitting the button again will boot it up.

The PCB is inexpensive from OSH Park. Minimum order is 3, so share with a friend or put it on 3 Raspberry Pi's

I created this so my kids will properly shut down the RetroPie after playing.

Parts

Parts.jpg

3 Boards from OSH Park $6.10 and free shipping

1x LED

1x .01uf Capacitor (100nf and 104 = .01uf)

1 330 Ohm Resistor

1x 1M Ohm Resistor

2x - Header 10 pin 2x5 (use 1x and electrical tape if the Pi has a heatsink)

1x Button Switch 6x6x9.6 the last number is the height of the button. A different height can be substituted.

Build

Heatsink.jpg

The "UNPLUGGED" part of the PCB is designed to give lateral support to the board and to channel electrostatic discharge to the 1M resistor. After soldering, clip component leads on the underside to make sure if doesn't short out on the Pi.

If you have a heatsink on your Pi, don't solder in the "UNPLUGGED" connector and put electrical tape of the backside of the PCB.

OS Configuration

It needs a service to shut it down when you press the button.
Download python script

wget -O off.py https://cdn.instructables.com/ORIG/FSJ/0G5H/JM6KYZ7W/FSJ0G5HJM6KYZ7W.py
chmod +x off.py

Setup startup service

sudo nano /lib/systemd/system/off.service
[Unit]
Description=Off Program
[Service]
ExecStart=/home/pi/off.py StandardOutput=null
[Install]
WantedBy=multi-user.target Alias=off.service

Save, then active the service


sudo systemctl enable off.service

sudo systemctl start off.service

It uses serial pin to light the LED while its running. So it needs serial console turned on in Raspberry Config.

sudo raspi-config

Downloads