Turning your Raspberry pi into an AirPlay receiver

Processed with VSCOcam with c2 preset

The Raspberry Pi is an awesome piece of hardware, you can do so much stuff with this little computer at very low costs and nearly unlimited possibilities. I’ve got one to expand my “musical network” at home. Besides a AirPlay enabled receiver in the living room and a Apple TV in the bedroom I wanted to get another AirPlay client for the bathroom or kitchen. After some research the Raspberry Pi turned up as the at least expensive and most flexible solution. Since there are a lot of tutorials on the Pi and Airplay it is fairly easy to set everything up.

If you want to build your own and got some experience with the console and Linux follow my short tutorial to turn your Raspberry Pi into a nice and cheap AirPlay receiver! If you don’t know what all these commands mean I recommend to check out Adam Burkepiles tutorial on raywenderlich.com which is the base of my version.

Preparations:

  1. You’ll need a Raspberry Pi, a SD card with 4gb memory and some speakers
  2. Download the current version of raspbian at: http://www.raspberrypi.org/downloads

Installation of raspbian:

  • Insert your SD card, open Terminal and type:
df -h
  • Check where your sd card is mounted and type:
sudo diskutil unmount /dev/<YOURSDCARD>
  • Your sd card is now unmounted and ready to get the raspian image
  • Now it’s time to prepare the sd card with raspbian, so type:
sudo dd bs=5m if=2013-09-25-wheezy-raspbian.img of=/dev/<YOURSDCARD>
  • This step can take a while, so be patient! If everything is done you will see a new command prompt in Terminal. If it’s done unmount the sd card, plug it into your raspberry, connect it via LAN and turn it on.
  • There are several ways to get the ip address of your pi, the easiest one is to download Fing for your iphone and let it scan your network. find the ip address of your pi and the move on to the next step.

fing

 

Configuration of the raspberry:

  • Now its time to remote connect to the raspberry via ssh. to do so type:
sudo ssh pi@<RASPBERRYIP>
  • Once you’re connected you should expand the file system to use the full space of your sd card. to do so follow the screenshots:

rasp02

rasp03

 

  • After the expansion, reboot your pi
  • Now reconnect via ssh and do some updates:
sudo apt-get update, sudo apt-get upgrade
  • When the update is done get the audio port working:
sudo amixer cset numid=3 1

rasp04

  • Now we have to install all the needed tools and libraries to get AirPlay working:
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
  • When the installation is finished, download perl net-sdp:
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
  • Since this is source code you have to compile it at first:
cd perl-net-sdpperl 
Build.PL
sudo ./Buildsudo 
./Build install
cd ..
  • The same goes for another needed tool, shairport:
git clone https://github.com/hendrikw82/shairport.git
  • Compile shairport:
cd shairport 
make
  • Okay, now lets do a test run:
./shairport.pl -a RayPi
  • If you check AirPlay on your iPhone, iPad or Mac you should see RayPi as a receiver. If so, plug some headphones or so into the audio port of the pi, connect to it and start playing music on your Apple device. Chances are good that you will hear a sound from your headphones! :-)
  •  The last step is to install shairport and register it as a daemon so it starts automatically every time you boot up your pi:
sudo make install
sudo cp shairport.init.sample /etc/init.d/shairport
cd /etc/init.dsudo chmod a+x shairport 
sudo update-rc.d shairport defaults
  • Now edit the shairport config file to give your AirPlay receiver the right name:
sudo nano shairport
  • Look for the following line:
DAEMON_ARGS="-w $PIDFILE -a <YOUR AIRPLAY NAME>“

rasp05

  • If everything is done, press CTRL+O to save the file and CTRL+X to quit nano

Finishing up:

Your raspberry is now ready to permanently use it as AirPlay receiver. If you want to connect your pi via wifi check out my tutorial!

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.