How to Setup a Raspberry Pi as an AirPlay Receiver
Turning your Raspberry Pi into an AirPlay receiver allows you to stream audio from your Apple devices directly to your Raspberry Pi. This is a great way to repurpose your Raspberry Pi as a smart audio device. This guide will walk you through the steps to set up an AirPlay receiver on your Raspberry Pi using shairport-sync
.
Prerequisites
Before starting, ensure you have the following:
- Raspberry Pi (any model)
- MicroSD card with Raspberry Pi OS installed
- Stable internet connection
- Access to the command line (via monitor and keyboard or SSH)
- Speakers or headphones connected to your Raspberry Pi
Step 1: Update and Upgrade Your Raspberry Pi
First, make sure your Raspberry Pi is up to date.
- Open a terminal on your Raspberry Pi or SSH into it.
- Run the following commands to update and upgrade your system:
sudo apt update
sudo apt upgrade -y
Step 2: Install shairport-sync
shairport-sync
is a popular open-source software that turns your Raspberry Pi into an AirPlay receiver.
- Install Dependencies:
sudo apt install -y build-essential git xmltoman autoconf automake libtool libpopt-dev \
libconfig-dev libasound2-dev libavahi-client-dev libssl-dev
-
Clone the
shairport-sync
Repository:
git clone https://github.com/mikebrady/shairport-sync.git
-
Build and Install
shairport-sync
:
cd shairport-sync
autoreconf -i -f
./configure --sysconfdir=/etc --with-alsa --with-avahi --with-ssl=openssl --with-soxr
make
sudo make install
Step 3: Configure shairport-sync
- Edit the Configuration File:
Open the shairport-sync
configuration file for editing.
sudo nano /etc/shairport-sync.conf
- Update the Configuration:
Customize the configuration according to your preferences. For example, you can set a custom name for your AirPlay receiver:
general = {
name = "My-AirPlay-Receiver";
};
- Save and Close the File:
Save your changes and close the editor by pressing Ctrl+X
, then Y
, and Enter
.
Step 4: Enable and Start shairport-sync
-
Enable
shairport-sync
to Start on Boot:
sudo systemctl enable shairport-sync
-
Start the
shairport-sync
Service:
sudo systemctl start shairport-sync
Step 5: Connect to Your AirPlay Receiver
Now that shairport-sync
is running, your Raspberry Pi should appear as an AirPlay device on your Apple devices.
- Open the Control Center on Your Apple Device.
- Select the AirPlay Icon.
- Choose Your Raspberry Pi (e.g., "My-AirPlay-Receiver") from the List of Available Devices.
Step 6: Enjoy Your Music
You should now be able to stream audio from your Apple devices to your Raspberry Pi. Connect your speakers or headphones to the Raspberry Pi and enjoy your music.
Troubleshooting
If you encounter any issues, check the status of the shairport-sync
service:
sudo systemctl status shairport-sync
This command will display the service's status and any error messages that can help you diagnose the problem.
Conclusion
By setting up your Raspberry Pi as an AirPlay receiver, you can easily stream audio from your Apple devices to your speakers or headphones. With shairport-sync
, the process is straightforward and provides a cost-effective way to create a smart audio setup. Enjoy your new AirPlay-enabled Raspberry Pi and the convenience of streaming audio directly from your Apple devices!