Introduction: RaspbAIRy - the RaspberryPi-based Airplay Speaker

About: I am a PhD student in bioinformatics interested in technology, electronics and computers with a fondness for crafts and good food.

With the delivery of my second RaspberryPi I finally got the chance to start this long-planned project:

I wanted to replace my old bathroom radio with a  more contemporary device by building a network-enabled speaker. Because I'm a user of several iDevices, the idea of making the speaker AirPlay-compatible became the basis of my further work.
After some googling I discovered James Laird's amazing shairport client for Linux. The initial installation on the RasPi worked like a charm, so I decided to take the project one step further by making it wireless. With a little help from Google again and some twiddling I finally got it to work and started writing this Instructable.

Have fun reading how it all went down and maybe build your own version of the raspbAIRy.

Step 1: Parts & Tools

This Instructable is based on the metric system and originates from Germany, thus dimensions are in millimeters and line voltage is 220V. I got most of the parts at my local electronics retailer or already had them laying around. The RasPi was ordered online at Farnell, the speaker cloth was found on eBay and the MDF was bought and already cut in width at a local hardware store.
  • RaspberryPi
RaspberryPi Model B with SD Card
Supported USB WiFi Adapter, like my LogiLink Nano Adapter
220V AC to 5V DC power supply
  • Sound
3,5W Mono Amplifier, in my case a Kemo M031N
Broadband speaker
White LED, 5mm
5x 475Ω resistors
2x 20kΩ resistors
10kΩ rotary potentiometer with knob
Power switch
Dip switch
3,5 mm audio socket and cable
220V AC to 12V DC power supply
Cable with power plug
  • Case
250 x 250 mm speaker cloth
1500 x 200 x 5 mm Medium Density Fibreboard (MDF)
600 x 200 mm artificial leather
Wood glue
  • Tools
Screwdriver and screws
Soldering iron and solder
Other typical workshop equipment

Step 2: Electronics

  • Stereo to Mono
Following the great guide of Dennis Bohn "Why not Wye", I chose to integrate an easy summing circuit or actually two, one for each audio input.
  • Input Switch
A simple dip switch (ON-ON) for selecting the audio input for the amp. I added this to be able to connect other audio sources and to use the device as a 'normal' speaker, independent from the RasPi.
  • Mono Amp and speaker
The selected amplifier was wired according to the datasheet. Basically it accepts input voltages from 5 to 12V DC and a mono input signal through an optional potentiometer for volume control. I connected a 8Ω broadband speaker, which sounds surprisingly good for only 10€.
  • Power Supply
I chose to integrate two separate power units to be able to independently turn off the amp/speaker while keeping the RasPi running. This is mainly due to the boot time of Raspbian of about 30-40 seconds. Because I had them laying around I used two plug-in adapters, one providing 5V DC (max. 2500mA) for the RasPi and the other providing 12V DC (max. 1500mA) for the whole audio setup.

Step 3: Installation

  • Raspbian 'wheezy'
After downloading the official image and following these easy steps, the RasPi was set up in a few minutes.
The following steps require some basic command line skills but if you stick to the linked tutorials you should be good.
  • Shairport
I found two different documentations to be of great help, one in English and one in German. These include nearly the same steps:
  1. Install some packages and their dependencies, that shairport uses, via apt-get
  2. Get shairport and the perl module Net::sdp via git
  3. Install shairport as a service and make it run at startup
  • Wifi
Support for some Wifi chipsets is already included in Raspbian. I found a USB Adapter with the RT5370 chipset for a few bugs at a local electronics store. In addition to its Linux ability it is also very economical on power. It therefore can be driven on one of the onboard USB ports of the RasPi. A video tutorial from Adafruit then did the trick for me.
  • Here is what I did (commands in italic):
  1. Updated apt-get
    • sudo apt-get update
  2. Installed vim (personal preference)
    • sudo apt-get install vim
  3. List USB devices to get infos on wifi dongle
    • $ lsusb
  4. Installed Ralink-Firmware
    • $ sudo apt-get install firmware-ralink
  5. Modified the interfaces config
    • $ sudo vim /etc/network/interfaces
    • auto lo
      iface lo inet loopback
      iface eth0 inet dhcp
      auto wlan0
      iface wlan0 inet dhcp
      wpa-ssid "my_ssid"
      wpa-psk "my_password"
  6. Reboot
    • $ sudo reboot
  7. Checked that wifi is running
    • $ ifconfig -a
  8. Installed all dependencies for shairport
    • $ sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils
  9. Installed Net::SDP for iOS6 support
    • $ git clone perl-net-sdp
    • $ cd perl-net-sdp
    • $ perl Build.PL
    • $ sudo ./Build
    • $ sudo ./Build test
    • $ sudo ./Build install
    • $ cd ..
  10. Got shairport from git
    • $ sudo git clone shairport
  11. Changed to shairport directory and compiled
    • $ cd shairport/
    • $ sudo make
    • $ sudo make install
  12. Copied the init sample to startup folder and set rights
    • $ sudo cp shairport.init.sample /etc/init.d/shairport
    • $ cd /etc/init.d
    • $ sudo chmod a+x shairport
    • $ sudo update-rc.d shairport defaults
  13. Changed name of shairport client
    • $ sudo vim shairport
    • changed the following lines:
    • NAME=ShairPort
      DAEMON_ARGS="-w $PIDFILE -a raspbAIRy"
  14. Set audio output to line
    • $ amixer cset numid=3 1
  15. Started shairport
    • $ sudo /etc/init.d/shairport start

Step 4: Case

  • The case is a simple 200 x 200 x 210mm cube-shaped box made of 5mm MDF, with the side parts being mitered with a 45° angle.
  • On the front I made cutouts for the speaker, the volume knob and the power LED. It was covered with light-grey speaker cloth  and clipped on with wooden dowels.
  • The back shows holes for the power chord, power switch, audio jack and input switch and is held in place by wood screws.

Step 5: Wiring

  • All of the audio wiring was done according to Step 2. The RaspberryPi got its own 5V DC power supply with a soldered-on MicroUSB connector.

Step 6: Final Closeups

Step 7: Modifications and Future Plans

  • Switching from Raspbian to ArchLinux to decrease boot time from ~35 to 6 seconds
  • Adding an audio output socket and switch
  • Adding bluetooth support for non-Airplay devices
A/V Contest

Second Prize in the
A/V Contest

Instructables Design Competition

Finalist in the
Instructables Design Competition

UP! Contest

Participated in the
UP! Contest