pi Shutdown Switch

Forums:

Ref: https://www.instructables.com/id/Raspberry-Pi-Zero-Switch-Off-by-Button/

#pidown.py
# pi zero short pin 21 to ground (last two pins on gpio)
import RPi.GPIO as GPIO
import time import os
buttonPin = 21
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
last_state = True
input_state = True
while True:
input_state = GPIO.input(buttonPin)
if (not input_state): print("Shutdown")
os.system('sudo shutdown -h now')
time.sleep(0.05)
GPIO.cleanup()

Create the python file in /usr/bin
sudo nano /usr/bin/pistop.py
--Paste in python text above

Add to startup so it runs on bootup to monitor the pins
sudo nano /etc/rc.local
# Add prior to exit 0 in rc.local
python /usr/bin/pistop.py

short pins and see if it works.

37.8269817,-122.4251495,05-20-2019 02:26:19 AM,!Slightly Lost!