Pi AirPlay and Spotify receiver
Build it step by step
0 of 7 doneFlash the card
Use Raspberry Pi Imager with your Wi-Fi and SSH.
Wire the DAC
Five wires and the clock pin to ground.
Enable the overlay
Add the dtoverlay line and reboot.
Check the card
aplay -l lists the DAC.
Install AirPlay
shairport-sync, then name it.
Install Spotify Connect
Follow Raspotify's instructions.
Plug in the amplifier
Play from a phone.
How do you build a pi AirPlay and Spotify receiver?
A Pi Zero 2 W with an I2S DAC turns old speakers into a wireless receiver for AirPlay and Spotify Connect. You need Raspberry Pi Zero 2 W, SanDisk microSD card 32 GB (A1, Class 10), Raspberry Pi 15 W USB-C power supply, PCM5102 I2S DAC module, Audio jack 3.5 mm (PCB, stereo) and Jumper wires female to female (40 pcs). It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 6
Wiring
| From | To | Why |
|---|---|---|
| PCM5102 VIN | Pi pin 1 (3.3 V) | Power |
| PCM5102 GND | Pi pin 6 (GND) | Ground |
| PCM5102 BCK | Pi pin 12 (GPIO18) | I2S bit clock |
| PCM5102 LRCK | Pi pin 35 (GPIO19) | I2S word select |
| PCM5102 DIN | Pi pin 40 (GPIO21) | I2S data |
| PCM5102 SCK | GND | Use the internal clock (many boards have a solder pad for this) |
| PCM5102 line out | Stereo jack or amplifier input | Audio out |
Code
The Pi Zero 2 W has no good analogue output, so a PCM5102 DAC board on the I2S pins gives clean line-level sound for an amplifier or powered speakers. Many PCM5102 boards need the SCK pin tied to ground (or a solder pad bridged) so the chip makes its own clock; read your board's notes. Install Raspotify from its own project page and read what any installer script does before running it. Spotify Connect needs a Premium account. Use a good 5 V supply of 2.5 A for the Zero (a micro-USB one), as weak supplies cause crackles and resets. Do not put the Pi on an open network where strangers can stream to it; AirPlay has no password unless you set one in the shairport-sync file. Do not store your Wi-Fi password in files you share. Line-level output should go to an amplifier input, never directly to a speaker.
# Pi AirPlay and Spotify receiver. Run these on the Pi over SSH. Not an Arduino sketch.
# 1. Flash Raspberry Pi OS Lite with Raspberry Pi Imager. In its settings add your own Wi-Fi details and enable SSH.
# 2. Enable the DAC: add this line at the end of /boot/firmware/config.txt (older images use /boot/config.txt)
# dtoverlay=hifiberry-dac
# and comment out "dtparam=audio=on", then reboot.
sudo nano /boot/firmware/config.txt
sudo reboot
# 3. Check the DAC appears as a sound card.
aplay -l
# 4. Install the AirPlay receiver.
sudo apt update
sudo apt install -y shairport-sync
# Edit /etc/shairport-sync.conf. In the general section set the name, and in the alsa section the device:
# general = { name = "Workshop speakers"; };
# alsa = { output_device = "hw:0"; };
sudo nano /etc/shairport-sync.conf
sudo systemctl enable --now shairport-sync
# 5. Spotify Connect: install Raspotify by following its project instructions
# (it is a Spotify Connect client for the Pi, needs a Spotify Premium account on your phone).
# 6. Both services start at boot. Check them.
systemctl status shairport-sync
systemctl status raspotifyTest checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Phone | The speaker name appears in AirPlay and Spotify |
| Play a song | Clean sound from the speakers |
| Reboot the Pi | Both services return by themselves |
| Walk away from the router | Gaps, then it recovers |
If it does not work
aplay shows no card
Check the overlay line and the wiring.
No sound
Check output_device in the shairport-sync config.
Crackles
Use a better power supply and a short audio cable.
Not visible on the phone
Phone and Pi must be on the same network.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the pi AirPlay and Spotify receiver?
Raspberry Pi Zero 2 W, SanDisk microSD card 32 GB (A1, Class 10), Raspberry Pi 15 W USB-C power supply, PCM5102 I2S DAC module, Audio jack 3.5 mm (PCB, stereo) and Jumper wires female to female (40 pcs). Raspberry Pi 15 W USB-C power supply: Use a micro-USB 5 V 2.5 A supply for the Zero.
How long does the pi AirPlay and Spotify receiver take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the pi AirPlay and Spotify receiver works?
Phone: The speaker name appears in AirPlay and Spotify. Play a song: Clean sound from the speakers. Reboot the Pi: Both services return by themselves.
aplay shows no card: what should I check?
Check the overlay line and the wiring.
No sound: what should I check?
Check output_device in the shairport-sync config.
Crackles: what should I check?
Use a better power supply and a short audio cable.
Not visible on the phone: what should I check?
Phone and Pi must be on the same network.
