Streaming Bluetooth Audio from Phone to Raspberry Pi using ALSA


This post shows steps to setup Bluetooth audio sink on Raspberry Pi using bluez-alsa. Bluetooth audio sink (A2DP sink) enables Raspberry Pi to receive audio from other Bluetooth devices (e.g. smartphone) and play it through the connected speaker. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker
  • Smartphone

 

Contents
– Steps
1. Bluetooth Pairing and Connection
2. Audio Routing
3. Verify
– Summary
– Troubleshoot
– Reference

 

Steps
1. Bluetooth Pairing and Connection
1-1. Launch BlueZ command line interface.

1-2. Setup a pairing agent.

1-3. Make the Raspberry Pi discoverable.

1-4. On your phone, search and select your Raspberry Pi from Bluetooth menu.

1-5. Confirm the pairing on both your phone and Raspberry Pi.

1-6. Authorize A2DP service (first 32 bits: 0000110d). [1]

Note: You may be asked about other services (such as HFP: 0000111E) depending on what services your phone supports. Just answer ‘yes’ to all the services if you are not sure.

1-7. Trust the phone so that Raspberry Pi will automatically accept connections from the phone from the next time.

Note: Replace “XX:XX:XX:XX:XX:XX” with your phone’s Bluetooth device address.

1-8. Exit from BlueZ command line interface.

 

2. Audio Routing
2-1. Forward audio from the phone to Raspberry Pi’s output.

 

3. Verify
3-1. Launch a media player and play some music on your phone. You should be able to hear the music from Raspberry Pi’s speaker.

 

Troubleshoot : Sound Cutting Out
Raspberry Pi’s (3 / 3+ / Zero W) on-board Bluetooth+WiFi combo chip has an issue and the Bluetooth sound cuts out when WiFi is enabled [2]. If you don’t need WiFi, you can just disable the WiFi interface to avoid the sound cutting issue.

If you need WiFi, one of the workarounds is to disable the on-board Bluetooth and use a Bluetooth dongle (e.g. Plugable BLE Adapter, Panda Bluetooth 4.0 Adapter) instead. Below is the steps to do that.

1. Open “/etc/modprobe.d/raspi-blacklist.conf”.

2. Add lines below and save.

3. Connect Bluetooth dongle on Raspberry Pi’s USB port.

4. Restart the Raspberry Pi.

 

References
[1] Service Discovery – Bluetooth SIG
[2] Pi3 bluetooth audio stutters with Wifi enabled

 

 

Sponsor Link

Leave a Reply

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