Skip to content

Tutorial: Build a low-profile AirPlay 2 audio receiver, powered by Raspberry Pi!

Notifications You must be signed in to change notification settings

N8WM/raspi-play

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 

Repository files navigation

raspi-play

Build a low-profile AirPlay 2 audio receiver, powered by Raspberry Pi! This is a cheap and easy project to wirelessly connect an old speaker system to your Apple devices, such as an Apple HomePod.

front of device (audio and SD ports) back of device (power and data ports)

This tutorial assumes you have a Unix-like terminal for setting up the Raspberry Pi

Materials

  • Raspberry Pi Zero 2 W - Amazon | Adafruit
  • I2S PCM5102A DAC Decoder - Amazon | Ebay
  • MicroSD Card (8GB+) - Amazon | Western Digital
  • USB or SD card adapter for the MicroSD card if your computer does not have a MicroSD slot (your MicroSD card may come with one, read its description) - Easily found on Amazon
  • 3D printed case (use the case and cover STL files in the repository [coming soon])

Tools

  • 3D Printer
  • Soldering Iron
  • Solder (preferably rosin core, lead-free)
  • Jumper wires (if your DAC decoder does not come with them, mine did)
  • Third hand tool/PCB holder (optional but recommended)
  • Hot glue & glue gun
  • Metal file (or something else to shave down the HDMI port's overhang)

Instructions



- 1 -
Gather the parts and tools specified

When 3D printing the case, I recommend a small layer height as opposed to a larger one for finer detail on port cutouts. I also recommend enabling supports.



- 2 -
Prepare the Pi to fit into the 3D-printed case

Discard the black piece of plastic covering the flex cable connector on the short edge of the Pi.

File away the metal on the HDMI port that overhangs the edge of the PCB board (notice in the second image how the HDMI port cannot be seen from underneath).


Pi preparation1 Pi preparation2



- 3 -
Solder jumper wires to the DAC decoder

On the short side of the board, the pads BCK, DIN, LCK/LRCK, GND, and VIN need to have jumper wires soldered to them. Do NOT solder a wire to SCK.

Apply a small bead of solder to jump the two little pads on the front side of the board, between SCK and BCK. NOT THE SCK AND BCK PADS THEMSELVES, but the tiny pads next to them.


DAC connections



- 4 -
Solder the jumper wires from the DAC to the Pi

Make sure the wires go into the front component side of the Pi, otherwise the Pi will not fit into the case properly. Please use the following guide:

Connection Guide GPIO Labels
DAC BOARD   > Raspberry Pi Zero 2 W connector
-----------------------------------------------
SCK         > Not wired (Internally generated)
BCK         > PIN 12    (GPIO18)
DIN         > PIN 40    (GPIO21)
LCK/LRCK    > PIN 35    (GPIO19)
GND         > PIN 6     (GND) Ground
VIN         > PIN 2     (5V)
GPIO guide

How mine looked after this step

Pi connections



- 5 -
Flash the SD card

Before permanently hot gluing the Pi and DAC into the 3D printed case, it is a good idea to make sure it all works, in case any fixes need to be made.

On your computer, plug the MicroSD card into your MicroSD reader slot or adapter.

Download the Raspberry Pi imager from the Raspberry Pi software page.

Launch the application and grant the necessary permissions. You should see a screen for selecting a device, an operating system, and storage.

For the device, choose RASPBERRY PI ZERO 2 W. The operating system should be RASPBERRY PI OS (LEGACY, 64-BIT) LITE (this may be located in the Raspberry Pi OS (other) category).

Select your MicroSD card or slot name from the Storage options, mine was called "APPLE SDXC READER MEDIA".


Raspberry Pi flash software

Click NEXT. If it asks you if you would like to apply OS customization settings before it flashes the MicroSD card, I recommend setting a custom hostname, username, and password. You can do this by clicking EDIT SETTINGS.


OSC edit settings

Go to the GENERAL tab. The hostname is what will show up on your Apple device when connecting to the AirPlay server, I named mine "AirPlayRBP", but if you leave it as default, it will be called "raspberrypi".


OS customization general

Go to the SERVICES tab and tick the Enable SSH checkbox.


OS customization services

Click SAVE. Now when it asks if you would like to apply OS customization settings, click YES.


OSC yes

If it asks if you would like to prefill the WiFi password from the system keychain, click No. We will set this up manually.


WiFi keychain

When it asks if you still want to continue, click YES. It may take a few minutes to flash the MicroSD, and you may be prompted to authenticate your computer accessing the MicroSD card.

When the program is finished flashing the card, you can close it.

Unplug the MicroSD card from your computer and plug it back in.



- 6 -
Configure the network settings

The SD card should be called bootfs, and navigating to it with a file explorer will reveal your Pi's boot directory.

Create a new file there called wpa_supplicant.conf using your preferred text editor. Open the file and paste in the template below:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<YOUR COUNTRY CODE>

network={
    ssid="<YOUR 1ST NETWORK NAME>"
    psk="<YOUR 1ST NETWORK PASSWORD>"
    key_mgmt=WPA-PSK
    id_str="<YOUR 1ST NETWORK ID>"
    priority=<YOUR 1ST NETWORK PRIORITY>
}

network={
    ssid="<YOUR 2ND NETWORK NAME>"
    psk="<YOUR 2ND NETWORK PASSWORD>"
    key_mgmt=WPA-PSK
    id_str="<YOUR 2ND NETWORK ID>"
    priority=<YOUR 2ND NETWORK PRIORITY>
}

Fill in your personalized preferences for each WiFi network you wish to add (anything with angular brackets <...>).

  • country: the two-letter country code (i.e. country=US, country=AU, etc.)
  • ssid: the case-sensitive name of the WiFi network (surrounded by double quotes)
  • psk: the password (surrounded by double quotes
  • id_str: a unique label to distinguish from other networks, could be anything (surrounded by double quotes)
  • priority: a unique number to determine what order WiFi networks should connect in (integer, no quotes)

This configuration is for two WiFi networks, but a different number of networks can be configured by adding or removing network={...} listings.

Save and close wpa_supplicant.conf.


Useful Network Settings Info

Once the Pi boots for the first time, the wpa_supplicant.conf file will be digested by the operating system, and it will be deleted

Don't worry! These network settings are not permanent! Here are a few ways to change them later down the line...

  • Running the wpa_cli command with root privileges in the Pi's terminal (interactive way to adjust existing settings, i.e. add a new network, or change a password). Here are a few useful commands to run after opening interactive mode with sudo wpa_cli:
    • list_networks gives you networks with their ID numbers (useful in other commands)
    • get_network <network_number> <variable_name> gets the value of a variable from a specific network (i.e. get_network 0 ssid)
    • set_network <network_id> <variable_name> <value> sets the value of a variable of a specific network (i.e. set_network 0 psk "S1lly_p455c0d3")
  • Creating a new wpa_supplicant.conf file in the boot directory (overwrites the existing network settings). This is useful if you cannot SSH into the Pi for various reasons.



- 7 -
Boot up the Pi

Plug the MicroUSB power cable into the outermost MicroUSB port. Two lights should turn on, a green LED on the Pi, and a red LED on the DAC. It will take several minutes for the Pi to configure itself on the first boot, so be patient.

A good way to tell if the Pi is finished booting is if the green Pi LED is steady

Verify that the Pi is connected to your network with the following command, assuming you are using the default hostname:

ping raspberrypi.local

To open the Pi's terminal, you can SSH into it. The following command assumes you are using the default credentials:

ssh pi@raspberrypi.local

The first time you SSH into the Pi, it will ask you if you want to continue to connect. Type yes. It will then prompt you for a password. The default password is raspberry.

Next, run these commands one at a time:

sudo apt-get update
sudo apt-get upgrade
curl -sSL get.pimoroni.com/phatdac | bash
sudo apt-get install git
sudo apt-get install autoconf

Follow the instructions to install the following:

Note: Whenever a command starts with a # symbol instead of a $, it means to run the command with root privileges, i.e. starting with sudo ....

[to be continued]

Resources

- Code to run AirPlay server: [Shairport Sync](https://github.com/mikebrady/shairport-sync) - DAC jumper wire connections: [Kamran Sethi](https://raspberrypi.stackexchange.com/a/76264)