Introduction: Raspberry Pi Bluetooth+Airplay Audio Receiver Combo

Picture of Raspberry Pi Bluetooth+Airplay Audio Receiver Combo

Let's make a bluetooth audio receiver allowing you hook up your R-Pi to your stereo and use your phone as the sound source.

To be honest, this is not a unique project. Plenty of people have attempted to get a bluetooth receiver working, some (less) have succeeded. After spending way to much time on trying to get the features that I want by combining sniplets from various guides I eventually got it right. In fact, I would like to give credit to Google and everybody on the internet for sharing their pain and experience. Without you I couldn't have done it!

The wish list:

  1. R-Pi Bluetooth and Airplay audio receiver: I want to be able to stream Spotify and other audio sources from a phone to my stereo. We have both Android and iOS-devices in our household so both should work.
  2. The receiver shall auto-pair and auto-trust phones trying to connect
  3. There should be a synthesized voice connect announcement (This is new, I think. I haven't seen anyone else doing this).
  4. There should be support for A2DP and A2CP profiles for meta data and playback control.
  5. Stand-alone operation. No display required. No login and manual steps, i. e. just plug it in and use it.
  6. Easy, predictable scripted install

As it turns out, A2DP and A2CP profiles mandate the use of Bluez 5 which in turn needs Pulse Audio 5.

What is Bluez? Bluez is the Linux bluetooth stack. It handles all the low level bluetooth stuff (pairing, audio data transfer, etc.)

What is Pulse Audio? It is a sound proxy. It will take the digital bluetooth audio stream, resample it and send it through to the analog headphone jack.

Step 1: What You Need

Picture of What You Need

This is what you need to complete this project:

  • Raspberry Pi (B+ v2 or Pi 2)
  • Bluez-compatible bluetooth 4.0 dongle
  • 8GB MicroSD
  • A good solid power source for the Raspberry Pi
  • A keyboard and display for initial setup
  • Optional: R-Pi compatible WiFi dongle, e. g. Realtek RTL8188CUS

A note on the Pi version. I have used a Pi 2 during installation since it saves time. Then I move the completed MicroSD to a B+ V2. Running this application on a Pi 2 is a bit of a waste of CPU cycles.

Step 2: Basic Prep

Picture of Basic Prep
  • Download Raspbian image here
  • Transfer image to sdcard using Win32 Disk Imager following instructions on
  • Insert sdcard and power up
  • Important! Expand file system to full 8GB capacity (see screenshots)
  • Reboot
  • Login as user pi (password: raspberry). Please note that for the rest of this guide it is assumed that you are logged in as "pi".
  • Update operating system and reboot:
sudo apt-get update
sudo apt-get -y upgrade
sudo reboot

Step 3: Install Helper-scripts

Picture of Install Helper-scripts

After too many manyal trial and error attempts of trying to get this working I realized I had to script the install. That way I will get the same result every time. The scripts can be found on bitbucket.

This is how to install:

pi@raspberrypi ~ $ cd ~
pi@raspberrypi ~ $ git clone
pi@raspberrypi ~ $ cd raspberry-pi-audio-receiver-install/
pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ 

Are you lazy? Skip to step 10!

Step 4: Bluez & Pulse - Install Dependencies

Next, you need to install required packages for Bluez 5 and Pulse Audio 5. Usually you don't need to worry about dependencies because the debian installer does it for you. We will install our software from source.

Simply run the script "":

pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./

Step 5: Bluez & Pulse - Install From Source

Neither Bluez 5 or Pulse Audio 5 are available in the Raspbian repositories; hence they have to be downloaded, built (compiled) and installed. In addition, the two software packages need to interact. For this purpose users and permissions have to be set up right. Run "".

pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./

Did anything go wrong? The first thing to check - are you on a 8 GB card and did you remember to expand the file system? Not that? Start over and run each part of the script manually.

Step 6: Bluez & Pulse - Configure

The next script configures the following:

  • Creates the file /etc/udev/rules.d/99-input.rules. This file triggers execution of /usr/local/bin/bluez-udev when bluetooth devices are connected or disconnected.
  • Copies custom utility files to /usr/local/bin:
    • simple-agent.autotrust: Python script mostly stolen from Bluez sample code. I modified a few lines to have it auto-accept any connection attempt. The script is depending on, which is also copied.
    • bluez-udev: Executes when devices are connected and links the incoming bluetooth source (input) with the pulseaudio sink (output) and reverses the process on disconnect. The script also triggers voice annoucements: "Device XYZ Connected" using supplied script
    • Text to voice script. If the RPi is on-line, the TTS-voice from Google Translate is used. Off-line fall back uses espeak.
  • Creates a startup script for Pulse Audio (/etc/init.d/pulseaduio)
  • Creates a startup script for Bluez (/etc/init.d/bluetooth)
  • Creates a startup script for simple-agent.autotrust as described above (/etc/init.d/bluetooth-agent)
  • Modifies /etc/bluetooth/main.conf for:
    • Device name
    • Bluetooth Class (Portable audio)
    • Disable discoverable timer so the device stays discoverable
  • Modifies /etc/pulse/daemon.conf for:
    • Resample method. The default resample method is not suitable for Raspberry Pi.
    • Various parameter adjustments to improve sound quality (I used to have problems with crackles and poor sound).
Run the script and enter the device name (what you will see when you attach from your phone):
pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./
Bluetooth device name: RpiAudio

Now, reboot!

Step 7: Shairport - Install From Source

The software package used for Airplay audio streaming is called Shairport. This is also best done by downloading the source and building it:

pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./

Step 8: Shairport - Configure

The script does the following;

  • Creates a /etc/init.d/shairport startup file
  • Edits the device name into the startup file
  • Creates the shairport user and adds it to the audio group
pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./
Airplay device name: RpiAudio

Now, reboot!

Step 9: Usage

Picture of Usage

Hook the Pi up to a sound system. If you will be using the voice announcements, I suggest you put your Pi on the network, either by cable or WiFi. You will get announcements even if you stay off-line but the script will fall back to espeak which produces a robot-style voice.

Android: Scan for bluetooth devices and the device name you specified should appear among discoverable devices. Connect and press OK on the pop-up.

iOS: Open your music player and attach it to the airplay player with the name you specified. I would have shared a couple of screenshots but my wife is out of town and so is her iPhone.

Play some sound and you should hear it through the sound system!

Step 10: Cheating! (all at Once)

So, why not put it all together? Either do the steps above one by one or run all scripts in sequence:

pi@raspberrypi ~/raspberry-pi-audio-receiver-install $ ./
Device name: RpiAudio
I would suggest you go cook dinner while this finishes. The script takes around 45min on a Rpi 2. Probably a lot longer on the B+. Output is saved to runall.log if you want to see the progress in retrospect.

Step 11: Final Words

Things that work well (for me, anyway) are:

  • Autopairing
  • Bluetooth and Airplay playback
  • Voice announcements for Bluetooth devices
  • Sound quality is as good as it can be on the Pi 11-bit D/A analog out. Keep output volume on the Pi as close to max as possible and turn the volume down a little on the Amp if needed. That way you will be using most of the 11 bits for sound. Doing the opposite (low vol on the Pi and high on the Amp) will give you a hissing background noise and distorted music. Do this: turn the Amp volume down, turn the Pi-volume up to max (using your phone), play a song and crank the Amp up to about max of what you will be wanting to use, then turn the Pi vol down to comfortable listening.

This is what can be improved or is not working:

  • Bluetooth volume control on some devices doesn't work. As far as I can tell, this is a limitation in Bluez 5 or possibly in the bluetooth implementations on some phones. In fact, I couldn't get volume control to work for iPhone 5 which is one of the reasons I wanted Airplay support.
  • Airplay connect/disconnect announcement. I haven't found a way to do this yet. There is nothing in the Shairplay logs to indicate a device connection. There is plenty about playback, meta data, etc but nothing about the connection. Please help me to figure this out! Leave comments.
  • Sound quality. I will try a USB soundcard and probably the hifi-addon board.
  • With Bluez 5 I have access to meta data and playback control but I haven't figured out what to do with it yet. I am pretty happy using the phone display for all that. For a brief moment I wanted to make a script to have the speech-script announce track and artist but I think that would start driving me nuts after about three songs. I thought about adding a display but for my application I am hiding the device.
  • I will probably use the voice engine to announce alerts from my home automation server (running Openhab)
  • I may add one or more GPIO-connected hardware buttons. One idea is to have a button to force disconnect a phone which is hogging the bluetooth connection.
  • Inactivity timer disconnect of devices

Step 12: Update Feb 2017: Raspbian Jessie

Good news! A couple of readers have updated code for Raspbian Jessie and added features (see comments for details). I want to highlight it here for stickiness.

Thanks a lot to adenbeckitt and BaReinhard!

First fork:

Second fork:


adenbeckitt (author)2017-01-23

This no longer works on Raspbian Jessie.

I've fixed all the code here;

You should be able to follow the normal instructions.

zbot473 (author)adenbeckitt2017-07-22

In your install file, is not executable! OP, please update the file and all else run chmod +x

It's worked well on RPI3 with Jessie. You said that this installation process have possibility to access to metadata and volume control? How does it make? As a result i want to request this metadata from remote client (node-red or smth else)

malaaraji (author)adenbeckitt2017-04-14

Is this easy to do on a Pi3? I am very inexperienced in this area and need some help.

ViktorK19 (author)adenbeckitt2017-02-13

Hey thanks, I've tried that on RPI zero but no success. Maybe just because I used I will try it on my old pi which had this back on wheezy if your update works and if not I will post here logs.

Thank you for your update, this is one of best solutions currently available.

adenbeckitt (author)ViktorK192017-02-13

Should work perfectly fine on the newest raspbian jessie. Any idea what the errors are?

ViktorK19 (author)adenbeckitt2017-02-20

@adenbeckitt, well bluetooth works well after I've manually patched some configs (there are rejects even when using clear raspbian lite), but airplay doesn't work for me, I will look at it when I have time but it seems that this service doesn't autostart at all (btw. author changed some comments in shairport config so there are also rejects because it looks for whole line).

knightgreider (author)ViktorK192017-03-14

What manual patches did you do? I am really inexperienced with this. I got Airplay to work but no bluetooth. Pi 3

BaReinhard (author)adenbeckitt2017-02-13

does this update allow for automated connection to bluetooth, aka no need for Pin code?

adenbeckitt (author)BaReinhard2017-02-13

It works in my version, yes.

BaReinhard (author)adenbeckitt2017-02-14

Hey @adenbeckitt I just wanted to say thank you for doing much of the leg work for this project and making it usable again. I'm sure you've seen by now but I have updated a few things to include sound card support and have moved it over to github. I believe I gave you collaboration rights to it, I'm still pretty new to github and bitbucket so I am still learning. Also, I wasn't sure whether I should have forked the repo or just cloned it. Anyway, I made sure to give credit where it was due. If you would like we can create something that merges the two repo's and allows for some choices before begins, or allow for the choices as begins. Let me know what you think. I am find with either two separate repo's or merging into one.

Thanks again!

ehsmaes (author)adenbeckitt2017-01-23

I think many people will be happy about that! Thanks a lot for your contribution!

Dank_Rogge (author)2017-08-06

Hello. Beginner here, i got myself a usb soundcard for this project. Trying to udnerstand where i tell my rasp to use the soundcard as output. Would it be in on of the pulseaudio init files or deamon?

SimonD130 (author)2017-07-27

You said you could get Artist and Track information.

Could you advise how? I've been trying in vain with "RegisterPlayer" and trying to watch for Property Changes, but I get all sorts of issues. Even though I have now compiled the latest BlueZ 5.46, my Python scripts complain that MediaPlayer1 cannot be found (though MediaControl1 is present), and the "simple-player" script from BlueZ, fails at RegisterPlayer with "InvalidArguments" and very little else!

Im trying to wrap everything into KODI. So I have created an AddOn Script which successfully calls Play, Pause, Stop, Rewind etc... Just need to collect Media Information to display the properties of the currently playing track in KODI.

Then I can work on HFP!

Tinkerchimp (author)2017-04-21

Thanks very much for this project! I've run the install routines from both forks (first adenbeckitt's and then BaReinhard's, and when I pair my phone with the raspberry pi and play music, it comes through garbled for a few seconds then stops. The phone seems to keep happily streaming the music over the connection after it stops. Any idea what could be going on?

kamyarkazemi1373 (author)2017-04-06

Great project I was wondering if there is anyway that the info for the music playing through Bluetooth could appear in Kodi?

curtisg890 (author)2016-01-28

I've managed to install it all sucesfully, but none of my devices can pick up the bluetooth. if i run hciconfig it shows the adapter is there. Any Ideas?

MattK53 (author)curtisg8902016-02-04

Same here. No Bluetooth discoverable device appearing anywhere!

Shairport works perfectly.

cat007 (author)MattK532016-08-28

Did you get it working?

MattK53 (author)cat0072016-08-29

No, never did. I recently bought a Rpi3 (WiFi and BT built in) so I aim to try it on that in the near future. Will let you know if I have any joy with that.

malaaraji (author)MattK532017-03-27

did it work using the Rpi 3?

MattK53 (author)malaaraji2017-03-27

No! But I haven't tried the updated the most up to date instructions (Feb 2017 above) yet.

RobertoT43 (author)MattK532016-08-28

same here, i installed from, so i can't wrong nothing, and shairport and other stuff i guess that are installed, but in raspbian i can't see in start, internet or other categories, any new programs installed.

i tried with my phone to see this bluetooth of my raspberry pi2 with asus bt400 without success. anyway bluetooth works, but to listen music my phone doesn't recognize the name of bluetooth that i insert when i installed this script to stream music into raspberry.

some help to do it ? seems that this tutorial is old or something like that

square_eyes (author)2017-01-02

Really keen to get this script working on Jesse, Pi 3 model B. Any pointers on what needs updating? I'm going to look through the scripts but I'm nervous I'll miss something and bork.

malaaraji (author)square_eyes2017-03-27

im using a RPI 3 and i need some help

BaReinhard (author)2017-02-15

I have added a few of these add-ons,

Bluetooth Volume control to work with iPhone 6S (configuration will depend on sound card being used, but it works)

AirPlay connect/disconnect (ish) seems possible, havent gotten espeak to work yet.

Added auxillary line input for those old schoolers out there.

Included addition of usb sound card, soon to try hifiberry dac+ pro

Added, car implementation to create an Access Point to connect to to get AirPlay to work.

all can be found here:

Keeps with the original


sudo ./


amey8 (author)2017-01-25

thanks it does not work

Aman_malhotra_287 (author)2016-12-30

sir any suggestions for which bluetooth dongle we should buy

sorry, can't really offer any good suggestions right now. I wrote this a while ago. Actually, now you don't even need a dongle. Use a raspberry pi 3 with built in bluetooth. However, the scripts are dated and need a brush up for newer raspbian versions.

IweM (author)ehsmaes2017-01-06

I managed before with an older version. It worked like magic. Great work! I tried to get it to work on the newest Jessie with an external soundblaster play! 2 but sadly no luck. I hope to find some time to modify your scripts some time soon. It would really make my CarPc a whole lot better :)

ViktorK19 (author)ehsmaes2017-01-04

How about update those scripts? I am still using it, but I need to downgrade my home pi server back to older version in order to make this work again and I need it mainly for my new rpi zero setup and there is better to use Jessie lite dist.

Thanks for amazing script BTW! :-)

MiroslavV6 (author)2016-09-18

Can I stream audio and execute ssh commands at the same time via the bluetooth ?

jojo59650 (author)2016-09-06

Hi, I gave a try today on your instructable. Thank you. I have used the lazy method on step 10. But I have a problem connecting my Raspberry Pi 3.

bluetoothctl give me:

[NEW] Controller AA:AA:AA:AA:AA:AA raspberrypi [default]

Can someone help me?

cat007 (author)2016-08-28


So I'm having issues where I can't see my pi from my phone, and my pi can't see my phone, or any other bluetooth devices.

I'm using a pi 3 Model B with the built in bluetooth.

Has anyone tried this on the Pi 3 Model B?


cat007 (author)cat0072016-08-28

Also - it deleted my Kodi install? What the???

cat007 (author)cat0072016-08-28

Further to this - if I go into bluetoothctl I get the following:


[NEW] Controller AA:AA:AA:AA:AA:AA suprapi [default]

Seems odd the mac address is AA:AA:AA:AA:AA:AA ??

cat007 (author)cat0072016-09-02

Output from one of the scripts that removed a whole bunch of stuff:

"The following packages will be REMOVED:

espeak kodi kodi-bin libasound2-plugins libespeak1 libpulse0 libpulsedsp

libsdl1.2debian mplayer2 pulseaudio pulseaudio-module-x11 pulseaudio-utils"

Official_sniff122 (author)cat0072016-08-28

where you running open elec? if so, reflashing the sd card would of wiped out kodi

cat007 (author)Official_sniff1222016-08-28

Thanks. I'll follow your instructions tonight re: reinstalling bluez and see how I get on.

I didn't reflash my sd card. Using Raspbian. One of the install scripts output had "removing packages as no longer needed: kodi (and a bunch of other ones as well). I'll copy the output tonight and put it up.


Official_sniff122 (author)cat0072016-08-29


Official_sniff122 (author)2016-08-28

i am currently in the process of doing it on a raspberry pi 1b, not a 1b+, does anyone know how long it will take? i so am doing the install thing where it is printing cc and ccld, is this what it is suppose to be doing?

JensSt made it! (author)2015-06-22

Great, thank you, it works fine on my Raspberry Pi B+ and the Inateck BTA CSR4B5 Bluetooth adapter.

RobertoT43 (author)JensSt2016-08-25

i tried ./ but anyway i can't see bluetooth of my rasp :( i have rpi2 with raspbian last version

ehsmaes (author)JensSt2015-06-23

Glad to hear it works!

RobertoT43 (author)ehsmaes2016-08-24

i tried but i can see bluetooth with my phone. i have rpi2 and raspbian, asus bt400 dongle and nexus 5.

LukeD64 (author)2016-08-16

OMSC doesn't have xz-utils installed by defaults and so throws an error. Just need to add this to the list off packages to install at the start.

LukeD64 (author)LukeD642016-08-16

Also doesn't have a c compiler installed so adding: 'sudo apt-get install build-essential xz-utils' would fix these.

JoshJ47 (author)2016-08-08

After doing everything, I keep getting "Connection failed- No usable services on this device." on my Raspberry Pi when I try and connect with my phone. Can someone help me?

ConnorB7 (author)2016-07-07

Installed! (2nd time now)
First time, amixer use to be full volume. Now with the 2nd install, I have to ssh into pi and use "amixer cset numid=1 -- 400". What do I need to do to set it max (or near) at boot?

MaximN3 (author)2016-06-16

Unfortunately doesn't work for me on RP3. Pulseaudio seems to be broken after running all scripts. Perhaps because OS already had it. It would be great if someone made such script for RP3. Great work, though.

P.S. Will try to grab pulseaudio configs from this repo and manually config my system

About This Instructable




Bio: IT-professional by day, DIY hobbyist (among other things) on my free time. I always have one or more projects going on. Usually something to do ... More »
More by ehsmaes:Motorized WiFi IKEA Roller BlindCheap 3D Delta Printer ImprovementsMotorize IoT with ESP8266
Add instructable to: