I would like to share my setup which is used for AirPlay, and nothing more than that.
My equipment is as follows:
Purifi EVAL1
smps1200a400
SMSL SU-8s
Raspberry PI4
Elac FS407
My goal was to achieve the greatest possible user-friendliness, while not compromising on quality.
The first thing I did was buy two of these:
TRU COMPONENTS 718672 3.5 mm audio jack Socket, vertical vertical Number of pins: 2 Mono Black 1 pc(s) | Conrad.com
One connected to the smps1200a400 (GPIO / GND to PIN J5.1 / J5.5) and the other to the Raspberry PI (GPIO / BCM pin 21 and GND39) then just connect the PI to the smps1200a400 via a minijack cable
Notice my 5A fastblow fuse, unbelievable Ghent does not add it
🙁
My wish is that my PI should turn on my amplifier when music is playing, and turn it off when nothing is playing and after 5 minutes.
And here I must admit that I came across a difficult task. Because I can not code anything. And I could not find anything that lived up to what I want. Yes. Volumio has a plugin, it only works during play / pause and not when the music stops by itself.
So ... I had to get started
🙂
The following is code without explanation. The purpose is as written to get my amplifier to turn on when music is playing and turn off when no music is playing and after 5 min
Download, install Raspberry Lite
Raspberry Pi OS – Raspberry Pi
Write an empty text file named "ssh" (no file extension) to the root of the directory of the card.
Create a text file called wpa_supplicant.conf, and place it in the root directory of the microSD card.
Code:
country=DK
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
scan_ssid=1
ssid=“your_ssid”
psk="your_wifi_password"
}
From Mac via terminal
ssh pi@ipadress
Password:raspberry
Change the password!!!
sudo raspi-config
******************************
Update Raspiberry
******************************
sudo apt-get update
sudo apt-get upgrade
sudo reboot
******************************
Install shairport
******************************
shairport-sync/INSTALL.md at master * mikebrady/shairport-sync * GitHub
Code:
sudo apt install --no-install-recommends build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
git clone
GitHub - mikebrady/shairport-sync: AirPlay audio player. Shairport Sync adds multi-room capability with Audio Synchronisation
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-systemd
make
sudo make install
sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync
******************************
Shairport settings
******************************
sudo nano /etc/shairport-sync.conf
Code:
general =
{
name = "Eigentakt";
volume_range_db = 80 ;
volume_control_profile = "flat";
};
sessioncontrol =
{
run_this_before_entering_active_state = “home/pi/pyh/stop.py";
run_this_after_exiting_active_state = “home/pi/pyh/start.py";
active_state_timeout = 300.0;
};
alsa =
{
output_device = "hw:1";
};
******************************
On/off on play/pause/music stops via GPIO
******************************
sudo apt install python3-gpiozero
sudo usermod -aG gpio shairport-sync
sudo mkdir pyh
cd pyh
sudo nano start.py
Code:
#!/bin/python3
from gpiozero import LED
from signal import pause
led = LED(21)
led.on()
pause()
sudo nano stop.py
Code:
#!/bin/python3
from gpiozero import LED
from signal import pause
led = LED(21)
led.off()
pause()
sudo chmod +x pyh/start.py
sudo chmod +x pyh/stop.py
******************************
Off on boot via GPIO
******************************
sudo mkdir logs
cd pyh
sudo nano launcher.sh
Code:
#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute python script, then back home
cd /
cd home/pi/pyh
sudo python3 start.py
cd /
sudo chmod 755 launcher.sh
sudo crontab -e
Code:
@reboot sh /home/pi/pyh/launcher.sh >/home/pi/logs/cronlog 2>&1
I can add if you need 3V, and not 0V to trigger your smps to turn on, then swap these start.py and stop.py so it looks like this:
Code:
run_this_before_entering_active_state = “home/pi/pyh/start.py";
run_this_after_exiting_active_state = “home/pi/pyh/stop.py";
sudo reboot
Play and forget