Made an AirPlay receiver using a Raspberry Pi
This project was done using instructions from Make magazine volume 49, and with additional instructions which are laid out in this Raspberry Pi Airplay Tutorial.
In this post I will be showing the steps I took to make the AirPlay device work, along with some mistakes made in the process, as I had to redo the project due to some early mistakes.
For this project I used a Raspberry Pi 2 with the NOOBS command line OS, though both sets of instructions have you download and use the Raspbian OS on your Pi.
The first thing that I did before starting this project, was getting the Pi connected to my local WiFi using a USB WiFi module from CanaKit. This was done using a brief tutorial from an adafruit article on how to set up WiFi using the command line. In the command line, I entered the following command so that I may edit a file containing network information along with the SSID and Password of the internet connection I wanted to connect to.
sudo nano /etc/network/interfaces
This command brought up a file that looks according to the following:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "ssid"
wpa-psk "password"
I then entered the SSID and password for my WiFi, saved the file, rebooted the Pi, and it was connected to WiFi.
Now onto the project: The first step would be to expand the file system using:
sudo raspi-config
and selecting the expand_rootfs option, however on the Pi I used, this was already done and thus not necessary.
After, I updated the package sources and packages by entering these two commands separately:
sudo apt-get update
sudo apt-get upgrade
On my first attempt at this project I did not enter those commands to update/upgrade packages, which is what I think caused the Pi to not have some necessary files for the program to compile and work in the last steps. Because of that, I had to manually delete all of the installed files via the command line, so that I could update things and then restart the project. The reason I did not enter them is because they are not in the original tutorial in the Make magazine, and that is likely because it is done implicitly when you load a fresh version of the Raspbian OS onto the Pi.
The next step was to change the default audio port by entering this command:
sudo amixer cset numid=3 1
Then I installed some prerequisites for the project using:
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
Next, the Perl Net-SDP had to be installed by entering:
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
and entered the following commands one at a time after the previous installation completes
cd perl-net-sdp
perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd ..
After that was installing and running Shairport with these commands in order:
git clone https://github.com/hendrikw82/shairport.git
cd shairport
make
and then finally finishing by running the next command to start up the AirPlay receiver, and entering the name of the receiver after -a in place of "name".
./shairport.pl -a name
after running it you can kill the program using Ctrl c at any time.
To test that the AirPlay capabilities were working, I hooked up some headphones to the Pi, checked that the Pi was broadcasting itself vie AirPlay by using an ipod, then played music over the connection and was indeed able to hear it through the connected headphones.
What I could potentially do next is to run some additional setup so that the program starts at launch, so that I will not have to manually run the program at startup. Also I could connect it to a stereo setup, as it is intended to be used for. Lastly, I could also get an Android app that will allow me to cast to AirPlay from my phone.
In this post I will be showing the steps I took to make the AirPlay device work, along with some mistakes made in the process, as I had to redo the project due to some early mistakes.
For this project I used a Raspberry Pi 2 with the NOOBS command line OS, though both sets of instructions have you download and use the Raspbian OS on your Pi.
The first thing that I did before starting this project, was getting the Pi connected to my local WiFi using a USB WiFi module from CanaKit. This was done using a brief tutorial from an adafruit article on how to set up WiFi using the command line. In the command line, I entered the following command so that I may edit a file containing network information along with the SSID and Password of the internet connection I wanted to connect to.
sudo nano /etc/network/interfaces
This command brought up a file that looks according to the following:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "ssid"
wpa-psk "password"
I then entered the SSID and password for my WiFi, saved the file, rebooted the Pi, and it was connected to WiFi.
Now onto the project: The first step would be to expand the file system using:
sudo raspi-config
and selecting the expand_rootfs option, however on the Pi I used, this was already done and thus not necessary.
After, I updated the package sources and packages by entering these two commands separately:
sudo apt-get update
sudo apt-get upgrade
On my first attempt at this project I did not enter those commands to update/upgrade packages, which is what I think caused the Pi to not have some necessary files for the program to compile and work in the last steps. Because of that, I had to manually delete all of the installed files via the command line, so that I could update things and then restart the project. The reason I did not enter them is because they are not in the original tutorial in the Make magazine, and that is likely because it is done implicitly when you load a fresh version of the Raspbian OS onto the Pi.
The next step was to change the default audio port by entering this command:
sudo amixer cset numid=3 1
Then I installed some prerequisites for the project using:
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
Next, the Perl Net-SDP had to be installed by entering:
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
and entered the following commands one at a time after the previous installation completes
cd perl-net-sdp
perl Build.PL
sudo ./Build
sudo ./Build test
sudo ./Build install
cd ..
After that was installing and running Shairport with these commands in order:
git clone https://github.com/hendrikw82/shairport.git
cd shairport
make
and then finally finishing by running the next command to start up the AirPlay receiver, and entering the name of the receiver after -a in place of "name".
./shairport.pl -a name
after running it you can kill the program using Ctrl c at any time.
To test that the AirPlay capabilities were working, I hooked up some headphones to the Pi, checked that the Pi was broadcasting itself vie AirPlay by using an ipod, then played music over the connection and was indeed able to hear it through the connected headphones.
What I could potentially do next is to run some additional setup so that the program starts at launch, so that I will not have to manually run the program at startup. Also I could connect it to a stereo setup, as it is intended to be used for. Lastly, I could also get an Android app that will allow me to cast to AirPlay from my phone.
Comments
Post a Comment