SW_OffButtonRPi - fablab-wue/piTelex GitHub Wiki
OFF-button on Raspberry Pi
If you do not intend to run your piTelex station with a RaspBerry around the clock, it is heavily recommended to use this option, to ensure to not mess up your SD-card, your linux-installation and last but not least your RPi. A power off button allows to shutdown the RPi properly before cutting the power
[!IMPORTANT] For using this functionality it is important to enable the "secure power off" feature of the Raspberry Pi on first startup.
First, navigate to /boot/config.txt
, then insert the code-lines below in section "[all]" right at the bottom of the document:
# Shutdown-button
dtoverlay=gpio-shutdown,gpio_pin=#
Replace '#' with the GPIO number to use, not the pin number. The GPIO pin numbering scheme is not in numerical order; see https://www.raspberrypi.com/documentation/computers/images/GPIO-Pinout-Diagram-2.png
(Contributed by Wolfram Henkel in telexforum.de)
Jochen aka Horatius added the idea for debouncing the push button:
dtoverlay=gpio-shutdown,gpio_pin=<gpio_number>,active_low=1,gpio_pull=up,debounce=<time-in-milliseconds>
To shutdown the RaspberryPi, the button must be pressed and held for the debounce time given in ms (see https://www.telexforum.de/viewtopic.php?t=5190&start=50#p48899).