[How-to] Add a Power button on CrowPi
The Raspberry Pi does not have a Power button, which can be used to gracefully shutdown or power-up a Raspberry Pi. But it would be relatively easy to add one.
Setup steps:
1) Wire a momentary switch (Push button) between the GPIO3 (Board pin 5) and GND (Board pin 6).
2) Copy the following statements to the end of the /boot/config.txt
file.
# Shutdown button dtoverlay=gpio-shutdown
3) Reboot.
Note 1: The dtoverlay gpio-shutdown monitors GPIO3 (defaults) as the system shutdown signal. If you like to use a different GPIO pin (e.g. GPIO21 (Board pin 40)), then add the optional “gpio_pin=<pin>” parameter to the statements as shown below,
# Shutdown button dtoverlay=gpio-shutdown,gpio_pin=21
Note 2: If you have other I2C devices connected to the GPIO3 (Board pin 5), then a different GPIO pin should be specified for the dtoverlay gpio-shutdown to prevent interference.
Note 3: Additional overlays and parameters are documented in the /boot/overlays/README file.
.
Operations:
- To shutdown
Press the Power button to initiate a clean shutdown procedure, after which the Raspberry Pi will go into the halt state (The Green LED on the Pi stopped flashing). Now it's safe to turn off the power.
- Waking up from the halt state
While the pi is in the halt state, pressing the Power button will restart the pi.
Note: Wakes up from the halt state only works with a ‘low’ signal on GPIO3, if the Power button is wired to a different GPIO pin, then you must reset the power in order to restart the Pi.
.
CrowPi:
The CrowPi also was not designed with a Power button, and the GPIO pins are not easily accessible once the ‘Rainbow’ cable is connected. It would make wiring a new Push button difficult. Fortunately, there are other project buttons available on the CrowPi board that can be repurposed as the Power button. So, choose your desired button and substitute the ‘gpio_pin=’ parameter with its corresponding GPIO pin number as shown in the table below.
======================================================
| INDEPENDENT BUTTON.....| UP ....... | GPIO26 (Board pin 37) ... |
| ...............................................| DOWN .| GPIO13 (Board pin 33) ... |
| ...............................................| RIGHT ..| GPIO19 (Board pin 35) ... |
| ...............................................| LEFT .....| GPIO25 (Board pin 22) ... |
======================================================