[Solved] Bluetooth headset mic not working/detected in Ubuntu 20.04

This is the headset i used but the following article can help you solve the similar issue for other headsets too. Also, the solution should work for other versions of Ubuntu.
Headset: Oneplus Wireless Z bass edition

Bluetooth: 5.0 (HFP, A2DP)

I am a developer and in order to take things and the development speed to next level I recently switched completely to Ubuntu 20.04 from Windows and everything was working great with the GNOME until i found a major issue that my Bluetooth headset microphone is not working in any conference calls.
Though my headset was working perfectly in Windows.

I found out that my laptop is using Internal Mic and not my Bluetooth headset mic which has much better microphone. Though, for audio output everything was working smoothly. I tried switching the microphone but I couldn’t see my headset microphone in the Input avaliable. I found that my headset only supports HFP(Hands-free Profile) of bluetooth and not the HSP(Headset Profile). After searching on the web, I found out that Ubuntu 20.04 uses Pulseaudio as it’s Sound server which only has out of the box support for HSP and not HFP. I tried switching to HSP/HFP but i wasn’t able to switch because PulseAudio only supports for HSP by default. Here is the screenshot of me trying to switch to HSP/HFP but stuck at A2DP :

Stuck at A2DP profile, can’t switch to HFP/HSP

To use HFP with Pulseaudio, they have mentioned in the documentation to use ofono and phonesim, but even after trying all the steps I wasn’t able to make things work and my microphone was still not detected.
In this attached link, you can find the post which has the steps to install ofono and phonesim. If you are getting the error “Failed to change profile to headset_head_unit” then also you can try these steps and see if things work out for you

OR

You can try my solution of replacing the sound server PulseAudio with Pipewire, which has support for most of the bluetooth profiles(HSP, HFP, A2DP etc). These are the steps to replace Pulseaudio with Pipewire :
Open your terminal and follow these steps:

  1. We will use a PPA for adding Pipewire to Ubuntu 20.04, which is maintained regularly:
    sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
  2. To update the PPA packages in your system do:
    sudo apt update
  3. Install the package
    sudo apt install pipewire
  4. There is also a dependency needed to be installed with pipewire otherwise you will face the issue of “Bluetooth headset won’t connect after installing pipewire” . Install the dependency by:
    sudo apt install libspa-0.2-bluetooth
  5. Now, To install the client libraries.
    sudo apt install pipewire-audio-client-libraries
  6. Reload the Daemon
    systemctl — user daemon-reload
  7. Disable Pulseaudio
    systemctl — user — now disable pulseaudio.service pulseaudio.socket
  8. Enable Pipewire
    systemctl — user — now enable pipewire pipewire-pulse
  9. If you are on Ubuntu 20.04, you also need to “mask” the Pulseaudio by
    systemctl — user mask pulseaudio
    I am not sure but if possible you can run this on other versions too.
  10. After a new update, you also need to enable pipewire-media-session-service
    systemctl — user — now enable pipewire-media-session.service
  11. You can ensure that Pipewire is now running through:
    pactl info

This command will give the following output, in Server Name you can see PulseAudio (on PipeWire 0.3.28)

pactl info

12. Things should be working by now and you can see your microphone in the Input section like this:

Headset microphone is now visible

If it doesn’t show then try restarting Pipewire by this command:
systemctl — user restart pipewire

You need to uninstall ofono and ofono-phonesim if you have them installed.
sudo apt remove ofono
sudo apt remove ofono-phonesim

You can also roll back the changes if you want by using :
systemctl — user unmask pulseaudio
systemctl — user — now enable pulseaudio.service pulseaudio.socket

If it’s still not showing your microphone, you can try rebooting once and remove and pair your bluetooth device again to check if it works now.

I hope i could have helped you in solving this problem. The quality of HSP/HFP isn’t good as it is used for 2 way communication(input, output) through bluetooth but you can always switch to A2DP when you want to only listen things like music,videos and not use your microphone and vice versa.

Ubuntu issues Fixed

These are the references I used to resolve the issue:

Bluetooth headset doesn’t connect after installing Pipewire

I am a Full stack software developer. Here, I will try to post articles about issues that I have faced during my development to help you resolve issues faster