We are trying to have the Pi shut down gracefully when power is removed. We have a battery connected so that it will have time to shut down. So far, our attempts to use gpio-shutdown have been unsuccessful. We're running Raspbian Stretch.

In /boot/config.txt we have the following line:


systemd --version reports systemd 232

When we connect pin 22 to 5V (for now we're manually shorting it with a wire), the Pi doesn't react.

The instructions on GitHub say

The Advanced Options section of the raspi-config utility can enable and disable Device Tree use, as well as toggling the I2C and SPI interfaces.

There are seven options under Advanced Options but none of them have to do with Device Tree, I2C, or SPI so I'm not sure Device Tree is enabled.

Is there something else we need to do to get gpio-shutdown to work?

2 Answers 2


I use dtoverlay=gpio-shutdown,gpio_pin=21 and when BCM 21 (pin 40) is connected to Gnd the Pi shuts down.

What pin are you actually using?

If you ACTUALLY "connect pin 22 to 5V" you have probably destroyed the GPIO (if not the Pi). GPIO are 3.3V devices.

NOTE there is no option in Stretch to NOT use Device Tree, although you can modify its behaviour.

  • The pin we’re actually using is the one labeled “22” on this page. To test the possibility that we fried the GPIO I tried again with a new Pi 3B fresh out of the box and made sure to connect it only to 3.3V, not 5V. We still get nothing. I tried changing to dtoverlay=gpio-shutdown,gpio_pin=21 and connecting BCM 21 to Gnd and still got no response. I wonder what’s different about our machine that makes it not work.
    – SSteve
    Commented Nov 7, 2018 at 15:44

Using a fresh install of Raspbian Stretch fixed the problem, whatever it was. We did very little with the previous install so there's no obvious cause.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.