Introduction: Raspberry Pi AirPlay Receiver

Picture of Raspberry Pi AirPlay Receiver

Are you tired of having to use a cable every time you want to play music from your iPhone or computer, but you don't want to spend several hundreds of dollars on a pair of wireless speakers?
Well, why not use a Raspberry Pi? This cheap, yet powerful single-board computer is a great device to run a media center or to stream audio to.
You can then connect it to any speaker or audio system you'd like, so you can even get much better sound quality than most AirPlay speakers.

Step 1: What You'll Need

To build this project, you'll need a Raspberry Pi, obviously, a Raspberry Pi 2 is preferred, but in theory, it should also work with first generation of Pi's. You'll also need a power adapter for the Pi, you could use a standard 5V phone charger, but keep in mind that the RPi 2 can draw up to 2 Amps ! You'll also need something to connect it to a network, this could either be a normal Ethernet cable, or a WiFi dongle, if you want to do it wirelessly.
For the media center, you'll need an SD card, at least 2GB in size. If you want to store your music and videos on the Pi itself as well, you'll probably need 16GB or even more.
The built-in audio card of the Pi is a bit noisy, especially when combined with a cheap power adapter. Therefore, I recommend using a USB sound card or a receiver with HDMI inputs. You could also get a HiFiBerry DAC+, although I haven't tried this yet.

To perform the installation, you'll also need a USB mouse, a computer with an internet connection and an SD card adapter.

And, of course, you'll need either an iPhone, iPod, or computer running iTunes, to stream your music from, and a pair of speakers.

Step 2: About Kodi, OpenELEC and Airplay

Kodi is an open-source media center, that can play music, videos, display photos, stream movies etc. One of its features is that it can receive AirPlay content.

OpenELEC is an open-source, Linux-based operating system, that has Kodi preinstalled. So instead of taking you to some kind of desktop like a normal operating system would, it automatically opens Kodi every time you start it.

With iOS 8 and older, Apple's streaming service AirPlay worked flawlessly with Kodi, you could stream virtually anything, videos, music, even screen mirroring worked perfectly.
But then Apple released iOS 9, and they changed their AirPlay protocol, breaking compatibility with Kodi and other open-source solutions.

In the latest version of Kodi (16.0), they restored the audio streaming. Screen mirroring and video streaming are not possible yet, but at least you can play your music.

However, OpenELEC hasn't been officially released with Kodi 16 yet, so we'll have to use the nightly builds to bring it to our Raspberry Pi.

Step 3: Downloading and Installing OpenELEC to the SD Card

Picture of Downloading and Installing OpenELEC to the SD Card

You can't install the nightly builds directly, so we'll have to install the latest stable version of OpenELEC first, and update it to the latest nightly build afterwards.

Linux (Ubuntu)

First, go to the OpenELEC download page and download the latest disk image for Raspberry Pi 2.

Next, open a terminal window (CTRL+ALT+T), type

watch lsblk

and hit enter. (You can paste in the terminal using CTRL+SHIFT+V)
lsblk lists all storage devices and partitions, and watch repeats the lsblk command every two seconds. While this command is running, insert your SD card into your computer. One or more new lines should pop up in the terminal, this is your SD card. Remember the device name of your SD card, or write it down. lt's sdx or mmcblk0 (where x is the drive letter). Also remember the partitions, sdx1 and sdx2, for example, or mmcblk0p1 and mmcblk0p2.

Hit CTRL+C to exit the watch command, and type in

cd Downloads

to go to your Downloads directory. (cd = change directory)

Unzip the file you downloaded by running

gunzip -d OpenELEC-RPi2.arm-6.0.1.img.gz

Then unmount the SD card:

umount /dev/sdxY

or

umount /dev/mmcblk0pY

Where x is the drive letter, and Y the partition number. Make sure you use the right letters (that you got from the watch lsblk command)
Do this for every partition on the SD card.

To install the disk image file (.img) to the SD card, run

sudo dd if=OpenELEC-RPi2.arm-6.0.1.img of=/dev/sdx bs=4M

or

sudo dd if=OpenELEC-RPi2.arm-6.0.1.img of=/dev/mmcblk0 bs=4M<br>

dd is a low-level copying tool. It just copies the entire image file to the SD card. (if = input file, of = output file, bs = block size)
Replace sdx accordingly. Make sure you select the right of (the right drive) since dd will completely overwrite whatever storage device you specify. Be careful not to destroy your hard disk.

When dd has finished copying, run

sync

to ensure the changes are synced to the SD card.

You can now remove the SD card and insert it into your Raspberry Pi.

(source: http://wiki.openelec.tv/index.php/HOW-TO:Installin... )

Windows

First, go to the OpenELEC download page and download the latest disk image for Raspberry Pi 2.

The downloaded file is a .img.gz file, it's an disk image file (.img) that is compressed using GNU zip, so Windows doesn't know how to open it, let alone how to install it.

To unzip the file, you'll need 7-zip, so download it from their site: http://www.7-zip.org/

To install the file to the SD card afterwards, you'll need Win32 Disk Imager. Download this piece software as well: https://sourceforge.net/projects/win32diskimager/

The 7-zip installation is very straightforward, just download and run the installer, click 'Install' and 'Close' when it's finished.

Next, go to you your Downloads folder, and open the OpenELEC-RPi2.arm-6.0.1.img.gz file with 7-zip File Manager (Right click > Open With > 7-zip File Manager, or if 7-zip is not in the list, Right click > Open with > Choose another app > More apps ↓ > Look for another app on this PC > 7-Zip > 7zFM.exe > Open )

In the 7-Zip file manager, click the blue '-' to extract it.

Next, install Win32 Disk Imager.

Just double-click the installer, and follow the instructions (see images)

Once it's installed, insert the SD card into your computer and run Win32 Disk Imager.

Then click the blue folder button to select the OpenELEC-RPi2.arm-6.0.1.img file.
Select the right device from the drop-down menu. It is very important that you select the drive letter that corresponds to your SD card, if not, you may corrupt data on other storage devices.
If you are sure that you selected the right letter, click write, and then confirm the action. This will start installing OpenELEC to the SD card. Wait for it to complete, safely remove the SD card from your computer, and insert it into the Raspberry Pi.

(source: http://wiki.openelec.tv/index.php/HOW-TO:Installin...)

Step 4: Installing OpenELEC to the Raspberry Pi

Picture of Installing OpenELEC to the Raspberry Pi

Insert the SD card into the Pi, connect it to a monitor or tv, connect a mouse, give it an internet connection, and turn on the power.
It should display the OpenELEC splash screen, resize the partition, and reboot.
Then follow the installation instructions (see images).

It is important that you enable Samba, you'll need it to install the nightly build.

When you get to the home screen, (with the words pictures, videos, music, programs and system), reboot the Pi. (the power symbol in the bottom left corner)

Step 5: Installing Kodi 16 (nightly Build)

Picture of Installing Kodi 16 (nightly Build)

To use AirPlay, we'll need the latest version of Kodi, Kodi 16.0. This version is only available as a nightly build.

Download the latest build from the site, that's the one at the bottom of the page.

Linux (Ubuntu)

Open a terminal (CTRL+ALT+T) and run

cd Downloads
bzip2 -d OpenELEC-RPi2.arm-7.0-devel-20160220221118-r22192-gb369831.tar.bz2

To go to the Downloads folder, and to unzip the file. (change the file name to the one you downloaded)

Now open your file manager (Nautilus) and go to your Downloads folder. There should now be a file OpenELEC-RPi2.arm-7.0-devel-20160220221118-r22192-gb369831.tar. Copy it (CTRL+C)

Then click 'Browse Network' in the bottom left corner in Nautilus. There should be two new network devices, one normal, and one in capital letters. This is your Raspberry Pi. (Your computer and your Pi should both be connected to the same network.)
The first one (AirPlay) is the ssh server. If you don't have it enabled in OpenELEC, you'll get a connection refused by server error. The ssh server can be used to browse the Pi's whole file system, but we don't need that. We only need the 'Update' folder, which is shared with Samba (Windows share) as well.

So double-click the server in all capital letters (AIRPLAY) and go to the 'Update' folder. Paste the nightly build .tar file there.

When it's pasted, reboot your Pi (use escape or right-click to go back to the home screen.)
It will automatically install the file.

On the startup screen, it will show:

Found new .tar archive. extracting...

Then it updates the kernel and the system and reboots.

It has now been updated to the nightly build.

Windows

In Windows, the procedure is quite similar.

To unzip the file, use 7-Zip (Right click > 7-Zip > Extract here)

Then copy the .tar file you just extracted. (CTRL+C)

Now go to System > System info > Summary on your Raspberry Pi, and remember the IP-address. In my case, this was 192.168.2.4.

In the address bar of Windows Explorer, type in

\\192.168.2.4\Update

(Change this to the correct IP-address)
This will take you to the Update folder on the Pi. Paste the .tar file you copied here.

When it's pasted, reboot your Pi (use escape or right-click to go back to the home screen.)
It will automatically install the file.

On the startup screen, it will show:

Found new .tar archive. extracting...

Then it updates the kernel and the system and reboots.

It has now been updated to the nightly build.

Step 6: Setting Up AirPlay

Picture of Setting Up AirPlay

Finally, you have to go to the settings to enable the AirPlay iOS 9 compatibility mode.

On your Pi, go to System > Settings > Services > AirPlay. Then click 'Settings Level' twice, to enter the Expert mode. Finally, disable 'AirPlay "Videos" and "Pictures" support', to enable iOS 9 compatibility.

Reboot once more, for the settings to take effect, and AirPlay should work.

Obviously, you'll need an audio device as well, so go to System > Settings > System > Audio Output > Audio output device, and select the right device.

Pi: Analog is the 3.5mm jack on the Pi itself, and Pi: HDMI is digital audio over HDMI (to use with an HDMI receiver or tv). External USB sound cards should be listed under ALSA.

Step 7: Connecting Your IPhone, IPad or Computer

Picture of Connecting Your IPhone, IPad or Computer

To connect your iPhone or computer with iTunes to the Raspberry Pi, you must have them connected to the same network.

To get it working with iTunes, just click the AirPlay icon next to the volume slider, and select Kodi (AirPlay).

On your iPhone or iPad, swipe up from the bottom to open the Control Center. Then click the AirPlay button, and select Kodi (AirPlay).

Once connected, the audio of your device should play on the Pi. The metadata and the album cover should show up on the screen of the Pi as well, and you can use the volume control on your Apple device to control the Pi's volume.

Note: You don't have to leave the display and the mouse connected, you can just use it with a power adapter and an Ethernet cable or WiFi dongle, so you can put it in a small enclosure next to your amplifier, for example.

(image 3 source: Apple)

Step 8: Conclusion

Picture of Conclusion

Although it is in a very cumbersome way, it is possible to use AirPlay with your Raspberry Pi. Well, it's not thát difficult to get it working, but it took me quite a lot of research, so hopefully the guys behind OpenELEC and Kodi will fix this in a future release of their amazing media center, and maybe even bring back video, screen mirroring and picture support.

Of course, Kodi can do a lot more than just receiving AirPlay music, so I highly recommend that you experiment with its other features as well, like playing YouTube videos from your phone, playing tv series, playing local music and videos (you can copy your media to the Pi in the same way we copied the .tar update file, just put it in the right folder), streaming music and videos from your Android phone, Windows or Linux PC or even directly from your NAS ... the list is pretty much endless. Also take a look at the plugins.

Well that's it for this Instructable, I hope it helps some of you out.
I use it everyday, I can just leave my phone in my pocket and walk around the house, while the music keeps playing, and I can skip or adjust the volume at any time.

If you liked this Instructable, please consider voting for me in the Raspberry Pi Contest or in the Hack Your Day Contest, that would help me a lot !

If you have any questions or remarks, just leave a command, and I'll try to help you out!

tttapa, 21-02-2016

Comments

DIY Hacks and How Tos (author)2016-02-21

Great Raspberry Pi project! You've got my vote.

Pathetic thing to ask, I know, but is there any particular reason that this didn't get featured? Just to improve my future Instructables.

If you want a good run down of the kinds of things that the staff look for when featuring, you can check out this instructable: https://www.instructables.com/id/How-to-Create-a-Fe...

This will give you some great tips and examples.

Thanks a lot! I'm glad you like it!

edwinkort (author)2016-02-21

Wanted to vote, but system wouldn't let me :(

seamster (author)edwinkort2016-02-23

If you vote from the contest pages, it will work. This appears to be a bug, and the site's developers are aware of it and working to resolve it.

https://www.instructables.com/contest/raspberrypi20...

https://www.instructables.com/contest/hackyourday/

tttapa (author)seamster2016-02-23

Thanks for the clarification!

tttapa (author)edwinkort2016-02-21

Hmmm, strange ... Does it work already?
Anyway, thanks for your interest!

edwinkort (author)tttapa2016-02-21

from the app I can vote. from the website not.

ThomasK19 (author)edwinkort2016-02-21

Got the sane problem. The web site does not let me cast my vote :-(

tttapa (author)ThomasK192016-02-22

Just messaged the support service, hopefully they will be able to help me ...

ThomasK19 (author)tttapa2016-02-22

Still no luck...

About This Instructable

12,023views

57favorites

License:

More by tttapa:Raspberry Pi AirPlay receiverHow to install Ubuntu 14.04 alongside WindowsGetting started with Ubuntu
Add instructable to: