HFP on Raspberry Pi

The purpose of this post is to enable Bluetooth Handsfree Profile (HFP) on Raspberry Pi so that Raspberry Pi can act like as a handsfree speaker phone or a handsfree car kit.

There is one thing needs to be mentioned before start. The original plan was to use Raspberry Pi3’s on-board Bluetooth chip for this project. Unfortunately, it didn’t work. It seems that the problem is related with the chip. So, we have to use a Bluetooth dongle instead.

Here is the list of contents of this post.

– Hardware Prerequisites
– Software Prerequisites
– Steps
1. Setting Up
2. oFono
3. PulseAudio
4. Connect your Phone
5. Make a Call!
– Conclusion
– Reference

Let’s get started.


Hardware Prerequisites
Since Raspberry Pi doesn’t have microphone input by default, it need to be added. In this post, I’ll use a USB sound card with a 3.5 mm jack microphone.

Also, as mentioned above, we’ll use a Bluetooth dongle instead of on-board Bluetooth chip.

Raspberry Pi3
– Bluetooth dongle (Panda Bluetooth 4.0 USB Adapter)
– USB Sound Card (SYBA USB sound adapter / FG-UAUDV1-C119)
– Microphone with 3.5 mm audio jack
– Speakers with 3.5 mm audio jack


Software Prerequisites
Below are the required versions to enable Bluetooth HFP according to PulseAudio release note.

– Bluez 5.0 (or later)
– PulseAudio 6.0 (or later)
– oFono 1.13 (or later)


1. Setting Up
1-1. Connect Bluetooth dongle and USB sound card with Raspberry Pi.
1-2. Connect the microphone and speakers to 3.5 mm audio jacks on the USB sound card.
1-3. Boot up Raspberry Pi Board. If it’s not set up yet, please refer this post.
1-4. As described, we don’t use on-board Bluetooth chip. So it needs to be disabled. To do that, open “/etc/modprobe.d/raspi-blacklist.conf”.

1-5. Add lines below and save.

1-6. Then reboot the board.

1-7. After reboot, check dmesg and make sure there is no Bluetooth-related errors.

1-8. Also, make sure hci0 is UP.

The result should be like this:

If it’s DOWN for some reason, then turn it up.

2. oFono
2-1. oFono is not installed by default, so let’s install it.

2-2. Make sure the version is 1.13 or later.

2-2. Then, start the service.

You can check the service running like below.

3. PulseAudio
Since the preinstalled PulseAudio is 5.0, it needs to be updated to at least 6.0.

3-1. Uninstall the current PulseAudio.

3-2. Open “/etc/apt/sources.list”.

3-3. Add the line below:

3-4. Execute commands below:

3-5. Update the package list.

3-6. Install PulseAudio and its Bluetooth module:

3-7. Check the version and make sure it’s 6.0 or later.

3-8. Open “/etc/pulse/default.pa”.

3-9. Add “headset=ofono” on the line of ‘module-bluetooth-discover’.

3-10. To enable echo canceling, add the lines below:

3-11. Start PulseAudio.

4. Connect your Phone
4-1. Launch bluetoothctl.

4-2. Then, input below commands.

4-3. Start searching your phone. Make sure your phone is discoverable.

4-4. After detecting your phone, turn scan off.

devices command shows a list of found devices.

4-5. Then, pair, trust and connect to your phone by specifying the Bluetooth device address (in this case it’s “XX:XX:XX:XX:XX:XX”, please replace it wity your device’s address).

If everything is ok, you should see “successful” at the end of the result for each command like below.

5. Make a Call!
To make a call, we’ll use oFono test scripts which is included in the source code.
5-1. First, download the source and extruct.

5-2. Then, you can make a call by:

If you want to end the call, then execute:


Thanks for all the forums and articles I referred, now HFP is working on Raspberry Pi!
Next, I’m planning to apply echo canceling and ambient noise suppression, maybe equalizer.

Update (June 22, 2017):
Added one step (step 3-10) to enable echo cancellation. It seems that ‘module-echo-cancel’ does not only echo cancellation but ambient noise suppression. I haven’t check the noise suppression yet but I think the echo cancellation is working well based on my brief testing.


– Connect Bluetooth Headset To Raspberry Pi 3 (A2DP & HSP)

– PulseAudio 6.0 Release Notes –freedesktop.org

– PulseAudio Documentation –freedesktop.org

– module-echo-cancel –freedesktop.org

– Pulseaudio echo cancellation — Debian User Forums


Leave a Reply

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