BarrowWight
Posts: 8
Joined: Thu Aug 17, 2017 10:22 pm

How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Fri Aug 18, 2017 9:35 pm

I have read from a couple of sources that a power button can be set up for the raspberry pi by placing a button across pins 5 and 6. A script can shut it down, and shorting while it is powered off will turn it on again.

Is it safe to do this for my old B+ that is running a headless system?

User avatar
davidcoton
Posts: 6747
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Fri Aug 18, 2017 9:53 pm

Can you link your sources?
Normally a software routine (which can be triggered by a GPIO) is used to shutdown the Pi, leaving it halted and consuming little (not zero) power.
It is not possible to wake a halted Pi using the GPIO, because nothing is running to monitor the input. The separate RUN header iscan be used to reset the Pi (using it while the Pi is running causes a hard (ungraceful, dangerous) reset).

Edit: Out of date info -- see below.
Last edited by davidcoton on Sat Aug 19, 2017 8:31 am, edited 4 times in total.
Location: 345th cell on the right of the 210th row of L2 cache

RonR
Posts: 2748
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Fri Aug 18, 2017 11:04 pm

I've been using this on an RPi 3 for a couple of months now and it works perfectly.

It's built into the new Stretch release (2017-08-16) and can be enabled by simply adding the following line to /boot/config.txt:

dtoverlay=gpio-shutdown

Nothing else is required except to connect a momentary normally open pushbutton switch between GPIO pins 5 and 6.

BarrowWight
Posts: 8
Joined: Thu Aug 17, 2017 10:22 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Fri Aug 18, 2017 11:45 pm

RonR wrote: I've been using this on an RPi 3 for a couple of months now and it works perfectly.

It's built into the new Stretch release (2017-08-16) and can be enabled by simply adding the following line to /boot/config.txt:

dtoverlay=gpio-shutdown

Nothing else is required except to connect a momentary normally open pushbutton switch between GPIO pins 5 and 6.
So bootup by shorting 5 and 6 is safe? I have a python script to run sudo poweroff, cron makes sure it is running from the start

User avatar
rpdom
Posts: 20008
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Aug 19, 2017 1:01 am

BarrowWight wrote:
Fri Aug 18, 2017 11:45 pm
So bootup by shorting 5 and 6 is safe?
Yes, perfectly safe. It's a feature of the bootloader that has been around for some time. The Pi doesn't fully power off, just shuts down and goes to the very start of the boot sequence. At that point it sits and waits for pin 5 to be connected to a ground pin before continuing with the boot.

lerner
Posts: 645
Joined: Sun Mar 29, 2015 12:12 am

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Aug 19, 2017 2:29 am

So (indulge my dumb question) if I have a RP2 with Jessie, which is also headless:

I put the button between 5 & 6 and press it.

It "shuts down". Would it then be safe to power the Pi down?

The thing is that I want a button to "shut it down - completely. As this goes nearly that far, I'm wondering if I could then turn it off.

Kind of off topic, but maybe not:
Is the shutdown forced or a normal one?

One thing I am also kind of missing is a RESET button.

Code: Select all

sudo reboot -f
(but that's another question - sorry.)

User avatar
rpdom
Posts: 20008
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Aug 19, 2017 3:19 am

lerner wrote:
Sat Aug 19, 2017 2:29 am
Would it then be safe to power the Pi down?
I haven't tested this shutdown method yet, but as long as it invokes a proper shutdown (which I suspect it does), it will be safe to remove power.
One thing I am also kind of missing is a RESET button.
There are two holes on the PCB marked "Reset". Connecting those two together briefly will do a hard reset of the Pi (no clean shutdown).

lerner
Posts: 645
Joined: Sun Mar 29, 2015 12:12 am

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Aug 19, 2017 3:37 am

Thanks.

Silly me, forgot about the reest pins.

RonR
Posts: 2748
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Aug 19, 2017 5:37 am

For Jessie, the attached archive contains the necessary pieces.

Raspberry Pi Pushbutton Shutdown/Startup

The enclosed script will install shutdown and startup capability using a SPST NO momentary pushbutton
switch connected to GPIO header pins 5 and 6. Pressing the button on a running system will initiate
a graceful shutdown (shutdown -h now). Once shut down, pressing the button will restart the system.


1. Copy install and gpio-shutdown.dtbo to the Raspberry Pi.

2. Make the install script executable:

$ chmod +x install

3. Run the install script:

$ sudo ./install

4. Reboot

For additional info, see:

http://www.stderr.nl/Blog/Hardware/Rasp ... utton.html
Attachments
PushButton.zip
(1.99 KiB) Downloaded 385 times

hwdornbush
Posts: 28
Joined: Fri Jan 20, 2017 7:08 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Jul 28, 2018 11:03 pm

Sadly, using pins 5 and 6 worked for me on a RPi Zero W but not on a RPi 3 model B. I tried to follow the information in the firmware documentation on using "dtoverlay=gpio-shutdown,gpio_pin=26" to assign it to another GPIO pin but this also did not work.

The RPi Zero W was running a newly downloaded version of stretch while the RPI 3 B was upgraded. Could this affect this working?

DirkS
Posts: 10737
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Jul 28, 2018 11:51 pm

hwdornbush wrote:
Sat Jul 28, 2018 11:03 pm
The RPi Zero W was running a newly downloaded version of stretch while the RPI 3 B was upgraded. Could this affect this working?
Is I2C activated on the 3B? It uses GPIO3 (physical pin 5) which is the default
hwdornbush wrote: I tried to follow the information in the firmware documentation on using "dtoverlay=gpio-shutdown,gpio_pin=26" to assign it to another GPIO pin but this also did not work.
To clarify: you do know that's GPIO26 (physical pin 37)?

hwdornbush
Posts: 28
Joined: Fri Jan 20, 2017 7:08 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sun Jul 29, 2018 9:15 pm

DirkS wrote:
Sat Jul 28, 2018 11:51 pm
hwdornbush wrote:
Sat Jul 28, 2018 11:03 pm
The RPi Zero W was running a newly downloaded version of stretch while the RPI 3 B was upgraded. Could this affect this working?
Is I2C activated on the 3B? It uses GPIO3 (physical pin 5) which is the default
Yes, it was activated. I de-activated it, and then the switch worked to both stop and start. But what if I wanted to use I2C or pin 5 was covered? Shouldn't I be able to use the alternative? See below.
DirkS wrote:
Sat Jul 28, 2018 11:51 pm
hwdornbush wrote: I tried to follow the information in the firmware documentation on using "dtoverlay=gpio-shutdown,gpio_pin=26" to assign it to another GPIO pin but this also did not work.
To clarify: you do know that's GPIO26 (physical pin 37)?
Yes, I know that GPIO26 is physical pin 37. I would like to use this on a Pi where pins 1-26 are covered by a touch screen interface. I connected the switch between pins 37 and 39 (ground, right?) but this did not shut down the Pi.

hwdornbush
Posts: 28
Joined: Fri Jan 20, 2017 7:08 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sun Jul 29, 2018 9:31 pm

I just solved my problem with using another GPIO pin. The syntax is

dtoverlay=gpio-shutdown,gpio_pin=26

not

dtoverlay=gpio-shutdown,gpio-pin=26

as I discovered in my code. Of, course, using an alternate pin will not provide a boot-up function as will pins 5 and 6.

Son1c
Posts: 14
Joined: Sat Aug 20, 2016 3:42 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Nov 09, 2019 10:41 pm

Why when i'm connecting poweron button to 5 and 6 pins and then touching GND by metallic item my Zero W starts booting? How to fix this?
Already tried to add external 10k pullup resistor and ceramic capacitor, didn't help...
Last edited by Son1c on Mon Nov 11, 2019 5:30 am, edited 1 time in total.

User avatar
bertlea
Posts: 312
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Nov 11, 2019 5:00 am

...This overlay only handles shutdown. After shutdown, the system
can be powered up again by driving GPIO3 low. The default
configuration uses GPIO3 with a pullup, so if you connect a
button between GPIO3 and GND (pin 5 and 6 on the 40-pin header),
you get a shutdown and power-up button.
Source: https://raspmer.blogspot.com/2018/09/sh ... -tree.html

User avatar
Burngate
Posts: 6520
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Nov 11, 2019 11:42 am

Son1c wrote:
Sat Nov 09, 2019 10:41 pm
Why when i'm connecting poweron button to 5 and 6 pins and then touching GND by metallic item my Zero W starts booting? How to fix this?
Already tried to add external 10k pullup resistor and ceramic capacitor, didn't help...
Pin 5 (GPIO 3) already has a 1k8 pull-up resistor on-board.

What do you mean by "touching GND by metallic item"?
Depending on your power supply, GND on the Zero W is probably not connected to earth.
Touching the Zero W's GND with an earthed metal object - a screwdriver, for example - could induce an unknown voltage onto any part of the Pi

Son1c
Posts: 14
Joined: Sat Aug 20, 2016 3:42 pm

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Nov 16, 2019 1:03 pm

Burngate wrote:
Mon Nov 11, 2019 11:42 am
What do you mean by "touching GND by metallic item"?
Touching the Zero W's GND with a screwdriver or a tweezers.
Burngate wrote:
Mon Nov 11, 2019 11:42 am
Depending on your power supply, GND on the Zero W is probably not connected to earth.
Touching the Zero W's GND with an earthed metal object - a screwdriver, for example - could induce an unknown voltage onto any part of the Pi
I already tried to connect Zero W's GND to earth, didn't help.

User avatar
Burngate
Posts: 6520
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Sat Nov 16, 2019 7:09 pm

About all I can think of is similar to
Patient: "Doctor, it hurts when I do this"
Doctor: "then don't do that"
Not much help, I'm afraid, other than it's generally unwise to touch anything that's powered with a metal object.

NeilAlexanderHiggins
Posts: 51
Joined: Sun May 25, 2014 10:22 am

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Dec 16, 2019 12:57 am

Where's the "official" documentation for this?, i.e. on the RaspberryPi.org website, properly documented , etc.? I can see all sorts of informal documentation by the 10 "million experts" out there, but nothing authentic.


alphanumeric
Posts: 3105
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Dec 16, 2019 9:55 am

I have found on my Pi 4B that if i2c is enabled the default dtoverlay=gpio-shutdown stops working. The Pi will not shut down when you ground GPIO 3. It will work if you map it to a different pin though with dtoverlay=gpio-shutdown,gpio_pin=
Just a FYI post.

NeilAlexanderHiggins
Posts: 51
Joined: Sun May 25, 2014 10:22 am

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Dec 16, 2019 10:56 am

deepo wrote:
Mon Dec 16, 2019 9:02 am
Is this what you are looking for?
https://elinux.org/RPI_safe_mode#Wake_from_Halt.5B1.5D

dtoverlay:
https://github.com/raspberrypi/firmware ... ays/README

/Mogens
Maybe github. Maybe not eLinux. I'm not sure how I would assess the bonafides of the posters. Documentation of the Raspberry Pi on the RaspberryPi.org web site would have the most appeal to me. This is one of those issues where everyone has either an issue or an opinion, but nobody seems to know the truth.

User avatar
rpdom
Posts: 20008
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How safe is it to use Pins 5 and 6 as a poweroff/poweron system

Mon Dec 16, 2019 11:13 am

NeilAlexanderHiggins wrote:
Mon Dec 16, 2019 10:56 am
Maybe github. Maybe not eLinux. I'm not sure how I would assess the bonafides of the posters. Documentation of the Raspberry Pi on the RaspberryPi.org web site would have the most appeal to me. This is one of those issues where everyone has either an issue or an opinion, but nobody seems to know the truth.
The github site is the official one. The raspberrypi.org documentation points at it.

I don't understand your negativity about the "experts" on here. Some of them work for Raspberry Pi and were instrumental in setting up those functions.
Unreadable squiggle

Return to “Advanced users”