Published October 28, 2015
Running AirPlay on a Raspberry Pi A+
Stream Music Wirelessly from your iPhone or iPad using a Raspberry Pi A+ as AirPlay receiver!
So I guess this post will mostly serve as a guide for next time I have to go through the process of setting a Raspberry Pi A up as a AirPlay streaming device using a HifiBerry DAC+. I’ve always wanted to be able to stream music wirelessly to the old Harman/Kardon stereo set in the livingroom – I just hate having to use the auxiliary cable constantly. In the beginning of this year I stumbled upon the Shairplay Airplay Server on github, which I’ve tried to install a few times, however I’ve always run into trouble using it since the original author of the plugin abandoned it because of no time for maintenance (who can blame him?). Not so long after I ran into Volumio – Audiophile Music Player (it was called RaspyFi before), which has some really great features! It’s a (free) open source linux distribution that turns embedded systems, such as the Raspberry Pi or BeagleBone into a music streaming device! It even has Spotify-support! It runs as a headless client, but it comes with a responsive web-ui that you can control from either phone, tablet or computer.
It also supports Audio boards, such as the HifiBerry DAC! And I must stress, if you’re doing anything related to audio on a Raspberry Pi buy a DAC add-on board – the difference in quality is clear.
For the installation you need (Recommended):
- Raspberry Pi A+ (doh!)
- Class 10 MicroSD-card (with adapter) with at least 4GB space
- DAC/Audio add-on board for the Raspberry Pi, such as the HiFiBerry DAC+ (Recommended)
- Power-supply with 2A
- USB-wifi dongle
First off, you need to download the Volumio distribution from https://volumio.org/get-started/, which is version 1.55 at the time of this post. After the download has been completed, you follow the directions for copying the image onto the MicroSD card, these instructions can also be found at the above link, otherwise look at the copy below:
- Extract the downloaded zip file and you’ll have a .img image file
- Download and extract Win32DiskImager
- Open Win32DiskImager, right-clicking on the file, and select “Run as Administrator”
- Insert the MicroSD Card on your computer, you could use an external card reader, the SD-card adapter or the SD slot, if your computer has one built-in
- Check that the device name correspond to the microSD card, then browse the files and select choose the image file you want to write (IMPORTANT! To be safe, unplug every External USB Drive you may have connected to your PC)
- When ready click on Write and wait for the process to complete
- Exit from Win32DiskImageWriter and eject the SD card
- Done! Volumio is now on your SD Card!
Mac OS X
On Mac OS X, you have multiple software that helps you copy the image file. Here’s some of them
- Pi Filler – http://ivanx.com/raspberrypi
- RPi sd-card builder – http://alltheware.wordpress.com/2012/12/11/easiest-way-sd-card-setup/
- Apple-Pi Baker – http://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/
- PiWriter – http://sourceforge.net/projects/piwriter/
- Once the download has finished, you can open it with StuffIt Expander, Zipeg, or any other zip-software for Mac OS X – just unzip it and you’ll have an .img file ready to be copied
- Download PiWriter and use it to flash your SD Card, it should work with every SD Image, not only Raspberry PI’s
- If above method fails to work, please see alternate method using console here
Now plug the sd-card into your Raspberry Pi!
Now we have to configure a couple of things before we can stream some high quality tunes wirelessly, I’ve listed them below:
- Configure WiFi USB Dongle for your wireless network
- Configure Power Saving Management for WiFi
- Configure VolumIO for AirPlay
- (Optional) Create backup of SD-card, in order to save time if something goes wrong later.
Now we arrive at the most difficult step, as the Raspberry Pi A+ doesn’t have support for wired ethernet. Plug-in your prepared Volumio SD card into the Raspberry Pi A+ and attach it to a monitor by HDMI cable and plug a keyboard into the USB. We just need to do a few changes before your Pi will appear as a AirPlay receiver.
We will have to add your wireless router settings in order for it to connect to your WiFi, afterwards these settings are editable/configurable from Volumios web-interface. Depending on your WiFi, the setting can be different – I encourage you to google for an alternative WiFi setup guide, if this one differs from yours. Otherwise, add a comment and I’ll see if I can help!
Lucky for me (and you), Volumio comes with my (our) favourite editor nano, so let’s edit the network interface configuration! Type following in console:
sudo nano /etc/network/interfaces
You’ll likely see the following:
IMPORTANT (Seriously…) – Disable WiFi Power Management
If you bought your WiFi dongle at ThePiHut or you know that your dongle is based on the RTL chipset (such as the RTL-8192), we need to change the power management (even though we added wireless-power off to the /etc/network/interfaces file). If you experience that the Raspberry Pi A+ randomly disconnects/loses connection, this is likely to be the problem! If I only knew this when troubleshooting – so a quick shout out to Matt from Raspberrypi-spy.co.uk for the guide.
First, check the power management flag by typing the following into the terminal:
If it returns 1, then power-management is enabled on your Raspberry Pi! So to change it, edit the following file:
sudo nano /etc/modprobe.d/8192cu.conf
Then add the following to the file:
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
To save and quit from nano use [CTRL-X], [Y] then [ENTER].
Now reboot your Raspberry Pi:
Voila! Power Management is disabled (and countless hours spent on troubleshooting connectivity problems was saved!)