Page 2 of 2

Re: Shutdown/Restart Pushbutton

PostPosted: 13 Apr 2019, 23:36
by stablgr
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

Re: Shutdown/Restart Pushbutton

PostPosted: 14 Apr 2019, 18:43
by janui
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.

Re: Shutdown/Restart Pushbutton

PostPosted: 16 Apr 2019, 18:17
by stablgr
Thanks Janui. I'll take a look at it this weekend and see where it leads me.

Best regards,
Gary

Re: Shutdown/Restart Pushbutton

PostPosted: 05 Sep 2019, 15:28
by andre_chang
This way can realize the shutdown state, click the button to start it?

Re: Shutdown/Restart Pushbutton

PostPosted: 24 Sep 2019, 20:18
by BritishAndy
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.

Re: Shutdown/Restart Pushbutton

PostPosted: 24 Sep 2019, 21:21
by R101
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?

Re: Shutdown/Restart Pushbutton

PostPosted: 24 Sep 2019, 21:45
by BritishAndy
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 :-)