i have a raspberry pi that i want to be able to reboot cleanly without ssh-ing into it
we're going to use a GPIO pin with a button wired up like this
|picture from adafruit's website|
and i'll be using gpi 23 .. that's pin 16 (nr 8 on the same line as pin 6)
My buton is actually a different setup from the on in this picture (mine breaks contacet when pressed
next we make a script
$ sudo nano /etc/softresetbutton.py
from time import sleep
import RPi.GPIO as GPIO
if ( GPIO.input(23)== True ):
# tue or false here depends on your button type
# when in doubt replace 'reboot &' in the following line with 'echo "pushed" &'
next we make this script executable
$sudo chmod +x /etc/softresetbutton.py
and test-run it
push the button to test it
works ok ??
now we need to make it run at startup
$sudo nano /etc/rc.local
and add the line
just above the " exit 0 "
reboot and you'll have a soft-rest button
if you would prefer a "clean halt" button .. replace the reboot command in the script with halt