{ the code ninja }

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 this link 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!

Exit mobile version