RaspbAIRy - the RaspberryPi-based Airplay Speaker

by zwuckl in Circuits > Raspberry Pi

342915 Views, 677 Favorites, 0 Comments

RaspbAIRy - the RaspberryPi-based Airplay Speaker

01.jpg
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.

Parts & Tools

IMG_0891.jpg
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
Saw
Screwdriver and screws
Soldering iron and solder
Stapler
Other typical workshop equipment

Electronics

bairy (1).png
  • 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.

Installation

xd3io-R-Pi_Logo.png
  • 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 https://github.com/njh/perl-net-sdp.git 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 https://github.com/albertz/shairport.git 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="/usr/local/bin/shairport.pl"
      PIDFILE=/var/run/$NAME.pid
      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

Case

P1080964.jpg
P1080967.jpg
P1080969.jpg
P1080970.jpg
P1080972.jpg
P1080973.jpg
P1080974.jpg
P1080975.jpg
P1080976.jpg
P1080978.jpg
P1080979.jpg
P1080981.jpg
P1080983.jpg
P1080985.jpg
P1080986.jpg
P1080990.jpg
P1080996.jpg
P1080997.jpg
  • 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.

Wiring

P1080999.jpg
P1090001.jpg
P1090003.jpg
P1090006.jpg
P1090008.jpg
P1090009.jpg
P1090011.jpg
P1090012.jpg
P1090013.jpg
P1090014.jpg
P1090015.jpg
P1090016.jpg
  • 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.

Final Closeups

01.jpg
02.jpg
03.jpg
04.jpg
05.jpg
06.jpg
07.jpg
08.jpg

Modifications and Future Plans

P1060123.JPG
  • 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