Skip to content

Shutdown Raspberry Pi if a defined pin is pulled down. Minimal overhead.

License

Notifications You must be signed in to change notification settings

Sod-Almighty/pi-shutdown

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-shutdown

Shutdown Raspberry Pi if a defined pin is pulled down. This can for example be used to shutdown a headless Raspberry Pi (including Raspberry Pi zero) gracefully (without risking to damage the file system on the sd card).

The background program, which monitors the pin, is automatically started during bootup of the system. It is written in C and very small to minimize the overhead. It polls the pin once per second.

To install:

You must have admin rights, such as "pi" in Raspbian!

  • Download the repository to your pi-top:
  cd Downloads
  git clone git://github.com/rricharz/pi-shutdown
  sudo apt-get install wiringpi
  cd pi-shutdown
  chmod +x install
  sudo ./install
  • Reboot your pi

The default pin is pin 40 of the gpio connector. This makes it easy to connect pin 40 to pin 39 (ground) to force a shutdown. If the two pins are connected, for example with a push button, "sudo shutdown -h now" is executed.

You can change the pin number in "pi-shutdown.c", line 11, constant PIN. But be aware that wiringPi pin numbers need to be defined there, see http://wiringpi.com/pins or type:

  gpio readall

If you are using the desktop on a rpi 2, 3 or zero, you can install the following gpio display, which will also give you the current actual logic state of each pin as well as the gpio and wiringPi pin numbers https://github.com/rricharz/pi-gpio-display

Afterwards, recompile the program and install it again

  make
  sudo ./install

About

Shutdown Raspberry Pi if a defined pin is pulled down. Minimal overhead.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.9%
  • Makefile 13.1%