RaspbAIRy - the RaspberryPi-based Airplay Speaker

329,403

661

52

Published

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
Saw
Screwdriver and screws
Soldering iron and solder
Stapler
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 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

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

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Casting Contest

      Casting Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    52 Comments

    that box !!!!! lovely

    Hi, can I ask you why a mono amp? Doesn't this kill the stero signal?

    1 reply

    In principle, you're right. But I wanted to keep the build relatively small and at the same time have enough room for a 10cm speaker. This is why I chose the summing circuit, which sums both audio channels and inputs it to the amp.

    Can this be combined with a bluetooth capability? For when you are outside

    Hi!

    Is there a possibility that this can stream HD Videos from any android or IOS device??? I would love to do this.

    I mean, can you use one wallwart?

    Sorry for the late reply, R (right) and L (left) are the + voltage lines of the stereo audio signal.

    I am sorry to say this inspite of detailed steps for building the project there is no information given regarding how to use the project /operate the project or what this airplay speaker is capable of like whether it produce any sound/ music? nothing clearly explained???

    1 reply

    Hey ramanar, I wasn't aware that this needed to be explicitly stated. This speaker provides Airplay (http://en.wikipedia.org/wiki/AirPlay) audio playback functionality. After booting you simply pair it with any given state-of-the-art Apple device for audio stream. Thus, the speaker is indeed capable of (re)producing the sound from your, let's say, iPhone or iPad.

    Something you may want to add: setting up your OS as read-only would allow you to safely turn it off quickly, without having to ssh and shutdown properly. Since you ensure there is never any write, there is no risk to shut it down during a write that leaves your SD card corrupted and your system unable to boot.

    I followed this for Arch Linux, there are tutorials for Raspbian also if you search:

    http://ruiabreu.org/2013-06-02-booting-raspberry-p...

    I'm sure some people actually turn it off brutally without configuring it as read-only, but doing that you never know when you'll corrupt your SD card!

    1 reply

    Good thought. Thanks for the input :)

    I'm building that in an old radio I have laying around :)

    How did you connect the 2 power blocs by cable, did you cut the pins that usually go to the wall outlet or something?

    1 reply

    Exactly. I simply sawed off the basis of the case including the pins, cut the wires behind and soldered extension wires on.

    Really cool project!

    I have two Raspberry Pi's lying around (one is model A and the other B).

    I bought the A by mistake and I think I can do something similar to your project with it, since it doesn't need the Ethernet port and only one USB port.

    The main difference is that I want to make it compatible with android.

    2 replies

    "Compatible with Android" doesn't mean much, the real question is the application you want to use. Some Android application actually support output to Airplay, like DS Audio that I'm using to stream from my Synology NAS.

    Or, maybe you want to make a generic blutooth speaker:

    https://www.instructables.com/id/Turn-your-Raspberry-Pi-into-a-Portable-Bluetooth-A/

    i realized two similar project with both raspberrys Model A and Model B, both are working and the updated firmware makes the audio connector working good. usb is for the ethermax adapter. it is working fine.

    Hi, I really like this and plan on doing something similar but inside a vintage radio. Are you happy with the way it sounds? Is it loud enough? Thanks,