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.
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
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.
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.