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) #

  1. Identify the address of your SD card.
    df -h
  2. Unmount the card with, replacing ‘disk1s1’ with your SD card address.
    sudo diskutil unmount /dev/disk1s1
  3. 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
  4. Pop the card into the RPi and boot up.

Update everything #

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo dpkg --configure -a

Expand file system and change hostname #

  1. Open the configuration client.
    sudo raspi-config
  2. Network options > change hostname
  3. Advanced options > expand filesystem

Set static IP #

  1. sudo nano /etc/dhcpd.conf
  2. 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
    
  3. 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 #

  1. sudo nano /etc/network/interfaces
  2. Find iface wlan0 inet manual.
  3. Add wireless-power off below it so you’re left with the following:
    iface wlan0 inet manual
    wireless-power off
    
  4. sudo reboot

Update firmware and packages, add new audio driver and change default audio port #

  1. sudo rpi-update
  2. sudo apt-get update
  3. sudo apt-get upgrade
  4. sudo nano /boot/config.txt
  5. Add the following:
    audo_pwm_mode=2
    
  6. sudo mixer set numid=3 1

Install prerequisites and perl net-sdp #

  1. sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
  2. git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
  3. cd perl-net-sdp
  4. perl Build.PL
  5. sudo ./Build
  6. sudo ./Build test
  7. sudo ./Build install
  8. cd ..

Install and run shairport #

  1. git clone https://github.com/hendrikw82/shairport.git
  2. cd shairport
  3. make
  4. Run Shairport, replacing ‘TheJukebox’ with your chosen AirPlay name.
    ./shairport.pl -a TheJukebox

Set volume level #

  1. alsamixer
  2. Set to your desired level. I use 85%.

Daemonise shairport #

  1. cd shairport
  2. sudo make install
  3. sudo cp shairport.init.sample /etc/init.d/shairport
  4. cd /etc/init.d
  5. sudo chmod a+x shairport
  6. sudo update-rc.d shairport defaults
  7. sudo nano shairport
  8. Delete the existing ‘DAEMON_ARGS’ line. 9 Add the following, replacing ‘TheJukebox’ with your chosen AirPlay name:
    DAEMON_ARGS="-w $PIDFILE -a TheJukebox"
    
 
1
Kudos
 
1
Kudos

Now read this

An open letter to universities: Why ‘doing your best’ isn’t always doing enough

I am a second-year production management student (theatre, not factory). My higher education experience costs 9,250 per year, plus accommodation, food, transport, bills and general living costs. I am not particularly happy. There seems... Continue →