Audiophonics Power Management Add-on

Hi all,
after 2 days hard work, i bring the Audiophonics Power Management Module to work.
If i push the power button short, it will be shutdown and go off.
The power LED will go after success boot from blinking to constant light.

Here are the doings that i made via SSH:

pacman -S nano
pacman -S wiringpi
mkdir /home/root
cd /home/root

-----------------------------------------------------------------

nano /home/root/softshutdown.sh

#!/bin/bash
#Audiophonics
#Shutdown detection script
#Script to set GPIO 4 High for 1sec
PATH=/usr/bin
echo “Setting pin GPIO4 High”
gpio mode 7 out
gpio write 7 1
/bin/sleep 1
echo “Setting pin GPIO4 Low”
gpio write 7 0
echo “RaspberryPi shutdown”
shutdown -h -P now
exit 0

Test softshutdown:

bash /home/root/softshutdown.sh &

-----------------------------------------------------------------

nano /home/root/softreboot.sh

#!/bin/bash
#Audiophonics
#Shutdown detection script
#Script to set GPIO 4 High for 1sec
PATH=/usr/bin
#Script to set GPIO 4 High and Reboot
#Reboot blink will stop after Boot OK return
echo “setting pin GPIO 4 High”
gpio -g mode 4 out
gpio -g write 4 1
echo “Raspberry Pi Reboot”
reboot
exit 0

Test softreboot:

bash /home/root/softreboot.sh &

-----------------------------------------------------------------

nano /home/root/sds.sh

#!/bin/bash
#RoPieee version
PATH=/usr/bin
echo “Audiophonics Shutdown script starting…”
echo "Asserting pins : "
echo “ShutDown : GPIO17=in, Low”
echo “BootOK : GPIO22=out, High”
echo “SoftSD : GPIO04=out, Low”
gpio -g mode 04 out
gpio -g write 04 0
gpio -g mode 17 in
gpio -g write 17 0
gpio -g mode 22 out
gpio -g write 22 1
while [ 1 ]; do
if [ “$(gpio -g read 17)” = “1” ]; then
echo “ShutDown order received, RaspBerry pi will now enter in standby mode…”
shutdown -h -P now
break
fi
/bin/sleep 0.25
done
exit 0

Test sds

bash /home/root/sds.sh &

-----------------------------------------------------------------

nano /lib/systemd/system/pwrmgmt.service

[Unit]
Description=Power Management Module
[Service]
Type=oneshot
ExecStart=bash /home/root/sds.sh &
[Install]
WantedBy=multi-user.target

systemctl enable pwrmgmt.service

Test pwrmgmt.service:

systemctl start pwrmgmt.service

-----------------------------------------------------------------

Script will be autorun after next reboot

4 Likes