This is the process I followed to get a working AirPlay receiver!
First off, assemble your Raspberry Pi (put the case on, plug in the Wi-Fi and sound adapters, and plug in an Ethernet cable). I highly recommend connecting a keyboard (USB) and a monitor (HDMI). This is going to just be a temporary thing until you’ve got everything configured, so you could just unplug your Blu-Ray player and hook it up to your telly (this is basically what I did).
Now you’re going to download Raspbian, which is the official Linux for the Raspberry Pi. I got Raspbian Wheezy from the official downloads page, as opposed to Raspbian Jessie, which is a more recent version. I choose Wheezy because it boots to the command line instead of to GUI, and I thought that for what I was doing, that would be a more sensible choice; I’m sure most of the instructions herein will be the same.
After I downloaded Raspbian Wheezy, I unzipped the resulting file and followed the instructions for creating an SD card using OS X. I used Disk Utility and worked out what the disk number of the SD card was by looking at the entry for ‘Device’ in the table underneath the usage chart, and then I ran the following in Terminal.app, where the n in rdiskn should be replaced with whatever the disk number you find is:
This whirred away with no outputs to the Terminal until the process had finished, so don’t be alarmed if nothing appears immediately; just be patient.
I then took the SD card out and put it into the Raspberry Pi. I connected an Ethernet cable to the Pi and to my router, so that it would have an Internet connection. I initially did this with no connected monitor, but I found it too frustrating for words not to be able to see what was happening, so I also plugged in a USB keyboard and a HDMI display. Then, I plugged the power cable in and watched everything boot.3
The username and password for your Raspberry Pi are, by default, pi and raspberry. On my first boot, I was logged in without needing these, but it’s worth knowing what they are for now. You ought to see the configuration screen upon your first boot, and so I followed these steps to configure my machine, expanding the filesystem, setting a locale and a timezone, and changing the name of my Raspberry Pi on the network. Then I rebooted, and logged in using the username and password, ending up at the shell.
At this stage, I got bored of being in front of my TV, so I unplugged the USB keyboard and the HDMI display and headed to my iMac, where I brought up my Wi-Fi router’s list of devices on the network. Upon learning the IP address that my Raspberry Pi had on the network, I was able to run
The Ethernet cable was trailing across my living room, so configuring Wi-Fi was the next thing to do. Fortunately, once you have the drivers for your Wi-Fi adapter set up correctly, this is pretty easy5! The Wi-Fi adapter I bought isn’t supported out-of-the-box, but a trip to Stack Exchange revealed that this wasn’t a problem, courtesy of this post by MrEngman on the Raspberry Pi forums. To get the adapter working, simply do
pi@RaspberryPi ~ $ uname -a
Linux RaspberryPi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux
to find your version number (in this case, it’s 3.18.11-v7+ #781) and then, on MrEngman’s post, find the .tar.gz filename which corresponds to that number. Then, I just scrolled to the bottom of his post to find out that I needed to run
tar xzf 8188eu-v7-20150406.tar.gz
to get my Wi-Fi adapter working. I rebooted the system before continuing, just to be sure.
I then rebooted and tested the output by plugging my EarPods into the sound adapter and then running
speaker-test -t sine
If you don’t hear a tone, it’s not properly configured.
Finally, I installed the tools I needed to get AirPlay running on my Raspberry Pi. I initially used this AirPlay tutorial and this AirPlay tutorial to get it working by installing a GitHub project called Shairport into ~/airplay, which is currently not under active development. I AirPlayed some audio to the Pi, and it worked fine, which made me very happy! However, when I tested using iTunes to play through the Pi and my iMac simultaneously, the two audio tracks were not in sync. As such, I went looking for ways to make AirPlay synchronise the playback.
I found my salvation in the form of Shairport Sync, which is a fork of Shairport with the added benefit that it is in active development6. Here are the steps I took to install it7 (including a line which checks whether systemd or System V is the way forward on your machine8), which come from the project’s Readme.
I then configured Shairport Sync so that when I AirPlayed to my Raspberry Pi it would appear with a different name. Since I’m going to hook this up to a Sony Hi-Fi, I ran
sudo nano /etc/shairport-sync.conf
before uncommenting the first line under general so that it read
name = "Sony Hi-Fi";
before the rest of the settings. Then I rebooted the Pi, and Shairport Sync automatically ran on startup and let me AirPlay my music to it, perfectly synchronised with my other speakers.
Finally, I decided to make a copy of my SD card so that if I messed things up in the future, I can roll back to being satisfied with my progress. To do this, I put the SD card back in my iMac, and then (following the advice of this guide) used Disk Utility to work out what disk number it was (the n in rdiskn), and then did
sudo dd if=/dev/rdiskn of=~/Desktop/pi.img bs=1m
I might be going crazy, but a look at the SanDisk website doesn’t seem to show this product as a current part of their line-up, with only a microSD XC card available; hence the link to a shop rather than the official product page. ↩
I later found out that this adapter doesn’t work without a significant amount of coaxing. Don’t worry, I’ll give the details of how I coaxed it herein! ↩
Watching all the console outputs whizz past on Linux really does make you feel like you’re in The Matrix. ↩
A lot of Raspberry Pi guides will tell you that you need to enable SSH yourself, but this appears to be false in newer versions of Raspbian. ↩
Some guides, such as this one, will tell you to edit /etc/network/interfaces to get Wi-Fi up and running, but again, this appears not to be necessary in newer versions of Raspbian. ↩
Shairport Sync was last updated in October 2015, three months before this was written. ↩
Note that I did this having already followed the tutorials to install Shairport, so it’s possible that this will not work without having done that. I think it should be fine, but I might be wrong! ↩
I think Raspbian Wheezy requires the System V method whereas Raspbian Jessie can use the systemd method, so this part might be a little different if you went modern and plumped for Jessie. ↩