I have a Pi 3B+ with an adafruit matrix bonnet. Im trying to shutdown the Pi with a single pole double throw switch I had laying around. I'm currently able to get the power on working through GPIO 3. I want to get the shutdown command to work on GPIO 2 if possible by adding dtoverlay=gpio-shutdown,gpio_pin=2 to /boot/config.txt but it doesnt seem to work when I short the gpio pin to the ground. I've also tried it on other gpio 25 with no luck.

This is my first RPi build so I'm wondering if I can only use certain gpio pins for the shutdown command? Since I am using the adafruit Matrix Bonnet to drive an led matrix, I am limited on the number of gpio pins I have available.

I also mentioned how I want to use this on a SPDT switch, will it cause an issue if the gpio pins are continuously held closed once it powers off or on?


1 Answer 1


GPIO2 seems a poor choice as this is normally used for I²C (you haven't mentioned what pins are used, what the unspecified bonnet uses or what OS you use).

I routinely use GPIO21 (pin 40) and it works with Raspberry Pi OS.

You could use a toggle switch, and this is safe (provided the pin is not configured as output) but clumsy - a press button works better.

It is unclear what is connected to GPIO3 or if you are attempting to use the same switch.

It is normal to use GPIO3 for both shutdown and restart.

  • Sorry, per the bonnet, "Unused GPIO pins include: SCL, SDA, RX, TX, #25, MOSI, MISO, SCLK, CE0, CE1, #19". For OS I'm running DietPi. I've already used GPIO 14 & 15 for fan control and an LED indicator. I am trying to use gpio 3 for Power On and a different gpio for power off. I cannot use GPIO 21 as that is used by the bonnet unfortunately.
    – VictorC
    Nov 2, 2023 at 2:24
  • 1
    Do NOT put details in Comments - edit your post. You have not posted any meaningful diagnostics.
    – Milliways
    Nov 2, 2023 at 2:29
  • After your response @Milliways I realized I didnt think about the fact I was using dietpi. After some research I found this post which helped me resolve the issue. Thank you. dietpi.com/forum/t/…
    – VictorC
    Nov 2, 2023 at 2:34

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.