Bluetooth Audio Receiver / A2DP Sink with Raspberry Pi

After much trial and error, I have managed to configure Raspberry Pi to function as a Bluetooth Audio Receiver, also known as A2DP Sink mode.

Much of the articles and configurations on the web are for older version of Debian (<=7.x) which worked correctly with older versions of PulseAudio (<=4.x), Alsa & Bluez (<=4.x).

The following configuration has been tested with latest release of Xbian, which is based on Debian Jessie (8.0) and Raspberry Pi 3, which comes with a built-in bluetooth module. Other compatible bluetooth modules should work as well.

  1. Start by install / updating all the packages
  2. Add users to groups. This is very important. If using any other distro, replace ‘xbian’ with your username.
  3. Set up PulseAudio, Bluetooth Device Class

    The Bluetooth service/device class 0x200420 mean the device is set up for Car Audio. See to explore more Bluetooth Class options.

  4. To pair with a device, we will need to use the “bluetoothctl” tool.
  5. Set the agent to KeyboardOnly and make it default. This needs to be done once only. Inside bluetoothctl, run the following commands:
  6. Turn on bluetooth on your phone/tablet and make sure it is discoverable. Run the following commands inside bluetoothctl:

    xx:xx:xx:.. is the MAC address of your handset/device. After running ‘scan on’, wait a minute for your device to show up along with it’s MAC address. After running ‘pair xx:xx:xx:..’ check your device and accept the incoming connection. Do the same on terminal by typing yes.

  7. Now connect to the Raspberry Pi from your handset and it should connect as an audio device. All audio played through the device should now be output using Raspberry Pi’s HDMI or Analog out depending on your Pi’s configuration.
  8. If the connection fails, try again, sometimes it takes 2 attempts.

That is all for now. Please test the above instructions and post your results in the comments below. Enjoy!

45 thoughts on “Bluetooth Audio Receiver / A2DP Sink with Raspberry Pi”

  1. Hello,

    Thanks for this how-to but I have a problem with the class. It is not
    0x200420 but 0x000000 :/
    I’m using the onboard bluetooth device on a PI3

    pi@LHC_V5:~$ sudo bluetoothctl
    [NEW] Controller B8:27:EB:7A:13:0C LHC_V5 [default]
    [bluetooth]# show
    Controller B8:27:EB:7A:13:0C
    Name: LHC_V5
    Alias: LHC_V5
    Class: 0x000000
    Powered: yes
    Discoverable: no
    Pairable: yes


    1. Hi Sylvain,

      1. You can set the class to 0x200420 again with:
      > sudo hciconfig hci0 class 0x200420
      2. Verify that it is set correctly with bluetoothctl
      3. Remove the Raspberry Pi from your handset and pair again.

      The pairing should work immediately without any actions from Raspberry Pi as the device is already trusted.

  2. Thanks for answer, in fact maybe I’m making a mistake, I’d like to use my PI 3 as audio receiver. I’ve got a DAC Hifiberry Amp+ on it and I’d like to pair my android phone for playing music with Spotify


  3. Hi,
    I managed to set it up, thanks, but the class changed when I reboot the PI :
    hciconfig -a :
    Class: 0x000420
    Service Classes: Unspecified
    Device Class: Audio/Video, Car Audio


    1. I am not facing the same issue, I wonder why? :/
      Perhaps you can try to run the “hciconfig hci0 class 0x200420” using a startup script?

    2. I had same issue on Arch Linux, so I installed pulseaudio-bluetooth, reboot, and now appears as 0x0c0420. This is working good.

  4. Thanks for writing up such concise instructions on how to connect and operate the Pi as a Bluetooth sink. Unfortunately, there seems to be an issue with the instructions now (hardware revision? later release of Raspbian?).
    When following your instructions I run into a couple problems during the pairing process. First, I get a pop up saying “Device has requested a pairing. Do you accept the request?”. If I click “OK” I get the error message “Connection failed – GDBus.Error:org.bluez.Error.Failed: No such file or directory. Try to connect manually.”
    If I then try to connect through bluetoothctrl I get the following:
    “Attempting to connect to XX:XX:XX:XX…
    “Failed to connect: org.bluez.Error.Failed”
    These look to be similar to the issues the other user is having. Any thoughts?
    Running Raspbian Jessie May 2016 Version, release 2016-05-27, kernel 4.4 on R PI 3 B ver 1.2

    1. Update:
      I tried following the instructions with a Xbian image and appear to have had more success. Problem being now that there just isn’t any audio.

  5. Very good instructions, however I haven’t been able to get audio to play from my iPhone on the RPi. I was able to pair with my phone and connect to the RPi, but audio still comes out of the phone. I am using Raspian 8 and bluez 5.23 on a Raspberry Pi 3. I am able to pair and connect with the phone, and I have verified that audio is working on the RPi by playing a test mp3 file using the play command from the sox package.

    $ sudo hciconfig -a
    hci0: Type: BR/EDR Bus: UART
    BD Address: B8:27:EB:BC:64:3C ACL MTU: 1021:8 SCO MTU: 64:1
    RX bytes:14338 acl:291 sco:0 events:342 errors:0
    TX bytes:12808 acl:276 sco:0 commands:125 errors:0
    Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
    Link policy: RSWITCH SNIFF
    Link mode: SLAVE ACCEPT
    Name: ‘raspberrypi’
    Class: 0x200420
    Service Classes: Audio
    Device Class: Audio/Video, Car Audio
    HCI Version: 4.1 (0x7) Revision: 0xb6
    LMP Version: 4.1 (0x7) Subversion: 0x2209
    Manufacturer: Broadcom Corporation (15)

    $ sudo bluetoothctl
    [bluetooth]# show
    Controller B8:27:EB:BC:64:3C
    Name: raspberrypi
    Alias: raspberrypi
    Class: 0x200420
    Powered: yes
    Discoverable: yes
    Pairable: yes
    UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
    UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
    UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    Modalias: usb:v1D6Bp0246d0517
    Discovering: no
    [bluetooth]# devices
    Device D8:BB:2C:E5:8E:29 Rimadyl
    [bluetooth]# info D8:BB:2C:E5:8E:29
    Device D8:BB:2C:E5:8E:29
    Name: Rimadyl
    Alias: Rimadyl
    Class: 0x7a020c
    Icon: phone
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Vendor specific (00000000-deca-fade-deca-deafdecacafe)
    UUID: Service Discovery Serve.. (00001000-0000-1000-8000-00805f9b34fb)
    UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
    UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
    UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)
    UUID: Handsfree Audio Gateway (0000111f-0000-1000-8000-00805f9b34fb)
    UUID: Phonebook Access Server (0000112f-0000-1000-8000-00805f9b34fb)
    UUID: Message Access Server (00001132-0000-1000-8000-00805f9b34fb)
    UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
    Modalias: bluetooth:v004Cp6E00d0930

  6. Never mind. I figured it out. pulseaudio wasn’t starting due to a problem with the script start-pulseaudio-x11. I haven’t figured out how to fix that problem yet, but if I start pulseaudio manually I am able to connect and play music from my phone.

    Thanks for this great how-to!

      1. Ok i figured out how to start it manually. The only problem is that as soon as I execute the command, my machine becomes completely unresponsive.

        pi@raspberrypi:~ $ pulseaudio –start

        and stays like that forever. Help?

  7. Thank you for this tutorial! It is a very useful feature to have and there are no recent tutorials.

    I’ve followed the instructions, but my phone does not connect to the raspberry pi. The raspberry pi shows up under the bluetooth devices after being paired, however a connection is not made when clicking in.

    PS, my phone is android, and the gear icon next to the raspberry pi device gives no options other than to ‘forget’ the device.

    Please help

  8. Thanks, this worked well. One thing to note is that you have to disable wifi for the Pi3 to stream music without any stuttering.

    sudo ifconfig wlan0 down

    You can also set it up to auto-connect to your bluetooth device by adding a line to /etc/rc.local.

    echo “connect [MAC address of device] /nquit” | bluethoothctl

  9. I have the my iphone and the pi paired and it says they are connected but the audio wont come through the pi’s audio jack. I’m using the 0x200420 class. If anyone can point me in the right direction that’d be great

    1. Go to terminal/SSH, type “sudo raspi-config” (no quotes)
      Scroll down to option 7, “Advanced Options” -> Enter/Return
      Scroll down to option A4, “Audio” -> Enter/Return
      Choose option 1 for the analog jack. You may or may not have to reboot the pi.
      If this isn’t the fix, then there is something else wrong.


    1. It a problem with your internal wifi. If you are using internal BT and wifi, the sound starts stuttering. Disable wifi – problem will be fixed

  10. Hey thanks for the posts! It’s nice to see many people working together with the pi.

    Like you said many write ups are outdated. We currently have a project that does essentially what you have done but uses an installation script to do everything for those who are afraid of the cli.

    The project sets the pi up as an audio receiver and includes auto pairing when a device tries to connect, Streams music via a2dp, device controlled volume, AirPlay functionality for audio, and aux line input. It also sets up the necessary sounds cards. The project currently has 2 versions, one for use when no wireless network is available and another that piggy backs off an existing wireless network.

    You can find them here:

    The install is the best part and super simple.

  11. Hi and thanks for the instructions.
    I just wanted to ask if there is a way to autoconnect new phones without commands on the pi.

    1. There is, I suggest looking into my project here:

      Specifically look at the bluetooth or bt_pa files they should outline it if you have a decent grasp on pulse audio and bluetooth. If not, I would suggest using my project on a fresh Raspbian Jessie Image. If you don’t want all that is included change the and remove the lines that install the functions that you don’t want.

      1. Brett and others, .. great work
        I am using the Bluetooth part of the package, and it works very well as long as I don’t use the phone SDcard to hold the source music (use the phone memory).
        I am trying to get the resulting audio stream, from the pulse or alsa, into MPD. Since there is already a loopback module used to facilitate the BT audio path, do you have any idea how I can get the stream into MPD? Another loopback or do I need to formulate a stream using e.g. ffmpeg ? (I have tried both but not succeeded so far)

  12. hello,

    My iphone is connected on the pi but the sound still comes out of it, I tried to start pulseaudio manually but when I execute pi@raspberrypi:~ $ pulseaudio –start
    it answer me:
    E: [pulseaudio] main.c: Too many arguments.
    plz some help?

    1. @thibtd: Why are you trying to start pulseaudio manually? It should already be running. But, to answer your question, the problem is that you need two dashes before a long argument like “–start”. A single dash if for short (single letter) arguments.

  13. Dear OP,
    i just wanted to say i really appreciate what you did and i like your post.

    I’ve been searching for so long, because all the other tutorials were outdated and didn’t work for me.

    This worked on first try. Thanks

  14. thanks for your writeup
    recently installed the latest XBian on an Rpi3b and used your guide to set this up;
    result is working streaming audio from phones via rpi to hifi system

  15. I was able to connect my phone after a fresh install. I (for whatever reason) cant get audio to come through the 3.5mm jack. has anyone figured this part out?

  16. E: Package ‘pulseaudio-module-bluetooth’ has no installation candidate

    E: Unable to locate package bluez-tools

  17. Thanks for the detailed instructions. I followed them and everything works except the sound from my phone goes nowhere. The phone is connected (or the audio would come from its speaker). Phone volume is way up. But no audio from the pi via the phone.

    I am running Raspi 3 B+ with a very recent Raspian: 4.14.34-v7+. I have a speaker connected to the speaker jack, and it works when I use omxplayer with no audio. But… I think omxplayer is going to ALSA. The GUI audio controls work for the omxplayer audio. I followed the instructions exactly – copy/paste into the command line.

    I uninstalled pulseaudio before starting this, and reinstalled it.

    Thanks for any help.

  18. Thanks for this info! After much head-scratching, I discovered that I also needed to install the bluetooth module (sudo apt-get install bluetooth) for this to work. Perhaps this detail will help someone else.

    Now to figure out why the sound is so distorted. I read somewhere that disabling the WiFi can help, but alas, I already disabled it…

  19. Hey
    There is another way to do it (it worked better for me less latency and no 0x0 after reboot proble)

    apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-pulseaudio python3.5-dev python3.5-dbus

    install bluez from post

    git clone
    cd bt-audio
    sudo python3

  20. Hey all,

    I had set this up on my pi 3B+ running raspbian buster a while ago, worked like a charm. For whatever reason, a reboot probably, it suddenly stopped working. I want to share the fix for this.
    First Problem: Pulseaudio doesn’t start on boot, which I saw in one of the other replies on this page.
    Solution: run “pulseaudio –start” (or put it in rc.local)
    Second Problem: No audio output.
    Solutions: set audio out to the right one (my case was analog, so I ran “sudo amixer cset numid=3 1”) and you may have to turn volume up by running “sudo alsamixer” and pressing up a few times.

    Hope someone finds this helpful,

Leave a Reply

Your email address will not be published. Required fields are marked *