kiwijam777
Participant
Post count: 15

It worked for me until it didn’t for one particular switch. After troubleshooting I found out there was an error in the code; it didn’t need the line to go “high” since the 6 pins on that end are always high. Try this one:
Create a file called “/home/pi/scripts/shutdown.sh”
Inside the file, type.

#!/bin/bash
echo “3” > /sys/class/gpio/export
echo “in” > /sys/class/gpio/gpio3/direction
while [ “$(cat /sys/class/gpio/gpio3/value)” != ‘0’ ]
do
sleep 1
done
poweroff &
exit 0

Remember you still have to refer to this file in RC.local

ADD SCRIPT TO LOAD AT STARTUP BY ADDING COMMAND TO /ETC/RC.LOCAL:
sudo nano /etc/rc.local
TYPE THE FOLLOWING IN RC.LOCAL AFTER THE LINE “#By default this script does nothing”:
sudo /home/pi/scripts/shutdown.sh &

If you still can’t get it, I will email you the files.