loading

Show info
COEL

Aarhus, Denmark

IMG_1486-1

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.

IMG_1487

Installation

For the installation you need (Recommended):

  1. Raspberry Pi A+ (doh!)
  2. Class 10 MicroSD-card (with adapter) with at least 4GB space
  3. DAC/Audio add-on board for the Raspberry Pi, such as the HiFiBerry DAC+ (Recommended)
  4. Power-supply with 2A
  5. USB-wifi dongle
  6. Patience!

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:

Windows

  1. Extract the downloaded zip file and you’ll have a .img image file
  2. Download and extract Win32DiskImager
  3. Open Win32DiskImager, right-clicking on the file, and select “Run as Administrator”
  4. 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
  5. 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)
  6. When ready click on Write and wait for the process to complete
  7. Exit from Win32DiskImageWriter and eject the SD card
  8. 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

Using PiWriter:

  1. Once the download has finished, you can open it with StuffIt ExpanderZipeg, or any other zip-software for Mac OS X – just unzip it and you’ll have an .img file ready to be copied
  2. Download PiWriter and use it to flash your SD Card, it should work with every SD Image, not only Raspberry PI’s
  3. If above method fails to work, please see alternate method using console here

 

Now plug the sd-card into your Raspberry Pi!

 

Configuration

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:

cat /sys/module/8192cu/parameters/rtw_power_mgnt

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:

sudo reboot

Voila! Power Management is disabled (and countless hours spent on troubleshooting connectivity problems was saved!)

Christian Østergaard Laursen