I am migrating from moOde to piCorePlayer. in moOde I had scripts to control a fan based on cpu temperature and a 12v trigger to turn on my amp.
I am a novice as far as programing goes. I made the scripts for moOde by cobling together different tutorials and forum posts. I can't find anything similar for piCorePlayer.
I need:
GPIO12 to be a pwm signal to control the fan
GPIO16 to go high when playback starts, and go low 120 seconds after playback stops.
I used the proportional version of this for fan control:
https://www.the-diy-life.com/connecting-a-pwm-fan-to-a-raspberry-pi/
And this is what I did for the 12v trigger:
enter:
nano /home/pi/autoamp
paste:
#!/bin/bash
# This Script is to read the Alsa Sound State and Automatcally
# swing a GPIO pin to allow auto switch on / off of an external
# amplifier, its crude dirty and badly written any sugestions
# or criticism welcome
#
# Trevor Cockayne trevoml@gmail.com
# Exports pin to userspace
echo "16" > /sys/class/gpio/export
# Sets pin 16 as an output
echo "out" > /sys/class/gpio/gpio16/direction
count=0
time=120
let count=$time
for (( ; ; ))
do
if grep -q "closed" /proc/asound/card1/pcm0p/sub0/hw_params; then
# echo "DAC IDLE"
let "count++"
else
# echo "DAC Playing"
count=0
fi
if [[ $count -gt $time || $count == $time ]]
then
# echo "Amp Off"
echo "0" > /sys/class/gpio/gpio16/value
count=$time
else
# echo "Amp ON"
echo "1" > /sys/class/gpio/gpio16/value
fi
# echo $count
sleep 1
done
enter:
chmod 755 /home/pi/autoamp
enter:
nano /etc/systemd/system/autoamp.service
add:
[Unit]
Discription=Automatic Amplifier Control
[Service]
ExecStart=/home/pi/autoamp
[Install]
WantedBy=multi-user.target
enter:
systemctl enable autoamp.service
enter:
systemctl start autoamp.service
Will these work for piCorePlayer?
Thanks,
freebirb
I am a novice as far as programing goes. I made the scripts for moOde by cobling together different tutorials and forum posts. I can't find anything similar for piCorePlayer.
I need:
GPIO12 to be a pwm signal to control the fan
GPIO16 to go high when playback starts, and go low 120 seconds after playback stops.
I used the proportional version of this for fan control:
https://www.the-diy-life.com/connecting-a-pwm-fan-to-a-raspberry-pi/
And this is what I did for the 12v trigger:
enter:
nano /home/pi/autoamp
paste:
#!/bin/bash
# This Script is to read the Alsa Sound State and Automatcally
# swing a GPIO pin to allow auto switch on / off of an external
# amplifier, its crude dirty and badly written any sugestions
# or criticism welcome
#
# Trevor Cockayne trevoml@gmail.com
# Exports pin to userspace
echo "16" > /sys/class/gpio/export
# Sets pin 16 as an output
echo "out" > /sys/class/gpio/gpio16/direction
count=0
time=120
let count=$time
for (( ; ; ))
do
if grep -q "closed" /proc/asound/card1/pcm0p/sub0/hw_params; then
# echo "DAC IDLE"
let "count++"
else
# echo "DAC Playing"
count=0
fi
if [[ $count -gt $time || $count == $time ]]
then
# echo "Amp Off"
echo "0" > /sys/class/gpio/gpio16/value
count=$time
else
# echo "Amp ON"
echo "1" > /sys/class/gpio/gpio16/value
fi
# echo $count
sleep 1
done
enter:
chmod 755 /home/pi/autoamp
enter:
nano /etc/systemd/system/autoamp.service
add:
[Unit]
Discription=Automatic Amplifier Control
[Service]
ExecStart=/home/pi/autoamp
[Install]
WantedBy=multi-user.target
enter:
systemctl enable autoamp.service
enter:
systemctl start autoamp.service
Will these work for piCorePlayer?
Thanks,
freebirb
Hi
This post on the 'slimdevices' forum may provide a good starting point. I think it'll be easier on PcP than on Moode:
https://forums.slimdevices.com/foru...player-using-gpio-to-turn-on-off-hi-fi-system
This post on the 'slimdevices' forum may provide a good starting point. I think it'll be easier on PcP than on Moode:
https://forums.slimdevices.com/foru...player-using-gpio-to-turn-on-off-hi-fi-system