HI,
I find it very strange that i can find so little info the most elementary of things :
Provide a on/off button with script to my Rpi.
So the RPi is out there, performing it's functions (handheld), and now it's time to stop.
What i would like:
There is a switch (tumbler?) that says on/off, it "breaks" the basic python while loop and
launches the command "sudo shutdown -h now".
Or is it so simple that nobody bothers to talk about it.
What makes me think it is not that simple, is that i saw a tumbler switch (somewhere?) with a little PCB attached,
that did just that, i think.
Question: which is the state of the art way to go?
thx,
Paul
Re: Rpi 3 Shutdown button
Is it running from battery? (explanation why asking this comes later)
There exists many approaches by attching a (physical) button to a GPIO, it will be configured as input, and initiate the shutdown-sequence, if button is pressed. There is also an overlay provided yet, which may cover this function, but I haven't tested until now ... (See '/boot/overlay/README.*' for more information.)DPaul wrote: ↑Sun Nov 12, 2017 11:27 am... and now it's time to stop.
What i would like:
There is a switch (tumbler?) that says on/off, it "breaks" the basic python while loop and
launches the command "sudo shutdown -h now".
Or is it so simple that nobody bothers to talk about it.
What makes me think it is not that simple, is that i saw a tumbler switch (somewhere?) with a little PCB attached,
that did just that, i think.
Question: which is the state of the art way to go?
But be aware, that this doesn't disconnect your battery, so it may be drained empty even if in shutdown-state! To avoid this, additional circuits are needed. There exists additional boards, for this purpose, if you do not want to build it by yourself ...
Greetings, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!
B: Yeah, that's very simple: It feeds your cat with radioactive material!
Re: Rpi 3 Shutdown button
I wrote this, but some people like it: Combined Restart / Shutdown Button for Raspberry Pi
If you want power physically disconnected, you'll need something like Pimoroni's OnOff shim. It uses some fixed GPIO assignments, so may not work for you.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
-
- Posts: 1412
- Joined: Fri Jan 04, 2013 1:57 pm
- Location: de_DE
Re: Rpi 3 Shutdown button
as FM_81 told... see /boot/overlays/README
Code: Select all
Name: gpio-poweroff
Info: Drives a GPIO high or low on poweroff (including halt). Enabling this
overlay will prevent the ability to boot by driving GPIO3 low.
Load: dtoverlay=gpio-poweroff,<param>=<val>
Params: gpiopin GPIO for signalling (default 26)
active_low Set if the power control device requires a
high->low transition to trigger a power-down.
Note that this will require the support of a
custom dt-blob.bin to prevent a power-down
during the boot process, and that a reboot
will also cause the pin to go low.
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:
ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \
SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \
ATTRS{keys}=="116", TAG+="power-switch"
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.
Load: dtoverlay=gpio-shutdown,<param>=<val>
Params: gpio_pin GPIO pin to trigger on (default 3)
active_low When this is 1 (active low), a falling
edge generates a key down event and a
rising edge generates a key up event.
When this is 0 (active high), this is
reversed. The default is 1 (active low).
gpio_pull Desired pull-up/down state (off, down, up)
Default is "up".
Note that the default pin (GPIO3) has an
external pullup.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
Re: Rpi 3 Shutdown button
OK, it's running from battery!
I need to disconnect the battery too, i understand now;
I'll look into these options,
thx,
Paul
I need to disconnect the battery too, i understand now;
I'll look into these options,
thx,
Paul
Re: Rpi 3 Shutdown button
Um, this doesn't exactly look like a friendly user shutdown method.beta-tester wrote: ↑Sun Nov 12, 2017 2:19 pm… Enabling this overlay will prevent the ability to boot by driving GPIO3 low.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
Re: Rpi 3 Shutdown button
scruss wrote: ↑Mon Nov 13, 2017 6:31 pmUm, this doesn't exactly look like a friendly user shutdown method.beta-tester wrote: ↑Sun Nov 12, 2017 2:19 pm… Enabling this overlay will prevent the ability to boot by driving GPIO3 low.
That is why you use gpio-shutdown and not gpio-poweroff.
However in my experience, this function only allows you to restart your Pi. It won't shut it down nor boot it the first time.
@OP
Just put a physical switch between the battery and the power input to break the vcc connection after you perform a shutdown. (wait about 10 seconds)
55:55:44:44:4C
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
52:4C:52:42:41
Rose tinted glasses are difficult to see through.
Re: Rpi 3 Shutdown button
OK, one can do it in this way, of course!
But it's not much elegant: You always have to do TWO actions at the end. One for shutdown and one for disconnect battery. And you have to do these in a correct timing ...
Best Regards, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!
B: Yeah, that's very simple: It feeds your cat with radioactive material!
Re: Rpi 3 Shutdown button
FWIW, I've been using 'dtoverlay=gpio-shutdown' in /boot/config.txt with a pushbutton switch connected between GPIO header pins 5 and 6 for many months now and it's been 100% reliable. Pushing the button when the system is running does a 'shutdown -h now' and pushing the button when the system is halted causes it to boot. As others have stated, it doesn't remove power from the RPi, but it does reliably halt and restart it.
Re: Rpi 3 Shutdown button
any info what current we talk about? ( in HALT state )
-
- Posts: 1412
- Joined: Fri Jan 04, 2013 1:57 pm
- Location: de_DE
Re: Rpi 3 Shutdown button
what about buying a UPS HAT/shield for the RPi?
i know, that there are some available.
they have a battery and battery charger. they can shut down the RPi correctly by button/software/automatically at external powerloss
and after shut down, then power off the RPi after a while completely (more or less) - i guess not with a relais, but more than it would be when the RPi is in halt mode.
search for Raspberry PI and UPS.
i know, that there are some available.
they have a battery and battery charger. they can shut down the RPi correctly by button/software/automatically at external powerloss
and after shut down, then power off the RPi after a while completely (more or less) - i guess not with a relais, but more than it would be when the RPi is in halt mode.
search for Raspberry PI and UPS.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)
Re: Rpi 3 Shutdown button
Hi,
I am inclined to repeat what i said in post #1.
Why is it so seemingly difficult ?
To use a (handheld) device, you need to switch it on and then off again.
(Completely off)
I am currently looking at the pimoroni shim:
https://shop.pimoroni.com/collections/e ... onoff-shim
For a beginner all this is very confusing
Paul.
I am inclined to repeat what i said in post #1.
Why is it so seemingly difficult ?
To use a (handheld) device, you need to switch it on and then off again.
(Completely off)
I am currently looking at the pimoroni shim:
https://shop.pimoroni.com/collections/e ... onoff-shim
For a beginner all this is very confusing


Paul.
Re: Rpi 3 Shutdown button
This is absolutely correct!
But for many people it gives a "special stimulus' to make things that "wasn't planned by the manufacturer". Often they have success, may be sometimes not?
And it is also a fact, that this can give (especially for a beginner) the sentence
How ever, I assume, the pimoroni-shim should do what you want ... May be, someone own's that (I didn't) and can confirm?
Greetings, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!
B: Yeah, that's very simple: It feeds your cat with radioactive material!
Re: Rpi 3 Shutdown button
I have an OnOff SHIM, and wrote about it here: Installing the Pimoroni OnOff Shim the hard way. Note that you don't have to install it the way I did.
Plus points:
- It appears to completely remove power from the board when turned off. It might draw a very tiny current when off, but I haven't metered it
- It's small
- It works!
- It re-routes the power connection off to the side of your Raspberry Pi, so it likely won't fit in existing cases.
- It uses a couple of fixed GPIO ports, and so won't work with some HATs
- It doesn't have any charger/battery capabilities
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
Re: Rpi 3 Shutdown button
Very interesting.
About the power switch, i have read that you can solder your own to the board?
If i can find a supplier with reasonable delivery times (like 24 hrs), i'm in
Paul
About the power switch, i have read that you can solder your own to the board?
If i can find a supplier with reasonable delivery times (like 24 hrs), i'm in

Paul
Re: Rpi 3 Shutdown button
Yes, the shim has optional breakout pins to connect an external momentary button
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
Re: Rpi 3 Shutdown button
One point to note is that the software supplied with the Pimoroni OnOffShim does not work with Raspbian Wheezy. I installed it on a Pi B and was confused why it would not install and work.
The power up button part works Ok as that is a hardware function.
After a bit of a struggle I got my Pi to shutdown when the button was operated using part of the supplied software. However this still left the Pi in a partially powered (hibernation state).
I eventually found a way of executing a small script in the final part of the shutdown sequence that killls the power completely. When the Pi enters Init 0 it looks for a scrips to control the UPS power and executes it if it exists. In the normal installation it does not exist but by supplying the UPS script which in my case energises the GPIO pin to kill the power I was able to get a complete power down.
I have never got the green LED to flash as it shuts down but that does not really concern me.
Note if you have the Shim fitted the Pi will not restart after a power failure (assuming the SD Card was not corrupted). To restart it you need to operate the button on the Shim.
The power up button part works Ok as that is a hardware function.
After a bit of a struggle I got my Pi to shutdown when the button was operated using part of the supplied software. However this still left the Pi in a partially powered (hibernation state).
I eventually found a way of executing a small script in the final part of the shutdown sequence that killls the power completely. When the Pi enters Init 0 it looks for a scrips to control the UPS power and executes it if it exists. In the normal installation it does not exist but by supplying the UPS script which in my case energises the GPIO pin to kill the power I was able to get a complete power down.
I have never got the green LED to flash as it shuts down but that does not really concern me.
Note if you have the Shim fitted the Pi will not restart after a power failure (assuming the SD Card was not corrupted). To restart it you need to operate the button on the Shim.