Where is the correct place for the Zero 2W to put in the gpio-poweroff dtoverlay load command?

I’m trying to get my Pi Zero 2W to raise a GPIO pin when powering down.
Nothing appears to be happening - the unit stays externally powered, suggesting my hardware does not detect the raised pin but in this case I would expect after 3s to see a kernal panic raised on the Pi.

I’m assuming that the correct file is /boot/config.txt (a symlink to /boot/firmware/config.txt) and have put the command (“dtoverlay=gpio-poweroff,gpiopin=4”) there.

One other possible cause of issues - my application on the Pi uses diozero java library (https://www.diozero.com/) to handle I2C messages.

Any help appreciated?

What command do you use to power down the device? reboot or halt will not assert the pin.

Just to be sure, did you connect the right pin? GPIO 4 is physical pin 7 (https://pinout.xyz/)

And did you activate i2c within dietpi-config?

AI also suggested :sweat_smile:
If the Java library exports GPIO 4 then gpio-poweroff can not take control over this pin. The overlay only works if the pin is unused.

I’ve tried “sudo shutdown now” and “poweroff”.

i2c is activated.

i have unmasked systemd-logind.

I don’t access the gpio pins via diozero, just i2c.

the pin assignment is correct - hardware engineer chose and built it.

it’s odd.

I have also installed device-tree-compiler to use dtc to check the device tree which does contain gpio-poweroff.

another weird thing - “dtoverlay -l” gives unknown command error in bash as if not dtoverlay not installed.

Yes this is expected, DietPi does not preinstall the RPi helper scripts. You can install it if you like or check with

ls /proc/device-tree/overlays/gpio-poweroff

and for I²C devices

ls /dev/i2c-*

BTW shutdown now often resolves to halt, better would be shutdown -h now, but poweroff should also trigger the GPIO.

Do you have maybe other overlays active which could touch that pin?
The connected hardware expects high state when the device is powered down?

And do you have maybe an LED or something else you could test on another pin, like GPIO pin 17? Or maybe try even whatever you have connected on GPIO pin 4 on another pin, to rule out it’s a problem with GPIO pin 4.

Otherwise I’m out of ideas.

OK, we can stand down , many thanks for your help.

The hardware for power off required an i2c message before power off to monitor for the pin.

My error - I KNEW it wasn’t that difficult.

1 Like