---
title: "Install Shairport Sync with AirPlay 2 on Raspberry Pi Zero 2 W and Waveshare PCM5122 DAC"
description: "A comprehensive, step-by-step guide to building a high-fidelity AirPlay 2 receiver using a Raspberry Pi Zero 2 W and the Waveshare PCM5122 HiFi DAC."
canonical_url: "https://hannoeru.me/posts/install-shairport-sync-airplay-2-raspberry-pi-zero-2-w-waveshare-pcm5122"
---

> Index of every page on this site: [llms.txt](https://hannoeru.me/llms.txt)

The Raspberry Pi Zero 2 W may be tiny, but paired with a proper DAC it becomes a surprisingly capable network audio streamer. In this guide, we'll build a **high-fidelity AirPlay 2 receiver** using **Shairport Sync**, enabling multi-room playback, tight clock synchronization, and excellent resampling quality.

This setup is ideal if you want an affordable, always-on AirPlay endpoint that integrates seamlessly with Apple devices—without compromising audio quality.

---

## 🛠 Hardware Requirements

You'll need the following components:

- **Raspberry Pi Zero 2 W**
- **Waveshare PCM5122 HiFi I2S DAC**<br />

*(exposed to ALSA as IQaudIODAC)*
- **MicroSD Card** (8 GB or larger)
- Power supply and speakers / amplifier

---

## Step 1: Flash and Boot Raspberry Pi OS

1. **Flash the OS**<br />


Use the official [Raspberry Pi Imager](https://www.raspberrypi.com/software/) and select **Raspberry Pi OS Lite (64-bit)**.
2. **Pre-configure the Image**<br />


Before flashing, click the ⚙️ **Edit Settings** icon and configure:
  - **Hostname** (for example: `hifi-pi`)
  - **Enable SSH**
  - **Wi-Fi credentials**
3. **Boot the Pi**<br />


Attach the Waveshare PCM5122 DAC to the GPIO header, insert the SD card, and power on the Pi.
4. **Connect via SSH**```bash
ssh pi@hifi-pi.local
```

> Note: recent versions of Raspberry Pi Imager require you to define a username in the OS customization settings — the implicit `pi` user no longer exists. Set your username there (for example `pi`).

---

## Hardware Verification

The Waveshare PCM5122 Audio Board carries a HAT EEPROM, so the firmware loads its overlay automatically at boot. Verify that ALSA detects it correctly:

```bash
aplay -l
```

You should see output similar to:

```text
card 1: IQaudIODAC [IQaudIODAC], device 0: IQaudIO DAC HiFi pcm512x-hifi-0
```

If the device appears as shown above, the hardware is ready.

> Troubleshooting: if the card is not listed, add `dtoverlay=iqaudio-dacplus` to the `[all]` section of `/boot/firmware/config.txt` and reboot — older revisions of the board ship without an EEPROM.

---

## Step 2: Install Build Dependencies

Shairport Sync with AirPlay 2 support requires several libraries for audio processing, encryption, and networking. Update your system and install the required packages:

```bash
sudo apt update && sudo apt upgrade -y
sudo apt install --no-install-recommends \
  build-essential git autoconf automake libtool \
  libpopt-dev libconfig-dev libasound2-dev \
  avahi-daemon libavahi-client-dev \
  libssl-dev libsoxr-dev \
  libplist-dev libsodium-dev \
  libavutil-dev libavcodec-dev libavformat-dev \
  uuid-dev libgcrypt-dev xxd
```

---

## Step 3: Install NQPTP (Required for AirPlay 2)

AirPlay 2 relies on **NQPTP (Not Quite Precision Time Protocol)** for accurate clock synchronization across devices. Without it, multi-room playback will not work correctly.

```bash
cd ~
git clone https://github.com/mikebrady/nqptp.git
cd nqptp
autoreconf -fi
./configure --with-systemd-startup
make
sudo make install
sudo systemctl enable nqptp
sudo systemctl start nqptp
```

---

## Step 4: Build Shairport Sync with AirPlay 2 Support

Now we compile Shairport Sync from source to enable AirPlay 2, metadata, and Systemd integration.

1. **Clone the Repository**

```bash
cd ~
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
```

1. **Configure and Build**

```bash
autoreconf -fi
./configure \
  --sysconfdir=/etc \
  --with-alsa \
  --with-soxr \
  --with-avahi \
  --with-ssl=openssl \
  --with-systemd \
  --with-airplay-2 \
  --with-metadata \
  --with-systemdsystemunitdir=/lib/systemd/system
make
sudo make install
```

> ⚠️ The `autoreconf` step can take a while on the Pi Zero 2 W. This is normal—grab a coffee and let it finish.

---

## Step 5: Configure Shairport Sync

Next, we'll configure Shairport Sync for stable, high-quality output on the PCM5122 DAC. The settings below come from a long-running, dropout-free setup on a Pi Zero 2 W.

1. Open the configuration file:

```bash
sudo nano /etc/shairport-sync.conf
```

1. Replace the contents with the following configuration:

```libconfig
general =
{
  name = "Living Room Pi";
  interpolation = "basic";
  volume_control_profile = "dasl_tapered";
  audio_backend_buffer_desired_length_in_seconds = 1.0;  // Increase this value as needed (e.g., 2.0, 5.0)
};

audio_backend =
{
  type = "alsa";
};

alsa =
{
  output_device = "plughw:CARD=IQaudIODAC,DEV=0";
  period_size = 8820;     // Larger values reduce underruns
  buffer_size = 44100;    // Or higher
};

airplay =
{
  enable_airplay_2 = "yes";
};

metadata =
{
  enabled = "yes";
  include_cover_art = "no";
};

diagnostics =
{
  statistics = "yes";
  log_verbosity = 0;
};
```

> Notes:
> 
> - `interpolation = "basic"` is the stable choice on the Pi Zero 2 W — it uses far less CPU than `soxr`, which matters when the same board is handling AirPlay 2 decoding. If you want maximum resampling quality and have headroom, change it to `soxr` (the build includes it).
> - Larger `period_size`/`buffer_size` values trade a little latency for fewer underruns. Tune them if you hear audio dropouts.

1. Save and exit (`Ctrl+O`, `Enter`, `Ctrl+X`).

---

## Step 6: Enable and Start the Service

Enable Shairport Sync so it starts automatically on boot:

```bash
sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync
```

You can verify its status with:

```bash
systemctl status shairport-sync
```

## Step 7: Disable Wi-Fi Power Saving (Recommended)

By default, Raspberry Pi OS enables Wi-Fi power saving to reduce energy consumption. While useful for battery-powered devices, it can cause **audio dropouts, increased latency, or AirPlay discovery issues** on always-on streamers.

For a stable AirPlay 2 experience, it's best to disable Wi-Fi power management.

To disable Wi-Fi power saving permanently, create a systemd service.

1. Create the service file:

```bash
sudo nano /etc/systemd/system/wifi-powersave-off.service
```

1. Paste the following content:

```ini
[Unit]
Description=Disable WiFi Power Save
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/iw dev wlan0 set power_save off
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
```

1. Enable and start the service:

```bash
sudo systemctl daemon-reload
sudo systemctl enable wifi-powersave-off
sudo systemctl start wifi-powersave-off
```

---

### Verify Status

You can confirm Wi-Fi power saving is disabled with:

```bash
iw dev wlan0 get power_save
```

Expected output:

```text
Power save: off
```

---

## Step 8: Disable Bluetooth (Recommended)

On the Pi Zero 2 W, Wi-Fi and Bluetooth share the same wireless chip and antenna. Keeping Bluetooth enabled adds interference and extra load on the shared radio, which can cause Wi-Fi instability — and for a Wi-Fi-only audio streamer, a stable wireless link is everything. Since this build has no use for Bluetooth, disable it entirely:

1. Edit the boot config:

```bash
sudo nano /boot/firmware/config.txt
```

1. Add the following line in the `[all]` section:

```ini
dtoverlay=disable-bt
```

1. Disable the Bluetooth UART service and reboot:

```bash
sudo systemctl disable hciuart
sudo reboot
```

After the reboot, verify that Bluetooth is gone:

```bash
systemctl is-active bluetooth
# inactive

rfkill list
# no Bluetooth entries (only the Wi-Fi one, if any)
```

> Bonus: with Bluetooth disabled, the UART pins are free — you can add `enable_uart=1` to the same `[all]` section if you ever want a serial console for debugging.

---

## 🎉 Enjoy High-Fidelity AirPlay 2 Streaming

Your Raspberry Pi Zero 2 W is now a **fully-featured AirPlay 2 receiver**.

- **Multi-Room Audio**<br />


Group it with HomePods, Apple TVs, or other AirPlay 2 speakers.
- **Stable Sound Quality**<br />


Buffered ALSA output tuned for the Pi Zero 2 W's CPU, with SoXR available if you want to trade CPU for resampling quality.
- **Seamless Apple Integration**<br />


"Living Room Pi" will appear instantly in the AirPlay speaker list on iOS and macOS.

For a device that costs only a fraction of commercial streamers, the result is remarkably close to a professional-grade solution.

Happy listening 🎧

## Sitemap

See the full [sitemap](https://hannoeru.me/sitemap.md) for all pages.
