Connect Bluetooth Headset Or Speaker

In this post, I’ll share with you the final solution that lets you connect your Bluetooth headset or speaker to Raspberry Pi 3.
You’ll be able to use both output speaker and input microphone.

By the way, thanks to the people who kept me updated in the comments, it was a long journey together (:

Firstly, let me sum up the root causes of this long time problem:

  1. Drop-out of ALSA support in Bluez v5 (replaced by PulseAudio).
  2. Unavailability of correct PulseAudio version for Raspbian Jessie.
  3. Incorrect audio rooting SCO-HCI for the Bluetooth chip BCM43438.

I solved the issues 1 and 2, but I couldn’t find a good solution for 3. For issues 1 and 2, I found how to install manually PulseAudio, with code sources, or using Debian backports. For issue 3, I used a BT-USB dongle that bypassed the internal Bluetooth chip and let me use A2DP and HSP profiles.

So the main problem wasn’t resolved, HSP that supports audio input wasn’t OK using the combo Wi-Fi/Bluetooth BCM43438. It took me a very long time to eliminate suspected parts one by one, and come up with the conclusion that we can’t do much more without the support of hardware suppliers. I contacted them but with no success.

This final solution has 2 steps:

  • Install latest PulseAudio version for Raspbian Stretch.
  • Re-route SCO Bluetooth audio using vendor command.

As usual, I recommend to start with fresh Raspbian, download it here:

Install the image in your SD Card.

Power ON Raspberry Pi, set up internet connection, SSH, …etc.

Update/Upgrade it:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo reboot

The update may take some time.


With Raspbian Stretch, PulseAudio is no more installed by default, they are now using Bluez-alsa.
At the same time, PulseAudio in the repository has now native support of both A2DP and HSP.

Install PulseAudio packages:
sudo apt-get install pulseaudio pulseaudio-module-bluetooth
dpkg -l pulseaudio pulseaudio-module-bluetooth

Installed version is 10.0. I remind that we need PulseAudio v6 or higher.

Bluetooth Connection:

Now we will connect to the Bluetooth headset (or speaker)
The same steps like in my previous tutorials using bluetoothctl.

Start Bluetoothctl tool and initiate it:
power on
agent on

Turn ON the headset, for mine I press and hold the button till I see white LED blinking + earcon.

Start the scan:
scan on

After some seconds, you will see the headset name and MAC address (xx:xx:xx:xx:xx:xx)
While scanning, we will kill Bluealsa, and start PulseAudio:
sudo killall bluealsa
pulseaudio --start

Go back to Bluetoothctl: Pair, trust and connect your device:
pair xx:xx:xx:xx:xx:xx
trust xx:xx:xx:xx:xx:xx
connect xx:xx:xx:xx:xx:xx

At this step, you should have you device successfully connected to Raspberry Pi.

A2DP Support:

Now let’s check that A2DP streaming is working.
We start by checking that PulseAudio is listing the Bluetooth sound card:
pacmd list-cards

The Bluetooth card will be index #1, you can also see the supported profiles (a2dp, hsp, off…)
Set A2DP as active profile:
pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx a2dp_sink

Set the Bluetooth device as output audio:
pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.a2dp_sink

Download this file and play it:
wget -P /tmp/
paplay /tmp/h2g2.ogg

HSP Support:

Now we will check for HSP profile. If you try to switch to headset_head_unit profile and use parecord to record your voice, it will not work. This is due to an incorrect audio routing of SCO. To correct that, use this command:
sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01

This is a vendor-specific hexadecimal command, that changes the Broadcom (or Cypress) BCM43438 configuration.

At this step, I couldn’t switch to headset_head_unit:
pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit

I got the error:
Failed to set card profile to ‘headset_head_unit’.

So I rebooted, removed the Bluetooth device and started again from the pairing step.
I can’t tell your what was the problem, but I’m used to this kind of instabilities, just try again.

This time the switch to HSP profile was OK:
pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit

Set the sink and source:
pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.headset_head_unit
pacmd set-default-source bluez_source.xx_xx_xx_xx_xx_xx.headset_head_unit

If you play an audio sound, you will notice the mono quality of headset audio.

Try to record your voice:
parecord -v /tmp/voice.wav

Play it back:
paplay -v /tmp/voice.wav

Short URL:
   Send article as PDF   

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!