Shutdown/Restart Pushbutton

Raspberry Pi related support

Re: Shutdown/Restart Pushbutton

Postby stablgr » 13 Apr 2019, 23:36

This is getting frustrating. I tried using GPIO pins 7, 21, 22, and 29 all without success. When I pull the input low I can see it is being read as it changes from 1 to 0 when I run 'gpio readall'.

For the gpio pins that were reading 0 by default I tried puling them high with (for example for gpio-25)
Code: Select all
dtoverlay=gpio-shutdown, gpio_pin=25,gpio_pull(up)

But this doesn't seem to have the desired effect. gpio-25 would still show low.

Should the dtoverlay statement be placed in a specific location in the config.txt file, or doesn't it matter?

I'm curious if anyone has tried this with Rune and been successful.

Thanks,
Gary
stablgr
 
Posts: 14
Joined: 21 Feb 2016, 04:32

Re: Shutdown/Restart Pushbutton

Postby janui » 14 Apr 2019, 18:43

Hi stablgr,
stablgr wrote:This is getting frustrating. I tried using GPIO pins 7, 21, 22, and 29 all without success. When I pull the input low I can see it is being read as it changes from 1 to 0 when I run 'gpio readall'.
I don’t understand why is wont work or why the gpio pins are different from those expected, I do understand the frustration.
You could try something different from the 'dtoverlay=gpio-shutdown,gpio_pin' method, this looks promising: https://github.com/ali1234/systemd-gpio
This looks far better than the python based routines, which loop in the background testing the gpio status. The documentation claims that it does not to use any resources.
This would also enable rune to do its internal shutdown as well, the 'command: ' should be something like this:
Code: Select all
command: /srv/http/command/rune_shutdown ; /usr/bin/shutdown -P now
It is worth taking the time to understand how it works. It uses the gpio utility, so the detected pin state changes which you have seen should trigger it.
janui

Edited 15-04-2019, the link provided was wrong, the correct link is now shown.
User avatar
janui
 
Posts: 674
Joined: 20 Dec 2014, 12:55
Location: Ollanda

Re: Shutdown/Restart Pushbutton

Postby stablgr » 16 Apr 2019, 18:17

Thanks Janui. I'll take a look at it this weekend and see where it leads me.

Best regards,
Gary
stablgr
 
Posts: 14
Joined: 21 Feb 2016, 04:32

Re: Shutdown/Restart Pushbutton

Postby andre_chang » 05 Sep 2019, 15:28

This way can realize the shutdown state, click the button to start it?
andre_chang
 
Posts: 84
Joined: 01 Feb 2016, 13:27

Re: Shutdown/Restart Pushbutton

Postby BritishAndy » 24 Sep 2019, 20:18

Hi, I have been following your conversation, thank you for all the info, it is exactly what I am trying to achieve. Have you had any luck?
I downloaded the files and installed as per:

Set Up:
cp gpio-trigger@.service /etc/systemd/system
mkdir /etc/systemd-gpio
cp examples/shutdown /etc/systemd-gpio
systemctl reenable gpio-trigger@shutdown

I assume from gpio readall and the config file that this uses GPIO.5 which is pin 18, but shorting this to 5v (or 0v) doesn't seem to do anything.
Is there anything more I need to do apart from the 'setup' above?

My 'project' is to mount the Pi in a 19" rack and use it as part of a PA system to play interval music during shows, it works really well but no easy way to shut it down and I would like to stay headless, hence me trying to figure this out. I am hoping to add a couple of status LEDs too. I guess I could just use a small touchscreen, but I like the minimalist look.
I have very little experience and I am rattling through tutorials and documentation as fast as I can, but struggling with this.

Thanks, and great work so far.

Andrew.
BritishAndy
 
Posts: 2
Joined: 24 Sep 2019, 20:02

Re: Shutdown/Restart Pushbutton

Postby R101 » 24 Sep 2019, 21:21

I have added dtoverlay=gpio-shutdown,gpio_pin=3 to the end of config.txt and found it works fine in 0.4.

I suspect that if I had the local browser enabled, it would not work, as pin=3 is used for the touch screen i2c bus. Could that be the problem?
(Pi 2, Ver. 0.4b build 20170229, JLS I2S over USB)
R101
 
Posts: 231
Joined: 29 Apr 2016, 16:16

Re: Shutdown/Restart Pushbutton

Postby BritishAndy » 24 Sep 2019, 21:45

I have got this working.
I think the code works fine as described above but I was getting confused with the pin numbering. GPIO=5 in the 'shutdown' file seems to be GPIO.21 on physical pin 29.
If I set GPIO=24 in 'shutdown' then this refers to GPIO.5 on physical pin 18.

In short, it works well. I didn't change the command string as shutdown -h now worked fine as downloaded and any attempt to modify it seemed to stop things working so any advice on this appreciated.

So now I can put 2 buttons on my project, a pull-up switch on pin 18 marked SHUTDOWN and a short between pins 5&6 marked RESET.

Now to work out some LEDs :-)
BritishAndy
 
Posts: 2
Joined: 24 Sep 2019, 20:02

support RuneAudio Donate with PayPal

Previous

Return to Raspberry Pi

Who is online

Users browsing this forum: cmh714 and 4 guests