Raspberry Pi On/Off Switch With Status Light

Introduction: Raspberry Pi On/Off Switch With Status Light

This project will make a button switch that will both boot up and shutdown a Raspberry Pi and will light an LED while the RPi is operational. Great for headless setups. I created it to augment a Raspberry Pi Baby monitor, because of the concern with using a camera in a shared room.

My example is on a Raspberry Pi Zero, but it will work on any Raspberry Pi.

I used the MakerSpot Prototyping Hat to install it on.

Step 1: Solder Board

The button switch is just Pin 5(GPIO3) and 6(GND) connected together. I added a .01uf capacitor because it would signal the GPIO without hitting the button especially when I discharged static electricity nearby. Works reliably with the capacitor.

The LED is hooked to ground with a 330 Ohm resistor and is powered by the TXD (Pin 8). It needs serial console enabled to Light up. My circuit board pictured is a little different from this guide because I was in the process of adding some IR LEDs to my project.

Step 2: Raspbian 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/FZE/8MLV/JF343EG3/FZE8MLVJF343EG3.py

Make off.py executable

pi@raspberrypi ~ $ chmod +x off.py

Setup startup service

pi@raspberrypi ~ $ 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

pi@raspberrypi ~ $ sudo systemctl enable off.service

pi@raspberrypi ~ $ sudo systemctl start off.service

It also needs serial turned on

pi@raspberrypi ~ $ sudo raspi-config

Step 3: Finished Project

I added this to a RPi Baby Monitor

Share

    Recommendations

    • Water Contest

      Water Contest
    • Fix It! Contest

      Fix It! Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    Discussions

    Private message me if you need tech support on this project