Raspberry Pi AirPlay setup
It took a while to find a reliable ‘set it and leave it’ configuration for my Pi-powered AirPlay network. Here’s the config I settled on, with thanks to Ray Wenderlich and Pi My Life Up.
Update: I’m no longer using this config because Shairport doesn’t support AirPlay 2 for multi-room synchronisation. A set of second-hand AirPort Expresses have taken up the role with no problems to report.
Write disk image to SD card (or just use Etcher) #
- Identify the address of your SD card.
df -h
- Unmount the card with, replacing ‘disk1s1’ with your SD card address.
sudo diskutil unmount /dev/disk1s1
- Write the image to the card, replacing the image location and disk address.
sudo dd bs=5m if=~/Downloads/wheezy-raspbian.img of=/dev/disk1s1
- Pop the card into the RPi and boot up.
Update everything #
sudo apt-get update
sudo apt-get upgrade
sudo dpkg --configure -a
Expand file system and change hostname #
- Open the configuration client.
sudo raspi-config
- Network options > change hostname
- Advanced options > expand filesystem
Set static IP #
sudo nano /etc/dhcpd.conf
- Add the following, changing addresses for your own network:
interface eth0 static ip_address=172.16.10.255/16 static routers=172.16.10.1 static domain_name_servers=172.16.10.1
- Using WiFi? Use this version instead, again changing the addresses for your own network:
interface wlan0 static ip_address=172.16.10.255/16 static routers=172.16.10.1 static domain_name_servers=172.16.10.1
Disable Wi-Fi power management #
sudo nano /etc/network/interfaces
- Find
iface wlan0 inet manual
. - Add
wireless-power off
below it so you’re left with the following:iface wlan0 inet manual wireless-power off
sudo reboot
Update firmware and packages, add new audio driver and change default audio port #
sudo rpi-update
sudo apt-get update
sudo apt-get upgrade
sudo nano /boot/config.txt
- Add the following:
audo_pwm_mode=2
sudo mixer set numid=3 1
Install prerequisites and perl net-sdp #
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
cd perl-net-sdp
perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd ..
Install and run shairport #
git clone https://github.com/hendrikw82/shairport.git
cd shairport
make
- Run Shairport, replacing ‘TheJukebox’ with your chosen AirPlay name.
./shairport.pl -a TheJukebox
Set volume level #
alsamixer
- Set to your desired level. I use 85%.
Daemonise shairport #
cd shairport
sudo make install
sudo cp shairport.init.sample /etc/init.d/shairport
cd /etc/init.d
sudo chmod a+x shairport
sudo update-rc.d shairport defaults
sudo nano shairport
- Delete the existing ‘DAEMON_ARGS’ line.
9 Add the following, replacing ‘TheJukebox’ with your chosen AirPlay name:
DAEMON_ARGS="-w $PIDFILE -a TheJukebox"