# dtoverlay=gpio-shutdown,gpio\_pin=3,active\_low=1,gpio\_pull=up

**URL:** https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274
**Category:** Troubleshooting
**Created:** [17 June 2019 23:06 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274 "2019-06-17T23:06:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![gerrond](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/b487fb/32.png) [@gerrond](https://dietpi.com/forum/u/gerrond)
#### Post date: [17 June 2019 23:06 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/1 "2019-06-17T23:06:37Z")

</div>

Hi

Adding this line to Dietpi/config.txt does not produce the desired shut-down. The same pi3B+ using Raspbian works.

Entering dtoverlay=gpio-shutdown,gpio\_pin=3,active\_low=1,gpio\_pull=up on the CLI produces no errors. lsmod says gpio-keys is loaded (but not used).

How to proceed?

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [20 June 2019 19:22 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/2 "2019-06-20T19:22:59Z")

</div>

gerrond  
AFAIK the syntax to load the overlay from console should be:  
dtoverlay gpio-shutdown gpio\_pin=3,active\_low=1,gpio\_pull=up  
dtoverlay -l then has “gpio-shutdown” in the list?

Ah:

```nohighlight
2019-06-20 21:15:59 root@micha:/tmp# dtoverlay -h gpio-shutdown
Name: gpio-shutdown

Info: Initiates a shutdown when GPIO pin changes. The given GPIO pin
        is configured as an input key that generates KEY_POWER events.
        This event is handled by systemd-logind by initiating a
        shutdown. Systemd versions older than 225 need an udev rule
        enable listening to the input device:

```

Please try:

```nohighlight
systemctl unmask systemd-logind
systemctl start systemd-logind

```

---

<div class="post-metadata">

### Author: ![gerrond](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/b487fb/32.png) [@gerrond](https://dietpi.com/forum/u/gerrond)
#### Post date: [24 June 2019 11:44 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/3 "2019-06-24T11:44:19Z")

</div>

─────────────────────────────────────────────────────  
DietPi v6.24.1 : 12:39 - Mon 24/06/19  
─────────────────────────────────────────────────────

- Device model : RPi 3 Model B+ (armv7l)
- CPU temp : 53’C : 127’F (Running warm, but safe)
- FQDN/hostname : alarmPi2
- LAN IP : 192.168.1.73 (eth0)
- MOTD : You can select the content of this banner by running: dietpi-banner  
─────────────────────────────────────────────────────

DietPi Team : MichaIng (lead), Daniel Knight (founder)  
Image : DietPi Core Team (pre-image: Raspbian Lite)  
Web : [https://DietPi.com](https://DietPi.com) | [https://twitter.com/dietpi\_](https://twitter.com/dietpi_)  
Patreon Legends : PINE64 community  
Donate : [https://DietPi.com/#donate](https://DietPi.com/#donate)  
DietPi Hosting : Powered by [https://MyVirtualServer.com](https://MyVirtualServer.com)

root@alarmPi2:~# dtoverlay gpio-shutdown gpio\_pin=3,active\_low=1,gpio\_pull=up  
DTOVERLAY[error]: invalid override value ‘3,active\_low=1,gpio\_pull=up’ - ignored

- Failed to set gpio\_pin=3,active\_low=1,gpio\_pull=up  
root@alarmPi2:~# dtoverlay=gpio-shutdown gpio\_pin=3,active\_low=1,gpio\_pull=up  
root@alarmPi2:~# dtoverlay -l  
No overlays loaded  
root@alarmPi2:~# systemctl --version  
systemd 232  
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN  
root@alarmPi2:~# systemctl unmask systemd-logind  
root@alarmPi2:~# systemctl start systemd-logind  
Failed to start systemd-logind.service: Unit dbus.socket not found.  
root@alarmPi2:~#

---

<div class="post-metadata">

### Author: ![gerrond](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/g/b487fb/32.png) [@gerrond](https://dietpi.com/forum/u/gerrond)
#### Post date: [24 June 2019 12:15 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/4 "2019-06-24T12:15:44Z")

</div>

I have just noticed that “shutdown now” -

stops the green LED and leaves the red LED on as expected but the USB current goes up from 0A68 to 0A82 - this is not what I expected! Raspbian April 2019 current goes down to 0A21. I don’t know whether it is inherrent in my dietPi or is due to the result of the dtoverlay thing.

Downloaded , uncompressed and uploaded today’s 7z to card.

Accepted minimal image.

After updates, entered “shutdown now”, current now falls to 0A19.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [30 June 2019 13:09 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/5 "2019-06-30T13:09:54Z")

</div>

```nohighlight
root@alarmPi2:~# dtoverlay gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
DTOVERLAY[error]: invalid override value '3,active_low=1,gpio_pull=up' - ignored
* Failed to set gpio_pin=3,active_low=1,gpio_pull=up
root@alarmPi2:~# dtoverlay=gpio-shutdown gpio_pin=3,active_low=1,gpio_pull=up
root@alarmPi2:~# dtoverlay -l
No overlays loaded

```

dtoverlay=gpio-shutdown… from command line btw cannot work. It’s shell syntax to create a variable but not run any command.  
Just to check: echo $dtoverlay

It looks like all parameters need to be separated by spaces (separate arguments):

```nohighlight
dtoverlay gpio-shutdown gpio_pin=3 active_low=1 gpio_pull=up
dtoverlay -l

```

The usage info is indeed misleading.  
dtoverlay -h gpio-shutdown shows dtoverlay=gpio-shutdown,=, but this is only the syntax for config.txt, not the command line. This is shown by the general dtoverlay usage info:  
dtoverlay [=…]  
But there again one cannot derive how to add multiple parameters. However space separated makes sense as these are then added as individual arguments to the command.

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [17 August 2019 19:11 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/6 "2019-08-17T19:11:00Z")

</div>

I have the same problem with a Pi Zero W running v6.25.3. I have the shutdown button working on a Pi3+ running Debian.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [17 August 2019 19:46 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/7 "2019-08-17T19:46:25Z")

</div>

systemd-logind is unmasked? systemctl unmask systemd-logind && systemctl start systemd-logind

And nothing else blocks/uses the GPIO pins, e.g. I2C, SPI or UART (serial device/console)?  
ls -Al /dev gives an overview of enabled devices, ttyS0, ttyAMA0, i2c\*, and spi\* are examples that use GPIO pins.

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [17 August 2019 20:03 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/8 "2019-08-17T20:03:04Z")

</div>

I ran those two commands didn’t change anything.

Running ls -Al /dev returned this line amongst others

lrwxrwxrwx 1 root root 7 Aug 17 19:51 serial1 → ttyAMA0

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [17 August 2019 21:02 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/9 "2019-08-17T21:02:06Z")

</div>

johncolman  
Try to disable this serial device, as long as you don’t use any serial/UART login terminal:  
/DietPi/dietpi/func/dietpi-set\_hardware serialconsole disable

Although I am not 100% sure if this disables /dev/ttyAMA0. It disables any boot messages and login console attached to this device, but via usual methods one can only disable /dev/ttyS0 completely on RPi models with WiFi+Bluetooth. /dev/ttyAMA0 shows up when Bluetooth is disabled, since otherwise Bluetooth uses/block this. /dev/ttyAMA0 uses GPIO 14 & 15 (so pins 8 & 10) AFAIK, so these cannot not be used for the shutdown button.

Aside the hardware side, you assured the user that executes the script has sufficient permissions (e.g. part of “gpio” group)? dtoverlay declaration in /DietPi/config.txt (and /boot/config.txt on Raspbian) is exactly the same?  
lsmod lists gpio\_keys?

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [17 August 2019 21:22 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/10 "2019-08-17T21:22:20Z")

</div>

I ran  
/DietPi/dietpi/func/dietpi-set\_hardware serialconsole disable  
No change.

I don’t have a script running , just the dtoverlay line added to the DietPi.txt, so haven’t changed any permissions.  
I have checked both txt files are the same.  
lsmod lists gpio\_keys just returns Usage: lsmod

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [19 August 2019 12:38 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/11 "2019-08-19T12:38:05Z")

</div>

@MichaIng

Also if I run dtoverlay -l I get No overlays loaded

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [19 August 2019 15:32 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/12 "2019-08-19T15:32:45Z")

</div>

johncolman  
lsmod is the command you should use and the output should contain gpio\_keys.

dtoverlay -l only shows the overlays loaded at runtime, thus not the ones added to config.txt.

Note as mentioned above that the syntax for loading overlays at runtime is slightly different, e.g.:  
dtoverlay gpio-shutdown gpio\_pin=3 active\_low=1 gpio\_pull=up  
Not sure currently if this fails, when loaded via config.txt already, but AFAIK it works. Then you can check via dtoverlay -l if it has been successfully loaded, respectively otherwise the first will throw an error message already.

If overlay and module is loaded and systemd-logind running (systemctl status systemd-logind) and the shutdown button does still not work, then we have to check if the pins are responding as expected. I don’t have the commands here, but it is possible to send input to the keys from command lines as well, as well as checking the current state of the physical pins.

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [19 August 2019 16:23 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/13 "2019-08-19T16:23:28Z")

</div>

Ok typed the wrong thing for lsmod, this is the reply from lsmod  
gpio\_keys 9575 0

When I run the overlay from the command line with spaces I get

- Failed to apply overlay ‘0\_gpio-shutdown’ (kernel)

This is what I get when I run systemctl  
root@DietPi:~# systemctl unmask systemd-logind  
root@DietPi:~# systemctl status systemd-logind  
● systemd-logind.service - Login Service  
Loaded: loaded (/lib/systemd/system/systemd-logind.service; static; vendor preset: enabled)  
Active: inactive (dead)  
Condition: start **condition failed** at Sat 2019-08-17 22:06:53 BST; 1 day 19h ago  
Docs: man:systemd-logind.service(8)  
man:logind.conf(5)  
[http://www.freedesktop.org/wiki/Software/systemd/logind](http://www.freedesktop.org/wiki/Software/systemd/logind)  
[http://www.freedesktop.org/wiki/Software/systemd/multiseat](http://www.freedesktop.org/wiki/Software/systemd/multiseat)

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [19 August 2019 17:01 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/14 "2019-08-19T17:01:27Z")

</div>

johncolman  
Ah that’s it, dbus is missing, didn’t think about that:  
G\_AGI dbus  
systemctl restart systemd-logind

Actually libpam-systemd might be required as well: G\_AGI libpam-systemd

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [19 August 2019 17:32 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/15 "2019-08-19T17:32:28Z")

</div>

Bingo

It shuts down and a second click of the button it restarts. Tried it a few times and works ok. I will try adding the super capacitor UPS on pin 18 next.

Thanks very much.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [19 August 2019 17:36 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/16 "2019-08-19T17:36:31Z")

</div>

johncolman  
Great, probably some info we should add somewhere, at least to dietpi.txt where you can set systemd-logind to be enabled prior to first boot.

Was dbus sufficient or libpam-systemd required as well?

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [19 August 2019 17:39 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/17 "2019-08-19T17:39:55Z")

</div>

Sorry I ran both first time before trying.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [19 August 2019 17:54 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/18 "2019-08-19T17:54:25Z")

</div>

Okay, could be tested, but actually the docs state that libpam-systemd is required for logind functionality in general: [https://packages.debian.org/stretch/libpam-systemd](https://packages.debian.org/stretch/libpam-systemd)  
The only other thing that systemd-logind does, AFAIK, is automatically spawning gettys on demand, but not tracking/handling any session tasks.

---

<div class="post-metadata">

### Author: ![Deleted\_User\_5820](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Deleted\_User\_5820](https://dietpi.com/forum/u/Deleted_User_5820)
#### Post date: [7 September 2019 14:26 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/19 "2019-09-07T14:26:02Z")

</div>

I just done another install and I didn’t need to run G\_AGI libpam-systemd for it to work.

---

<div class="post-metadata">

### Author: ![AnBad](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/a/3e96dc/32.png) [@AnBad](https://dietpi.com/forum/u/AnBad)
#### Post date: [6 March 2021 16:15 UTC](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274/20 "2021-03-06T16:15:23Z")

</div>

For what ever reason I had to unmask the systemd-logind.

Install:  
G\_AGI dbus  
G\_AGI libpam-systemd

sudo systemctl unmask systemd-logind

Bootconfig change:  
sudo nano /boot/config.txt  
dtoverlay=gpio-shutdown,gpio\_pin=3  
reboot

I am looking for a way to change the power up from Pin 3 to Pin 21, cause Pin 3 is already in use.

[Next page](https://dietpi.com/forum/t/dtoverlay-gpio-shutdown-gpio-pin-3-active-low-1-gpio-pull-up/3274.md?page=2)
