Skip to content

Support us

Authors: fire1ce | Created: 2022-04-24 | Last update: 2022-04-24

External Power Button For Raspberry Pi

Python script to control Raspberry Pi with external power button - Wake/Power Off/Restart(Double Press)

Official Github Repo

Raspberry Pi Power Button - Wake/Power Off/Restart(Double Press)

Information

When Raspberry Pi is powered off, shortening GPIO3 (Pin 5) to ground will wake the Raspberry Pi.

This script uses pin GPIO3(5), Ground(6) with momentary button.

gpio layout

raspberrypi-with-button

Requirements

  • python3-gpiozero

Can be install via apt

sudo apt install python3-gpiozero

Install

This will install the script as service and it will run at boot

curl https://raw.githubusercontent.com/fire1ce/raspberry-pi-power-button/main/install.sh | bash

Uninstall

curl https://raw.githubusercontent.com/fire1ce/raspberry-pi-power-button/main/uninstall.sh | bash

Default Behavior

Button Press (Raspberry Pi is ON) Behavior
Single Nothing
Double Reboot
Long press and releases (above 3 seconds) Power off
Button Press (Raspberry Pi is OFF) Behavior
Single Power On

Check if service is running

sudo systemctl status power_button.service

Comments