Single Power Button Solution where I2C/GPIO3 is in use

I think I’ve found a way to have a single pushbutton control both power up and power down for the RPi for systems that use I2C and thus cannot use GPIO3 for power down.

Here is how I have this configured on my system (HiFiBerry DAC+, 7" RPi Official display, no encoders) Currently using GPIO24 for activity LED, and GPIO25 as the power down switch.

|----------- [GPIO3/SCL]
|----------- [GPIO25]
|------------ [Pushbutton] -------[GND]

In /boot/config.txt

#Setup act light, and dedicated power button

The actual gpio_pin used by gpio-shutdown is not critical, just pick a free pin.
The real trick here, is to configure the shutdown pin as “gpio_pull=off” which disables the internal pull-up. Now, short GPIO25, and GPIO3 (Which has an external pull-up, and is shared with I2C SCL line)

When the system is running, GPIO25 is an input, and does not effect the I2C SCL. Pressing the Pushbutton shorts GPIO25 to GND and the system shuts down. At this point, GPIO3 is used as the “reset” and pressing the Pushbutton shorts GPIO3 to GND performing a system reset. Since GPIO3 and GPIO25 are shorted together, a single button connected to GND will provide all the switching needed.

I don’t know if this will work with every configuration, at this point I’ve tested it just a little bit, and it seems to work. I suspect that the code for gpio-shutdown is doing some debounce that is preventing the low cycles of SCL Clock from causing a shutdown.

1 Like

Interesting discovery, but it wold take a lot of cross planet soldering to entirely convince some of the hardwares :smiley:

Not 100% sure, but I think this was causing “unexpected power-down” of my system. I was using this as a soft power button before I had encoders wired up on my DIY build so I’ve now abandoned the GPIO power off, but I’ve kept the switch and GPIO3 connection to allow me to soft power on a system.