A small python program that shuts down a RaspberryPi after connecting GPIO pin 3 to GND.
Just download or copy the code of this little software: Download
Save it anywhere on your pi.
You only need python and RPi.GPIO.
If you are running Raspbian everything should be installed!
If python is not installed you only need to do this:
sudo apt-get update
sudo apt-get install python
To install RPi.GPIO run following commands:
sudo apt-get update
sudo apt-get install rpi.gpio
If that doesn't work use this. If 0.6.2 is not the latest version copy the download link from here: https://pypi.python.org/pypi/RPi.GPIO
sudo apt-get install python-dev gcc
wget https://pypi.python.org/packages/c1/a8/de92cf6d04376f541ce250de420f4fe7cbb2b32a7128929a600bc89aede5/RPi.GPIO-0.6.2.tar.gz
tar -xvf RPi.GPIO-0.6.1.tar.gz
cd RPi.GPIO-0.6.1
sudo python setup.py install
cd ..
sudo rm -rf RPi.GPIO-0.*
Just navigate with your terminal to your downloaded file and run
python GPIO_Shutdown.py
Replace the GPIO_Shutdown.py with your filename.
You may need to run it as root:
sudo python GPIO_Shutdown.py
Connect pin3 to the GND pin next to it (for example with a paperclip). Then the RaspberryPi starts to shutdown.
If you are not sure about what pin is the right one, just look at the RaspberryPi Website.
Be sure to use the right pin, using the wrong one may cause a damnage of your RaspberryPi!
If you want to use another pin than pin3 just change the 3 after GPIO_Pin in the file It may look like this:
...
GPIO_Pin = 5
GPIO.setmode(GPIO.BCM)
...
To run it automatically after the startup of RaspberryPi, you just have to add following line above exit 0 to /etc/rc.local.
You have to replace path_to_file with your own path to your downloaded file.
python /path_to_file/GPIO_Shutdown.py &
Just remove your downloaded file and the line in /etc/rc.local
If you do not need python anymore use:
sudo apt-get purge python
I hope this helped you a bit.
Have fun with this small software.