micknew wrote:
> I had the same issue.
>
> This is what I did.
>
> Import python-gpio
>
> The create a python file
> ...
Thanks micknew. I was reluctant to install the python extensions only to
have a physical power (on AND off) switch, so I looked for alternatives,
even more because the wiringpi extension is already installed. I know
that with PCP, I could simply put a physical switch in the power cord,
but for practical reasons (the pi will be integrated into a vintage hifi
device (Wega Concept 51k) and I want the push botton to sit in a
modified 6.3 mm headphone plug) I prefer this solution:
What I have done now is:
- Connect a push button to GND (Pin 6) and GPIO3 (Pin 5). This is
already sufficient to start the Raspi from sleep mode, without any
additional software. I've read that when you connect a GPIO to GND, you
don't need the pullup resistors, as they are already contained in the
circuitery. To be honest, I have no clue whether the power consumption
is really less than when the pi is running...)
- Create a script (shut.sh in my case) that contains:
Code:
--------------------
#!/bin/sh
gpio mode 9 in
while true
do
result="$( gpio read 9 )"
if [ "$result" = "0" ]; then
sudo poweroff
fi
sleep 0.5
done
--------------------
This script checks every 0.5 seconds whether the push button has been
pressed.
I put the script into /mnt/mmcblk0p2/tce/, made it executable and backed
up.
In the TWEAKS section, I put
Code:
--------------------
/mnt/mmcblk0p2/tce/shut.sh
--------------------
as User command #1.
Works fine for me
PCP (always latest version) on RasPi 3 with PhatDac (player & server)
PCP on several RasPis 2 +3
2 Airplay speakers (Sony SA-NS510) integrated via Airplay Bridge Plugin
------------------------------------------------------------------------
streampunk's Profile: http://forums.slimdevices.com/member.php?userid=66210
View this thread: http://forums.slimdevices.com/showthread.php?t=107352
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix