I do not know what version of the firmware you are using, but for any current version on the RPi 3B, or RPi 4B this two-step procedure by @MatthijsKooijman still works. It may also work on other versions, but I've not tested it.
In other words: It seems that you have made an error somewhere, or your configuration has been altered. Follow the detailed procedure below, incl. the verification. If it doesn't work, please post the following information:
- list all active lines in your
/boot/config.txt
- Pi 4 only: run
rpi-eeprom-config
& post the results
Step 1: add one line to /boot/config.txt
:
dtoverlay=gpio-shutdown,gpio_pin=3
Note that gpio_pin 3
is physical pin 5
- the SCL
line for the default I2C bus - I2C1. If you're using I2C (if it's enabled), that is OK - you only need to avoid I2C1 in your configuration. For example, I use I2C for my Real Time Clock (RTC), which by default uses I2C1. Consequently, I moved the RTC to I2C0 before verifying this answer.
Step 2: Connect a momentary pushbutton switch between physical pin 5
and GND
on the RPi:
Shutdown the RPi, and remove power (pull the plug) before making the wiring connections shown below. Two wires and a momentary PB switch are all that's required.
simulate this circuit – Schematic created using CircuitLab
Verify:
Re-apply power to the RPi, and verify that it starts and responds normally (as it did before making the changes in Steps 1 & 2). Login to the RPi via SSH.
If you have a USB power meter, note the voltage and current to the RPi while running. On my RPi 4B system: 4.99V ≤ V ≤ 5.02V & 400mA ≤ I ≤ 470mA
Press and release SW1
- the momentary pushbutton:
The RPi should have shutdown "safely". Note the voltage and current to the RPi afterwards. On my RPi 4B system: Vin = 5.06V & Iin = 270mA. Verify that the SSH session you started has closed with a message similar to: Connection to raspberrypi4b.local closed by remote host
.
Press and release SW1
again:
The RPi should re-start. Verify this by initiating another SSH session to the RPi and/or by observing the voltage & current input resume normal/running levels.
Beware of conflicts:
The RPi 4 has a "low-power mode" configuration that may be set in the EEPROM bootloader configuration using parameters WAKE_ON_GPIO=0
& POWER_OFF_ON_HALT=1
. When this configuration is set, and with the RPi 4 running, a press & release of SW1 will shutdown the system, placing it in "low power mode". However, the RPi 4 can only be re-started by cycling power or toggling the GLOBAL-EN
node; i.e. connect GLOBAL_EN
to ground & then release. This behavior verified on the following RPi 4B firmware image: Thu 29 Apr 16:11:25 UTC 2021 (1619712685)
Future-Proof this answer:
The configuration parameters for RPi are in flux, and it is a given that they will remain in flux. While this answer was valid when submitted, conditions will change at some point. Please consult /boot/overlays/README
on your system to verify the instructions remain essentially unchanged from this baseline version
dtoverlay=gpio-shutdown
should behave the same.