Switching a Pi off

Raspberry Pi related support

Re: Switching a Pi off

Postby noxx2 » 07 May 2015, 16:57

neanderthaler wrote:I installed switch, resistors, led, python and the shutdown script from here:
http://www.forum-raspberrypi.de/Thread-tutorial-hoch-und-runterfahren-mittels-taster-incl-status-led
Needs to be adopted to archlinux: arch uses systemd instead of the debian sysvinit.
Works great, with no noticeable load on my slightly aged Pi B+.
I use an USB-DAC, but it should work with I2S-DACs as well. The relevant IOs are not used by iqaudio AFAIK.
If you are not afraid of playing around with linux, just give it a try!
Well worth it, IMHO.


hello neandertahler

i use on my PI the same solutiuon, under Raspian works this good. But i dont know what i must installed
on a Arch-System?
perhaps you can help (or anyone other).

regard
noxx2
 
Posts: 5
Joined: 05 May 2015, 17:24

Re: Switching a Pi off

Postby neanderthaler » 09 May 2015, 07:39

Hi noxx2,

- install python and RPi.GPIO as described here: http://www.runeaudio.com/forum/python-on-rune-audio-t636.html
- copy shutdown_switch.py to /usr/bin, remember to remove "sudo" and
Code: Select all
chmod 755 shutdown_script.py

- create a new service-file /usr/lib/systemd/system/shutdown_pi.service with this content:
Code: Select all
[Unit]
Description=shuts down the Pi if button pressed
Requires=
After=

[Service]

Type=simple
ExecStart=/usr/bin/python /usr/bin/shutdown_switch.py
TimeoutSec=0

[Install]
WantedBy=multi-user.target

- do a
Code: Select all
systemctl enable shutdown_pi.service

Reboot and you're done.
Good luck :)
neanderthaler
 
Posts: 22
Joined: 01 May 2015, 08:20

Re: Switching a Pi off

Postby yjo » 10 May 2015, 04:18

Hi,
I installed a button switch and an LED.
The hardware and software are both very simple.
The short push of the button toggles play/pause, and the long push (indicated by the LED) starts shutdown.
The control script is written in shell script, so installation of python or so is not required.

http://yjo-blog.blogspot.com/2015/02/runeaudio-03.html

yjo
yjo
 
Posts: 11
Joined: 07 Feb 2015, 14:38

Re: Switching a Pi off

Postby neanderthaler » 10 May 2015, 19:37

Hi yio,

your solution with bash scripting looks indeed promising.
Did you check if it causes any measurable load on cpu?

BTW, to start (again), you have to unplug and plug in the power source?
When I find some spare time, I'll try to merge start function into your bash script. It's just one more GPIO. Pentecost, or summer holiday, or christmas...:-)

Isn't it great to find at least some solutions to this !"§$%&! problem?
I like this forum.
neanderthaler
 
Posts: 22
Joined: 01 May 2015, 08:20

Re: Switching a Pi off

Postby yjo » 11 May 2015, 13:08

> your solution with bash scripting looks indeed promising.

Thanks. Simple is best ;)

> Did you check if it causes any measurable load on cpu?

"ps -aux" reports as below:

Code: Select all
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       138  2.0  0.1   3364   812 ?        S    20:05   0:40 /bin/sh /usr/bin/shutdownbt_led.sh


This means this daemon script affects little the performance of the whole system, I think.

> BTW, to start (again), you have to unplug and plug in the power source?

Right, but I installed another paddle switch for turning the power on/off.
For restarting the Pi, I just turn off the switch and then turn it on again.

raspi.jpg
raspi.jpg (118.72 KiB) Viewed 3018 times


The script, switch, and LED work well on not only Rune but also Volumio and moode audio :D
I didn't test on Archphile -- maybe my todo :roll:

PS. An IR remote controller also works well on Rune, Volumio, and moode. I can also shutdown (and reboot) the Pi from the remote controller.
yjo
yjo
 
Posts: 11
Joined: 07 Feb 2015, 14:38

support RuneAudio Donate with PayPal

Previous

Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 28 guests