Gpio-poweroff and gpio-shutdown for Raspberry Pi

To better manage industrial/OEM boards based on Raspberry Pi you could need dedicated GPIO lines to control power lines (e.g. PSU shutdown/enable terminals or START buttons).

In this case you could provide direct GPIO control through Linux sysfs, C, Python or..... use gpio-poweroff and gpio-shutdown functions supplied in latest Raspberry images.

 

For this purpose you can use specific additional hardware to manage PSU or power pushbutton through commercial controllers (such LTC2951, LTC2955 and others) or create your own using microcontroller.

 

Briefly, gpio-poweroff is used as output to enable/disable control terminal of PSU (active high or low as you need), while gpio-shutdown is used as input to detect hardware shutdown request.

Keep in mind gpio-poweroff and gpio-shutdown are not present in all Raspberry images: gpio-shutdown is missing on some old images (gpio-poweroff and gpio-shutdown are both present in 2017-11-29-raspbian-stretch-lite).

 

To enable gpio-poweroff and/or gpio-shutdown you need to act on /boot/config.txt adding code as follows:

 
dtoverlay=gpio-poweroff,gpiopin=21

In the example above GPIO21 (default GPIO pin is GPIO26) is set as poweroff pin (active high): in this case GPIO21 is low at boot, stays low until user poweroff, then it goes to high level.

 

 
dtoverlay=gpio-poweroff,gpiopin=21, active_low="y"

In this example poweroff pin is set active low, so after power up it goes to high value and goes down at poweroff.

 

 

 

 

 

Last update 20 Feb 2018.