emuola
Posts: 24
Joined: Wed Jun 19, 2013 5:50 pm

Power button (halt/wake) without GPIO3?

Wed May 22, 2019 9:04 am

Running 3B+ and rtc module. I want to make a power button, but it seems to be complicated due to the rtc using the GPIO3. The shutdown pin is easy to specify to another unused GPIO pin, but the wake is always the GPIO3, right? I know about the RUN header, but is there any feasible way to have one switch for wake/halt without the possibility to use GPIO3?

User avatar
thagrol
Posts: 1465
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 11:40 am

This is working for me on a Pi 2: one single pole push button wired between the two pins in parallel and ground.

Other options include:
  • A double pole switch. One pole to your shutdown switch, the other to GPI0 3
  • A non locking (momentary) on-off-on toggle switch. Common wire to ground, one side to GPIO 3, the other to your shutdown pin?
  • Use an RTC module that doesn't interface via I2C.
Note to self: don't feed the trolls

If I've asked you a question, please answer it. I'm unlikely to be able to help without that information.

emuola
Posts: 24
Joined: Wed Jun 19, 2013 5:50 pm

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 11:53 am

thagrol wrote:
Wed May 22, 2019 11:40 am
This is working for me on a Pi 2: one single pole push button wired between the two pins in parallel and ground.
Could you please specify "the two pins" you are referring to? :)
A double pole switch. One pole to your shutdown switch, the other to GPI0 3
A non locking (momentary) on-off-on toggle switch. Common wire to ground, one side to GPIO 3, the other to your shutdown pin?
I thought that using the rtc (wich uses i2c) means I cannot use GPIO3 at all?

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

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 12:25 pm

i2c is a shared bus, you can have multiple devices on it. I would think grounding the SCL pin, logic low, to turn the Pi on isn't going to hurt any device connected to it?
Using it for shutdown may be another matter, while still using it for i2c? The ground to initiate the shutdown is likely going to cause an IO error. If your shutting down anyway what does it matter? As far as I know It won't damage anything.
What I wonder is signals from i2c connected devices going to cause the Pi to get confused and shut down?
I think we kind of need somebody from the Pi Foundation that is in the know, to chime in on this.

I'm currently only using GPIO 3 to turn on my Pi. And I don't have any i2c devices connected to those Pi's. They are running motion eye and I haven't bothered trying to add the config.txt edit for the shutdown. I just hut them down via thier web interface.

I have some older Pi A+'s (A+ not a 3A+) running headless that I shut down vis a GPIO pin. Its not GPIO 3 as they have numerous i2c devices connected. Power on is done via the run pin and or a power switch.

klricks
Posts: 6367
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 12:36 pm

emuola wrote:
Wed May 22, 2019 11:53 am
thagrol wrote:
Wed May 22, 2019 11:40 am
This is working for me on a Pi 2: one single pole push button wired between the two pins in parallel and ground.
Could you please specify "the two pins" you are referring to? :)
A double pole switch. One pole to your shutdown switch, the other to GPI0 3
A non locking (momentary) on-off-on toggle switch. Common wire to ground, one side to GPIO 3, the other to your shutdown pin?
I thought that using the rtc (wich uses i2c) means I cannot use GPIO3 at all?
GPIO 3 (pin 5) is always power on regardless and can also be used for I2C or some other purpose after the RPi has booted.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

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

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 12:42 pm

I do believe he is referring to Pins 5 (GPIO 3) and pin 6 Ground. I just plug a two pin pigtail into those two pins and wire a momentary switch to the end.
https://www.adafruit.com/product/1003
https://www.adafruit.com/product/1445

klricks
Posts: 6367
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 12:51 pm

alphanumeric wrote:
Wed May 22, 2019 12:42 pm
I do believe he is referring to Pins 5 (GPIO 3) and pin 6 Ground. I just plug a two pin pigtail into those two pins and wire a momentary switch to the end.....
No, He is means using GPIO 3 and another GPIO configured to power down. Both GPIOs wired to the same switch so that they both get grounded at the same time when the switch is pressed.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

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

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 12:59 pm

klricks wrote:
Wed May 22, 2019 12:51 pm
alphanumeric wrote:
Wed May 22, 2019 12:42 pm
I do believe he is referring to Pins 5 (GPIO 3) and pin 6 Ground. I just plug a two pin pigtail into those two pins and wire a momentary switch to the end.....
No, He is means using GPIO 3 and another GPIO configured to power down. Both GPIOs wired to the same switch so that they both get grounded at the same time when the switch is pressed.
Yes you are right, I missed his "This is working for me on a Pi 2: one single pole push button wired between the two pins in parallel and ground. " statement. Ops.
I don't think grounding GPIO 3 on a Pi 2 will boot it up though? That only works on model 3's. As far as I know anyway.

klricks
Posts: 6367
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 1:05 pm

alphanumeric wrote:
Wed May 22, 2019 12:59 pm
....
....I don't think grounding GPIO 3 on a Pi 2 will boot it up though? That only works on model 3's. As far as I know anyway.
There are 2 versions of the RPi2 with different SOC's. The later version is much like a RPi3 but without BT and WIFI.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

User avatar
thagrol
Posts: 1465
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 2:24 pm

To address various points from the above:
Could you please specify "the two pins" you are referring to?
GPIO 3 for wake up and whichever GPIO you choose for shutdown. In my case that's GPIO 4.
I do believe he is referring to Pins 5 (GPIO 3) and pin 6 Ground. I just plug a two pin pigtail into those two pins and wire a momentary switch to the end.
Nope. See above.
No, He is means using GPIO 3 and another GPIO configured to power down. Both GPIOs wired to the same switch so that they both get grounded at the same time when the switch is pressed
. Yep
I don't think grounding GPIO 3 on a Pi 2 will boot it up though? That only works on model 3's. As far as I know anyway.
It works on the one I have otherwise I wouldn't have posted it. For information, my Pi 2 is v1.1 with a Revison code of a01041

I've also had wake on GPIO 3 working successfully on a Pi B rev 2 (revision code 000f)

As for whether it's safe with I2C devices connected, I've not yet tried it but given that GPIO 3 gets toggled between high and low during I2C transfers I can't see why it shouldn't be. Any device is permitted to toggle that line as it's bi-directional. Pulling it low with a switch will probably disrupt any transfer going on at that time but that will only matter in the shutdown case and possibly not even then.

In the specific case of an RTC, they're generally only accesed at start up. Once the Pi has booted the linux clock is used in preference to the RTC. RTC are used to preserve the time over power loss events so that Pi with no internet access will still have the correct time.

I have not tried using GPIO 3 for shutdown when also using I2C. I'd expect a shutdown to happen the first time anything toggles SDA (GPIO 3) to a low.
Note to self: don't feed the trolls

If I've asked you a question, please answer it. I'm unlikely to be able to help without that information.

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

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 2:31 pm

thagrol wrote:
Wed May 22, 2019 2:24 pm
To address various points from the above:
I don't think grounding GPIO 3 on a Pi 2 will boot it up though? That only works on model 3's. As far as I know anyway.
It works on the one I have otherwise I wouldn't have posted it. For information, my Pi 2 is v1.1 with a Revison code of a01041

I've also had wake on GPIO 3 working successfully on a Pi B rev 2 (revision code 000f)
I'm pretty certain that works on any Pi.
Signature is on holiday.

User avatar
thagrol
Posts: 1465
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 2:40 pm

[quote=thagrol post_id=1471212 time=1558535086 user_id=7855
I have not tried using GPIO 3 for shutdown when also using I2C. I'd expect a shutdown to happen the first time anything toggles SDA (GPIO 3) to a low.
[/quote]

Just did a very quick test.

Reconfigured shutdown to GPIO 3, made sure I2C was enabled, rebooted and ran

Code: Select all

i2cdetect -y 1
with no devices attached.
Pi did not shutdown. Which is good. But it didn't shutdown when I shorted GPIO 3 to ground either.

Same Pi 2 as earlier.

So.

If using a GPIO shutdown button and I2C you can use GPIO 3 for power up but you cannot use it for shutdown.

You can wire GPiO 3 and a second GPIO connected together and to ground through a switch but I'd expect some conflict with any I2C transaction occuring at the time the button is pressed.

One button is definitely possible. Two is probably safer.
Note to self: don't feed the trolls

If I've asked you a question, please answer it. I'm unlikely to be able to help without that information.

emuola
Posts: 24
Joined: Wed Jun 19, 2013 5:50 pm

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 4:19 pm

Thanks for the replies guys :) I'll do some further testing with the switches.

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

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 4:42 pm

Also like to post a thanks for the extra info. :D
I don't have a model 2 here to test with, I gave mine to new home's when I upgraded to Model 3's.

User avatar
thagrol
Posts: 1465
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Power button (halt/wake) without GPIO3?

Wed May 22, 2019 8:33 pm

Should work with a Pi 3. Certainly using GPIO3 for shutdown and boot up does.

One thing I forgot to mention above: Do not tie the run header and a GPIO shutdown pin together on the same button/switch (or to a double pole switch).

Unless things have changed, the run header will reset the chip immediately without a clean shutdown. You'll end up with a reset button not a power switch.
Note to self: don't feed the trolls

If I've asked you a question, please answer it. I'm unlikely to be able to help without that information.

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

Re: Power button (halt/wake) without GPIO3?

Thu May 23, 2019 8:15 am

Yeah, the Run pin is something like the reset Button on a PC. If its running and you push it, it will do a hard reset / reboot with no proper shutdown in between. Not a good thing. I have a button wired to the RUN pin of the Pi Zero I use in my Pirate Radio. I use it to turn it on when I want to listen to some tunes. I never unplug the power, I just shut down with the "other" Phat Beat shutdown button and leave it plugged in / powered up.
Just have to remeber to press the correct button to shut down. ;)
Pressing the wrong one doesn't really hurt anything electrically. I just run the risk of corrupting my Micro SD card. And having to wait for it to boot up again to shut it down properly, lol.

Return to “Beginners”