QBee - AirPlay / MPD Integrated Speaker




Introduction: QBee - AirPlay / MPD Integrated Speaker

This is a complete walkthrough on how to build a full featured standalone AirPlay and MPD (Music Player Daemon) sound system. You will find instructions on how to carry out each of these steps:

  • The server part. It is based on ArchLinux running on a Raspberry Pi. It is running Shairport (AirPlay emulator) and an MPD server.
  • The hardware part. This include the casing, speaker set-up as well as all complementary parts and electronics (such as the LCD, switches, etc.).

These two parts are quite seperate so this will come in handy if you just want to set up the server and plug in ready-made speakers.

I paid roughly $280 for all the spare parts so be aware that this won't save you any money comparing to buying AirPlay speakers. This will however be more flexible and the speakers and amplifier will be of much higher quality than what you can find for this price.

Since this is quite a big project, you might be wanting to deviate from what I did. I will be detailing how I selected and planned the whole setup based on what I wanted so you can choose audio equipment and design to your liking.


  • Height 17cm
  • Weight 47cm
  • Depth 19 cm


  • Raspberry pi running on ArchLinux with Shairport (AirPlay) and MPD server
  • Hifiberry DAC
  • 50W stereo amplifier (TPA3116)
  • 2x 15Wrms HiVi B3S speakers
  • 2x8 LCD screen displaying artist and track information
  • Volume potentiometer
  • External Ethernet and USB port (for WiFi adapter)
  • Silent fan
  • 3.5mm input jack with switch
  • Status LEDs

Warning: This involves manipulating high voltage. As in any such project, take the necessary precautions while testing and using your setup so you don't damage yourself of your equipment.

Step 1: Select Speakers and Equipments

In order to specify the dimension of the box, you first need to decide what kind of equipment you want to put in.


Since I read a lot of good stuff about the 2x50W TPA3116 amplifier (works with 24V), I decided to go that one. It's cheap, you can get it from roughly $18 and has plenty of power for a small box.


Since this is 50W peak, 15Wrms speaker were a good choice (30W peak). In general, it's better to settle for lower wattage speakers than what the amplifier is capable of to prevent having capped input on the speakers.

Since I used magnets to secure the cover on the front, I preferred to choose shielded speakers.

The next thing to look at is whether the speakers need a closed chamber of will need a bass reflex setup. I preferred to have a closed box since it is easier to build.

Since this will be standalone, carefully note the cutoff frequency for your speakers, especially if you want decent bass. I selected the B3S HiVi Research speakers that require a volume of 2L and have a cutoff frequency of about 80Hz (which is high but fine once you get used to it).

Power supplies

The next thing you want to look at is the power supply to power your amplifier. Since I have a 2x50W amp, I went for a 24V 5A (120W) PSU. LED PSUs tend to be pretty stable so they are a good bet. Again, take some margin with the amplifier power to make sure it doesn't draw too much power from the PSU.

In addition to this, you need something to power up your Raspberry Pi. It's better to completely isolate the amplified and low voltage circuits to prevent any parasites. I added a 5V PSU for the Pi and a DC-DC converter to power the fan and the LCD backlight from the 24V PSU.


Because the audio output from the Pi isn't that good, you will want to use a DAC. I2C DACs don't take much space and aren't that expensive so they are a good choice. I went the the Hifiberry analog DAC.

The rest

You also need to fit the Pi. The rest of the equipment doesn't take up much space so at this point you don't really have to bother about it. You just need to make sure you can fit in a fan if you want. I used a 60mm 12V fan powered on ~6V (it spins at a lower speed and makes less noise). Noiseblocker or Noctua fans are really silent and you have to stick your ear on the box to hear them.

Step 2: Choosing the Design and Dimensions

Each speaker needs a volume of 2L. A box of 16x14x10cm totals to 2.24L, which is good excluding the volume taken up by the speaker itself.

The box is made up of 2 speaker chambers surrounding a larger chamber for the equipment. The biggest object is the power supply (20cm) so an inner volume with a width of 22cm is suitable. With the above dimensions for the speaker chambers, the rest of the equipment will fit.

I used a structure made with MDF panels for the speaker boxes and plywood to cover up and make a nice finish.

The MDF is 1cm thick and the plywood 5mm thick. If the thickness of the material you use are different, you will have to adjust the dimensions below.

To sum up, here are the dimensions of the pieces you need to cut:


  • 2x 46x16cm (front and back panels)
  • 4x 16x10cm (top and bottom panels)
  • 4x 16x16cm (side and inner panels)


  • 2x 47x17cm (front and back panels)
  • 2x 47x19cm (top and bottom panels)
  • 2x 19x17cm (side panels)

Step 3: Circuit

I will not go into much detail on the high voltage part of the circuit, just make sure you take necessary precautions when testing. The high voltage powers the 24V and the 5V PSUs. The 24V PSU powers the amplifier and the DC-DC step down converter. You need to add a switch (and optionally fuse) on the high voltage phase. You also need to add a switch to short the relay when playing from the jack.

GPIO pins

Most the GPIO pins will be used to control the LCD. One will be used to turn on the relay, thus switching on the 24V PSU. We will also use a +5V and ground pin.

Relay control

This is a classical bit of circuit that you can use whenever you want to switch an electromechanical relay from a Pi. The diode is here to make sure no voltage spike go back to the transistor and Pi. The transistor basically boost the current that is fed in its base branch. The transistor I used has a gain of around 600. If the base current is enough, it will saturate the transistor and thus the voltage across its emitter and collector will be zero.

The current needed by the relay is computed from its resistor and voltage (I = U/R). The voltage is 5V and the resistor is 70 Ohms. The needed current is at least 71 mA, which means we need a current of at least 0.118 mA coming into the transistor. We can control this using a resistance between the GPIO and the transistor. Using R = U/I (U = 3.3V), we get R <= 28 kOhms. We can put a 10 kOhms resistor to make sure the transistor is saturated.

LCD control

We also use a transistor to control the voltage input of the LCD. A 1 kOhms resistor is needed to limit the current that can be drawn from the Pi to prevent damage, it will be more than enough for the LCD. Here is the pin correspondence for a 16 pin LCD:

  • 1: ground
  • 2: 5 or 3.3V depending on what you choose
  • 3: contrast
  • 4: RS, register select (high=data, low=command)
  • 5: R/W (low=write, high=read), we will set this to ground
  • 6: E, Enable
  • 7-14: bit pins (we will use only the 4 last in a 4 bit operation)
  • 15: LED anode (+)
  • 16: LED cathode (-)

To be able to adjust the contrast, we will connect the pin 3 on a potentiometer. The bit data, RS and E cables go straight from the Pi to the LCD. The pin 2 and one end of the potentiometer are connected to the collector branch of the transistor. The LED pins are connected to the DC-DC step down converter which is itself fed by the 24V PSU (it will thus be turned on by the relay). You have to pick a resistor, or use a potentiometer that will dim a bit the backlight to your liking. I used a 10kOhms resistor.

The rest of the information you need to map your wirings are on the schematic. I soldered all this on a regular protoboard.


You have to solder a header on the I2C port of the Pi to feed the Hifiberry. The analog signal comes from 3 little connections on the side of the Hifiberry (you have to solder something here too). This goes to the dip switch along with the cables from the 3.5mm input. I takes 3 pin on the switch to switch one channel. We have to switch left and right so you need a 6-pin switch. The output goes to the potentiometer, and then to the amplifier. When we use the input jack, we need to short the relay to turn on the amplifier. I added a little switch on the back to do this.

Step 4: Assembling the Box

Carefully note the order of the steps below. If you glue a piece of wood too early, it might be hard to do some things later on.

MDF structure

Once you have cut the pieces of wood, the first part will be assembling the MDF. The easiest way to do this is to put one long panel flat and glue the 8 other smaller pieces on it (4 panels per speaker box), holding everything together with braces. I used Epoxy glue for this step since it will hold very well. As you are doing this, be careful to finely adjust the pieces together so it forms a nice rectangle. Since we are going to glue plywood panels on this structure, small imperfections in alignment may become problematic.

Once this has dried up, you should cut out acoustic foam to the right dimensions that will be inserted later on. you can glue the other (front or back panel). Sand of the rough edges and make sure everything is flush.

Plywood finish

So the panels will assemble nicely, bevel the inner edges at a 45 degree angle.

Before we glue them on the box, we need to work on the front panel to make the holes and sockets to fit the controls and LEDs. Drill a rectangle hole that in which to fit the LCD in the center as well as holes to accommodate the potentiometer, dip switch, LEDs and 3.5mm input. Also drill hollows that will allow them to nicely fit from the outside (see picture).

Once you have done this, you need to prepare a small wooden plate that will hold together the controls with appropriate holes and sockets for each part. Fit the parts in the front panel, place the plate on them and put hot glue between the parts and the wooden plate to hold everything together. Remove the pate (and the controls that should be glued on it), and put epoxy glue to permanently fix them.

You need to cut out a part of the MDF front panel so that your wooden plate with your controls can reach the plywood panel. Drill holes on the front plywood panel (on the inner side, not all the way through) in which you will put 4 magnets that will serve to hold the cover.

You can now glue the front and back panels to the box, carefully watching the alignment. The plywood should be 5mm larger than the MDF on each border.

Take out a bit of the back panel (both MDF and plywood) to accommodate the rear controls and inputs. You should take out a larger part of plywood as you can see on the pictures.

Glue the top and side panels.

Finishing up

The bottom panel will be screwed with the rubber feet to have access to the equipment. Drill holes and glue the 4 screw pitches on the MDF with epoxy (not all the way through, the speaker boxes need to be closed!).

Drill 4 holes for the vents and glue them in.

Drill your holes for your speaker as well as 2 inner holes to pass the audio cables from the amplifier to the speakers. Position the cables and put glue in the extra space in the holes. You can also insert the acoustic foam inside the speaker boxes.

Cut out a piece of plywood that will hold all the rear controls and glue it on the bottom plywood panel.

The cover

To protect the speakers, we are going to build a nice cover made of acoustic cloth that will neatly stick to the box using magnets. Build a frame based on the position of the four magnets you placed on the front panel. Note that the frame is not a rectangle because of the front controls so it is not that simple. Make sure it is plane when you glue it together.

Attach the acoustic cloth with staples. Be careful on the corners just above the controls, it could have be done better than what you see on the pictures.

I'm not going to go in details in how to position the equipment inside. You can look at the pictures to see how I have done it and do something similar.

Step 5: Setting Up the Pi

Before you start, you can find my Python script to control the amplifier PSU and the LCD with the GPIO pins here: https://github.com/gpajot/qbee-gpio. It is basically a bunch of threads that listen to sound output, turn on the PSU, fetch the metadata depending on the source and display it on the LCD. There are some configuration variables to be defined based on your setup. You can also enable the debug mode if you need to set up another audio source or if something is not working

Instructables doesn't handle well URLs in code snippets and they kept coming back so I had to remove the protocol bit, be careful when you paste this in...

Initial setup

Grab the ArchLinux image from here: http://archlinuxarm.org/platforms/armv6/raspberry-pi.

If you are on Unix based system, copy it on your SD card with these commands:

diskutil list
diskutil unmountDisk /dev/disk#
sudo dd bs=1m if=Downloads/ArchLinuxARM*.img of=/dev/disk#

I didn't bother to create another account than root, if you do, you will need to use sudo for some of these commands.

Plug in the Wifi adapter, start the Pi, perform a full system upgrade and install wireless tools and check the adapter:

pacman -Syu
pacman -S wireless_tools wpa_actiond
ip link set wlan0 up

Get a key for your access point to set up automatic connection:

wpa_passphrase [ssid] [passphrase]

Create a service file "/etc/netctl/{{filename}}" and fill in your information:


Enable automatic connection:

netctl enable {{FILENAME}}

Change the hostname if you want:

nano /etc/hostname

Setup automatic time adjustment:

timedatectl set-timezone Europe/Paris
timedatectl set-ntp 1
ntpd -u ntp:ntp
ntpd -qg

Add this line to the crontab (crontab -e):

@reboot ntpd -qg

GPIO and Python

I will use Python to control the GPIOs, install it with the necessary packages. pyinotify will be used to detect changes in sound output.

pacman -S python2 python-distribute gcc
ln -sf /usr/bin/python2 /usr/bin/python
wget pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO--{{VERSION}}.tar.gz
tar xf RPi.GPIO-{{VERSION}}.tar.gz
sudo python setup.py install
git clone github.com/seb-m/pyinotify
cd pyinotify
sudo python setup.py install

Create a service file to start the python script automatically:

Description=Python GPIO controller




Install Shairport, dependencies, tools and sound packages:

pacman -S file
pacman -S base-devel
pacman -S abs
pacman -S git wget
pacman -S avahi libao openssl perl-crypt-openssl-rsa perl-io-socket-inet6 perl-libwww
pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins lsof

Install perl-net-sdp from AUR repository (use --no-check-certificate for wget if not working):

wget aur.archlinux.org/packages/pe/perl-net-sdp/perl-net-sdp.tar.gz
tar -zxvf perl-net-sdp.tar.gz
cd perl-net-sdp
makepkg -s —asroot
pacman -U perl-net-sdp.pkg.tar.gz

Restart, then build Shaiport, test it and install it if everythong is working:

git clone github.com/abrasive/shairport.git shairport
cd shairport
./shairport -a Qbee
make install

Create the service file to start up automatically (/etc/systemd/system/shaiport.service). The -M argument is used to get the metadata for the playing title (you first need to create the directory). -b is to set the buffer and -d is to launch it as a daemon.

Description=Startup ShairPort (Apple AirPlay)

ExecStart=/usr/local/bin/shairport -a QBee -M /var/lib/shairport -b 256 -d
ExecStop=/usr/bin/killall shairport


Enable the services:

systemctl enable avahi-daemon
systemctl enable shairport


Install MPD:

pacman -S mpd mpc
usermod -G audio -a mpd

Create directories and add the line to mount the NAS (if you have one, or an external drive) on /etc/fstab:

mkdir -p /mnt/nas/music
chown -R mpd:audio /mnt/nas
pacman -S cifs-utils
//***.***.*.**/path/to/music /mnt/nas/music cifs ro,guest 0 0

Here is my configuration file (/etc/mpd.conf):

user "mpd"<br>pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"
music_directory "/mnt/nas/music"

audio_output {
enabled         "yes"
type            "alsa"
name            "HiFiBerry"
device          "hw:0,0"
dsd_usb         "yes"

You also have to create some files:

touch /var/lib/mpd/mpd.db
touch /var/lib/mpd/mpdstate
mkdir /var/lib/mpd/playlists

Now type this in and wait for the library to update. It will take a while and the db file won't be updated until it is done.

mpc update

You should now be all set to test everything!

Step 6: Shopping List

To make things easier, here is a list of all the parts I used, with a rough estimate of what I paid.

Electronics ($100)

  • Raspberry Pi
  • 8GB SD card (SanDisk Extreme or better)
  • Wifi adapter
  • 8x2 16pin 3.3V LCD
  • 10-50k potentiometer + knob
  • 10-20k potentiometer trimmer
  • Dip switch
  • 3.5mm jack input
  • USB extender cable (male + female)
  • Ethernet cable and extender
  • Red LED
  • Green LED
  • Protoboard
  • 2 transistors (NPN BC547B)
  • 5V electromechanical relay
  • 1x 1kOhm 1/4W resistor
  • 2x 10kOhm 1/4W resistor
  • 2x 22kOhms 1/4W resistors
  • Diode (1N4007)
  • 1 IDE or GPIO cable
  • 12V (very) silent 60mm fan (NoiseBlocker or Noctua)
  • Various cables and wires

Power ($35)

  • 24V 120W PSU
  • 5V PSU (1.2A min)
  • DC-DC step down converter
  • 2 rocker switches
  • Fuse
  • 2-pin power input and cable

Audio ($100)

  • 2x 15Wrms wide band speakers (HiVi Research B3S)
  • TPA3116 2x50W 24V amplifier
  • Hifiberry DAC (analog, plain version, no header soldered + 2x13 stacking pin)

Hardware ($40)

  • MDF 1cm thick panel
  • 5mm thick plywood panel
  • Rubber feet, screws and screw pitch
  • Acoustic cloth and foam
  • Wooden cleat (for inner support and cover)
  • Assorted screws and pitches
  • Wood wax (yellow/white) (for a nicer finish)
  • 4 metal vents
  • 8 magnets (rare earth magnets are generally strong and have a low range so they are perfect for this)



    • Tiny Home Contest

      Tiny Home Contest
    • Fix It! Contest

      Fix It! Contest
    • Metalworking Contest

      Metalworking Contest

    3 Discussions

    Killer Project! Been looking at doing something like this for quite a while. Would be nice to upgrade the amp and add additional channels (bass output, side-face speakers for 'surround', etc), would also love to explore additional input and display options, though im sure thats jumping a bit far for most DIY'rs ;)
    Love the instructions, thank you for the scripts - very well done! (2 thumbs and a couple of toes way-way up!)

    Thanks for sharing.

    Make a video, how to work with your tablet or phone (air, mpd)

    thanks for sharing your diagrams with us and also for letting us know the costs of this! awesome project!