Raspberry Pi Zero AirPlay Speaker


Looking for a new project to build around the Raspberry Pi Zero, I came across the pHAT DAC from Pimoroni. This little add-on board adds audio playback capabilities to the Pi Zero. Because the pHAT uses the GPIO pins, the USB OTG port remains available for a wifi dongle. Perfect for a small wireless speaker project!


The project is fairly simple and requires following components:

The Raspberry Pi Zero is obviously the brains of the project and will run the Shairport software to wirelessly stream music to. The pHAT DAC is a neat little add-on board adding audio to the Raspberry Pi. It has a jack output, and the possibility to add RCA connectors to it. The fact that the RCA connectors are not presoldered is a bonus, as it exposes the audio lines and keeps a low profile. A small mono amplifier from Adafruit then takes the audio from the pHAT and amplifies it (what else?), playing audio from the speaker. A wifi dongle connected via the USB OTG port provides wireless network connectivity for streaming.

I decided to make a mono speaker to keep things smaller. Making this project with stereo support would imply having a second speaker and replace the mono amplifier by a stereo one.

Screen Shot 2016-01-20 at 22.36.19IMG_0674

I know this isn’t the nicest way to convert stereo to mono (at all?), but it works. I tried to tackle the problem from a software point of view by downmixing the stereo to mono, but with no success. If I do manage to find a proper solution, ideally in software, I’ll be sure to update this post. If anyone has tips on how to achieve this in a simple way, feel free to leave it in the comments!


On the software side, nothing too difficult either.

I started off from the latest Raspbian Jessie image which can be downloaded from the official Raspberry Pi website.

Using “dd”, I put the downloaded image on a 8Gb microSD card and then used it to boot the Pi Zero from.

sudo diskutil list
sudo diskutil unmountDisk /dev/disk3
sudo dd if=Downloads/2015-11-21-raspbian-jessie.img of=/dev/disk3 bs=1m
sudo diskutil unmountDisk /dev/disk3

Once booted, I set up the wifi in the graphical desktop environment by selecting the correct SSID and entering the wifi password. With the Pi Zero connected to the network, I could update the software.

sudo apt-get update
sudo apt-get upgrade

Then came the time to install the project specific software: support for the pHAT DAC and the AirPlay software.


A tutorial on how to install and use the pHAT DAC is available on the Pimoroni website. I did things slightly differently though, as I didn’t disable the default sound driver.

Device-tree overlay is used to describe hardware. As the pHAT DAC uses the same hardware as the HiFi Berry, the same overlay can be used by appending the following lines to the config file:

pi@raspberrypi:~ $ sudo nano /boot/config.txt


After rebooting, I listed the audio devices using the “aplay” application, and there it was: card 1 – HiFi Berry.

pi@raspberrypi:~ $ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

To make it the default for audio playout, I updated the asound.conf file and replaced every reference to “card 0” by “card 1”.

pi@raspberrypi:~ $ sudo nano /etc/asound.conf

pcm.!default {
  type hw
  card 1

ctl.!default {
  type hw
  card 1

A final reboot ensured everything was applied.


Shairport is an Airtunes emulator, allowing compatible iOS devices or iTunes to stream audio to the device running it.

A few dependencies need to be met before Shairport can be installed and run.

pi@raspberrypi:~ $ sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
pi@raspberrypi:~ $ git clone perl-net-sdp
pi@raspberrypi:~ $ cd perl-net-sdp/
pi@raspberrypi:~/perl-net-sdp $ perl Build.PL
pi@raspberrypi:~/perl-net-sdp $ sudo ./Build
pi@raspberrypi:~/perl-net-sdp $ sudo ./Build test
pi@raspberrypi:~/perl-net-sdp $ sudo ./Build install

With the dependencies taken care of, the actual Shairport software can be installed.

pi@raspberrypi:~ $ git clone
pi@raspberrypi:~ $ cd shairport/
pi@raspberrypi:~/shairport $ make

At this stage, it’s possible to test if everything was installed properly by manually running the script.

pi@raspberrypi:~/shairport $ ./ -a AirPi

Afetr confirming everything works as expected, the shairport application can be daemonized in order to have it automatically start at boot.

pi@raspberrypi:~/shairport $ sudo make install
pi@raspberrypi:~/shairport $ sudo cp shairport.init.sample /etc/init.d/shairport
pi@raspberrypi:~/shairport $ sudo chmod +x /etc/init.d/shairport
pi@raspberrypi:~/shairport $ sudo update-rc.d shairport defaults

Finally, the shairport file needs to be modified in order to specify the name of the AirPlay device. This could be anything you want. In my case, I picked something generic, such as “AirPi”.

pi@raspberrypi:~/shairport $ sudo nano /etc/init.d/shairport


Reboot the Pi. Shairport should be running automatically.


Time to package the working AirPlay speaker into something nice, by making a good looking enclosure for it.

This was actually the hardest part of the project. Mainly because I wanted to make it out of wood and with a slightly tricky shape. It meant doing some maths before cutting pieces at the right length using the miter saw and then ensuring the correct angles were cut as well in order to properly connect the pieces. As I’m not a woodworker, and the tools at my disposal are not the most suited either, the results are not always as accurate as you’d expect. That’s where sanding paper and wood filler come to the rescue …

Screen Shot 2016-01-21 at 20.07.53 Screen Shot 2016-01-21 at 20.05.28

Some accents were given to the build by adding 3D printed parts: the side panels and the speaker grill. One of the side panels was not glued into place and can be removed if needed, in order to access the electronics. I was hesitating to paint the 3D printed parts in a different color for a chrome or brass look, but ended up leaving the pieces as is. It gives the build a little funky side, no ?


Like the project? What else would you make with a Pi Zero? Let me know in the comments!



23 thoughts on “Raspberry Pi Zero AirPlay Speaker

    1. I’m not sure, I haven’t tried to AirPlay to multiple speakers at once.

      From a first quick search, it looks like AirPlay from an iOS device (iPhone, iPad, iPod, …) does not work to multiple devices out of the box. A third party app seems to be required, and even then there would be limitations it seems. AirPlay to multiple devices from a PC or MAC via iTunes seems possible though.

    1. You can control the volume from your smartphone via AirPlay, but if really needed, you could add two buttons connected to free GPIO pins and have them trigger the command for volume up and down.

    1. This one could easily be made portable if powered from a battery. I didn’t know about the USR-S12, something worth looking into 🙂
      If you end up building one, I’d love to see the result!

  1. Raspbian is now using systemd instead of sysV init script.
    Here is a sample systemd configuration:

    # cat /etc/systemd/system/shairport.service
    Description=shairport – Airtunes emulator avahi-daemon.service

    ExecStart=/usr/local/bin/ $SHAIRPORT_OPTS


    # cat /etc/default/shairport

    # systemctl start shairport.service

    1. Hi Ben
      I put in these systemd config files, and I can start and stop shairport and see its status.
      However when I try sudo systemctl enable shairport.service to get the ssytem to start automatically on boot up I get an error:
      Failed to execute operationL invalid argument.

      I’ve triple checked the config files. Any idea how I resolve this?

  2. Frederick,

    Jeetje wat maak jij gave projecten, erg inspirerend!

    I am building a retro-radio and i have the same amp and I succeed in down-mixing the audio to mono with the following settings:

    nano /etc/asound.conf

    pcm.!default makemono

    pcm.makemono {
    type route
    slave.pcm “hw:0”
    ttable {
    0.0 1 # in-channel 0, out-channel 0, 100% volume
    1.0 1 # in-channel 1, out-channel 0, 100% volume

    By the way you should try Very light program with a webinterface and also the options for Airplay and Upnp. I am using this in all my Radio-projects.



    1. Hey Harry, thanks! Het is net de bedoeling om mensen te inspireren om zelf dingen te bouwen en uit te proberen. Ik ben blij dat het lukt 🙂

      I tried something similar for the downmixing but couldn’t quite get it to work. I’ll have a look at your snippet and see how it differs from what I had.

      Thanks for the tip on Archphile, it looks interesting!!

  3. The photograph differs from your schematic overlay in the sense that there is a grey cable going from “L” output on the Phat DAC to a pin that I am unable to see on the amp breakout. Am I correct to assume it goes to A- on the amp chip? All help appreciated 🙂

    1. The grey wire is the GND connection. On the drawing, I’ve connected it to the GPIO header, rather than the L channel’s GND pin on the picture.

Leave a Reply

Your email address will not be published. Required fields are marked *