PiZero AirPlay Receiver
Hey Guys,
this instructable will show you, how you can add AirPlay to any hifi system with cinch inputs and use it with multiple units as a synchronized multi room audio system.
It's quite simple and cheaper than an Apple AirPort or AppleTV.
For this projectyou will need:
1 Raspberry Pi Zero or better a Raspberry Pi Zero W 5-9$
1 Pimoroni pHAT DAC for Raspberry Pi Zero 15$ or better a I2S PCM5102A DAC Decoder from eBay 6$
1 Micro USB power supply 5V/1-2A 5$
1 microSD card (8gb and class 10 recommended) 3-5$
1 usb wifi-dongle 3-10$ (not needed with a Raspberry Pi Zero W)
1 usb otg cable 1$
1 HDMI compatible display (just for configuration)
1 usb keyboard (just for configuration)
1 usb-hub (just for configuration)
I got my parts as a complete kit from Pimoroni (sd card and power supply not included).
If you got your parts together, we can start right away.
Assembling the Hardware
Solder the male 2*20 Pin Header onto the Pi and the female onto the pHAT DAC.
I've soldered the pHAT DAC directly onto the Pi, so the complete setup gets even more compact. But keep in mind that an eventually disassembly will be more complicated.
Now plug the USB-OTG with the wifi dongle attached into the Pi Zero (expect you are using a Pi Zero W, then there is no need for an extra wifi dongle).
Prepare the Raspberry Pi Zero
The Raspberry Pi Zero comes with only one usb-Port and no network interface, so it is a bit tricky to configure our wifi dongle.
There are at least three different ways:
- Use a usb hub (active) and the hdmi monitor.
- Configure the network on an other (fullsize) Raspberry Pi
- Use a console cable
But before we can start configuring our network connection, we will need a working raspbian.
In this instructable i will use Raspbian Lite "Jessie".
You can download it at the website of the Raspberry Pi Foundation
If you dont know how to install the downloaded file on the sd card just follow this link: Instruction
In the next steps I will use the method 1 mentioned above!
So plug in a keyboard and the wifi dongle into the hub and connect it over the otg cable with the Zero, insert the sd card with raspbian installed and power it with the micro usb supply. Don't forget to plug in your monitor.
At the first boot, log in with the username "pi" and the password "raspberry".
Now type
sudo raspi-config
and hit enter.
Things you have to do inside the raspi-config program:
- resize the file system
- change the localisation options according to your location
- set the wifi-country
Reboot your Pi.
Do a full update of the opreating system with:
sudo apt-get update
and
sudo apt-get upgrade
Now we are ready to configure the network.
Type
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines to the file:
network={ ssid="insert_your_wifi_network_name_here" psk="insert_your_wifi_password_here" }
Reboot your Pi and type in
ifconfig
You should see an entry called wlan0. If you configured the wifi connection correct, you should see something like
inet addr:192.168.2.x (or similar, like the second picture)
You can now either stay at your current method configuring your Pi or switch to a ssh connection.
You can find a complete guide for the ssh connection at SSH Tutorial
Installing the PHAT DAC
The easiest way to get the pHAT DAC working, is to use the one-line installer from pimoroni:
curl -sS get.pimoroni.com/phatdac | bash
This script will set everything up for you whether you are running
Raspbian Wheezy or Jessie (including Jessie Lite). You will need to reboot your Pi after the script has completed.
This should work for the eBay I2C Decoder as well because it uses the same DAC chip!
Install Shareport Sync
Shairport Sync is an AirPlay audio player — it plays audio streamed from
iTunes, iOS devices and other AirPlay sources such as Quicktime Player and ForkedDaapd, among others. Audio played by a Shairport Sync-powered device stays synchronised with the source and hence with similar devices playing the same source. In this way, synchronised multi-room audio is possible without difficulty.
Before you can install shareport you need a bunch of other packages.
sudo apt-get install build-essential git sudo apt-get install autoconf automake libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev sudo apt-get install avahi-daemon libavahi-client-dev sudo apt-get install libssl-dev<br>sudo apt-get install libpolarssl-dev sudo apt-get install libsoxr-dev
Now you are good to go!
Download the git repo with:
sudo git clone <a>https://github.com/mikebrady/shairport-sync.git</a>
Go into the new folder with
cd shareport-sync
then
autoreconf -i -f ./configure --with-alsa --with-avahi --with-ssl=openssl make sudo make install
To configure the freshly installe software type
sudo nano /etc/init.d/shairport-sync.service
You can now edit your shairport configuration. Add the lines:
[Unit] Description=Shairport AirTunes receiver After=sound.target Requires=avahi-daemon.service After=avahi-daemon.service [Service] Type=simple ExecStart=/usr/local/bin/shairport-sync -a "MyShairport" Restart=always [Install] WantedBy=multi-user.target
By changing the "MyShairport" text you can add your individual name for your AirPlay device. Save and quit this file by hitting ctrl+o, enter and ctrl+x and enter.
Add Shairport Sync to the System Services and First Start
The next thing we have to do is to add the shairport service to the system services. This is done by the command
systemctl enable shairport-sync.service
Now it's time to start the service for the first time. Type
systemctl start shairport-sync.service
and the service wil be launched. If you want to check the status of the service type
systemctl status shairport-sync.service
into the console.
Now you're good to go to stream your music. You should see your newly created device in iTunes or in your music app on your iDevice. For me I configured two Raspberry Pi Zeros named "Denon DRA-1025R" and "Schlafzimmer".
Connect any audio amplifier with your Raspberry Pi over 3,5mm audio and enjoy your streamed music!