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:
- Drop-out of ALSA support in Bluez v5 (replaced by PulseAudio).
- Unavailability of correct PulseAudio version for Raspbian Jessie.
- Incorrect audio rooting SCO-HCI for the Bluetooth chip BCM43438.
In my previous posts, 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.
If you want to know more about what was done before, you can check my archives:
- Connect Bluetooth Headset To Raspberry Pi 3 (30/08/2016)
- Connect Bluetooth Headset To Raspberry Pi 3 (AD2P only) (25/03/2017)
- Connect Bluetooth Headset To Raspberry Pi 3 (A2DP & HSP) (25/03/2017)
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:
https://www.raspberrypi.org/downloads/raspbian/
Install the image in your SD Card, find more help here:
https://www.raspberrypi.org/documentation/installation/installing-images/
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.
PulseAudio
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-bluetoot
h
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:
bluetoothctl
power on
agent on
default-agent
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 http://youness.net/wp-content/uploads/2016/08/h2g2.ogg -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.
/tmp/h2g2.ogg
Try to record your voice:
parecord -v /tmp/voice.wav
Play it back:
paplay -v /tmp/voice.wav
IT WORKS!
Please post a comment if you have any question or suggestion.
Sources:
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp#comment-2484
Next steps:
- To improve the tutorial, auto switch to Bluetooth after connection, and disable idle module.
- To use bluez-alsa instead of PulseAudio, since it is by default in Raspbian Stretch.
- To add the command in next Raspbian release?
- To find explanation of what the command does to Bluetooth adapter (sound quality…)
Hello
Sorry but I get troubles with the Bose SLIII
here is the description :
pacmd list-cards
2 card(s) available.
index: 1
name:
driver:
owner module: 7
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Mono analogique Output (priority 200, available: unknown)
output:analog-stereo: Stéréo analogique Output (priority 6000, available: unknown)
off: Éteint (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Stéréo analogique
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#1: Monitor of bcm2835 ALSA Stéréo analogique
ports:
analog-output: Sortie analogique (priority 9900, latency offset 70000 usec, available: unknown)
properties:
index: 6
name:
driver:
owner module: 32
properties:
device.description = “Bose SLIII”
device.string = “08:DF:1F:4D:1E:59”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “hifi”
bluez.path = “/org/bluez/hci0/dev_08_DF_1F_4D_1E_59”
bluez.class = “0x240428”
bluez.alias = “Bose SLIII”
device.icon_name = “audio-card-bluetooth”
profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: yes)
off: Éteint (priority 0, available: yes)
active profile:
sinks:
bluez_sink.08_DF_1F_4D_1E_59.a2dp_sink/#4: Bose SLIII
sources:
bluez_sink.08_DF_1F_4D_1E_59.a2dp_sink.monitor/#6: Monitor of Bose SLIII
ports:
hifi-output: HiFi (priority 0, latency offset 0 usec, available: yes)
properties:
hifi-input: HiFi (priority 0, latency offset 0 usec, available: no)
properties:
only a2dp_sink gives an answer, else headset is unknown
the main difference is to priority and latency which are quite different from the alsa jack output
when reading of the .ogg file is set , there is reading but any sound out from the bose
I set the hcitool but I don’t know what ’s for.
When I tried bluez in terminal mode, I got a message : frame isn’t transmitted approximatively
I noted than the pulseaudio (pavucontrol ) never gives information about the bose in output devices
Any suggestion will be readen attentivily.
Thanks a lot by Philippe
Hi Philippe,
What do you want to do?
Your speaker has only a2dp_sink so you can only use it to stream audio, I searched for Bose SLIII and I didn’t find that it has an internal microphone.
Youness,
Tried your instructions but cannot get set profile and sink. Errors on each.
I have a headphone unit working well on a2dp but have been unable to get speaker working.
When trying the speaker it pairs and connects but there is no card listed for the unit.
As a sidenote….i tried a completely clean system (using stretch) and couldn’t get either unit to output sound. Headphones pair and connect and show as card1 but have been unable to activate profile. Speaker pairs and connects but do not even show as card. I have been reading all your efforts and will continue to monitor your site. Thanks for all your hard work.
Larry
Hi Larry,
Your devices work for other PC oh smartphone? Do they need any specific step like insert a pin code (0000)… Etc?
What if you try to set profile to “off” before setting it to another profile, sometimes this works.
Did you stop bluealsa? If not maybe it takes your Bluetooth card and doesn’t let PulseAudio list it.
Don’t give up I’m sure we can make it work.
Hi Youness, didn’t expect such a quick reply…..thanks.
Buth units work well with android and ios hardware.
I did turn off bluesalsa and noticed that the profile was turned off in pavuaudio so i rebooted and turned the profile on.
I will be busy with other things today but will try to capture some info when i get a chance.
Seems like all works well in your guide until I check cards as explained above. And seems odd that i can get a card for the headphones and can connect bit cannot get audio to output. Both units appear to suppory a2dp and hfp.
I receive notifications on my phone, so except if I’m sleeping, I will answer comments few minutes later 🙂
I recommend you to do everything in command line, I can’t guarantee that GUI tools are updated and fully support PulseAudio and Bluez.
For your information, I’m doing everything by SSH so I never use an interface to configure Bluetooth, maybe this detail hide some errors on your side.
Hey Guys,
I thought I’d highjack the comment section of your post, Youness, and ask for help in a similar setup I’m trying to get working: In my case I have an USB audio interface with in- and outputs connected to a Raspberry Pi Zero. I want the Pi to connect to another device (pc, ipad…) registering as a bluetooth headset (using hsp). So far following a mixture of your tutorial and this link (https://didier.io/post/raspberrypi-stream-sound-over-bluetooth) I managed to configure the pi as a bluetooth speaker. But I can not get it to send the microphone input of the audio-interface over bluetooth… Any ideas? I tried different values for the Class parameter in /etc/bluetooth/main.conf .. So far without success.
Any help or ideas would be greatly appreciated!
Jan
Did you tried the module-loopback? With that you can route a source to a sink. If I get your problem, you want that the Raspberry Pi Zero W receive the Bluetooth microphone and sends it to another device?
hello jan were you able to accomplish using pi zero as headset for other devices?
Please let me know as i am working on something similar
Hi to everyone
A lot of responses
some progress today
1 to youness
the bose SLIII is only made for playing music
and I want to run it in my home without connection to the Pi3 except by bluetooth
2 to Larry and youness
this afternoon, after some trials with terminal and gui nothing get
but just now afer restarting the Pi3
I start the Bose
I click on bluetooth : make discoverable, add device and wait for bose, paired it
and
suprise : in a terminal I just killer the bluealsa
and in pulseaudio gui I got the Bose in output device
in Bluemindo I started playing a music
go back to every sourdine button in audio, pulseaudio output and playing
now it’s running nearly well.
Is the main progress would be stop the bluealsa service in console?
I’ll try later, for instance I listen with pleasure.
Thanks a lot.
Philippe
De rien Philippe.
As I said before I don’t use GUI because I already had some problems and they don’t implement latest changes of PulseAudio and Bluez.
Also bluealsa is started by default so we need to kill it before.
I think that it is now OK for you, as reported by someone here, the reconnnection of Bluetooth is done with no additional command.
Sorry youness
but 45mn after the starting , I lost the stream on the bose
I try to restart but nothing for instance.
A new pi restarting give me a bose instance
how :
1 turn on the bluetooth by clicking on its icon
2 click on the audio speaker to connect the bose if exists; if not add …
3 the bose answers by a bip
4 open a terminal and kill the bluealsa service
5 go to bluetooth, verify bose is connected
6 then start the music player ( bluemindo for me )
7 choice the file to play
seriously it’s fine
The question : it’s little complex
Philippe
Hi,
I think you can set some steps in the boot, but I didn’t test before so I’ll just suggest that:
Create a .sh file (e.g. bluetooth_auto.sh):
sudo nano bluetooth_auto.sh
Add the lines:
#!/bin/bash
# disable bluealsa
sudo killall bluealsa
#start pulseaudio
pulseaudio --start
#start Bluetooth
sudo systemctl start bluetooth
Save it with CTRL & X, then Y, then ENTER.
Make is executable:
sudo chmod +x bluetooth_auto.sh
Copy it into in init scripts:
cp bluetooth_auto.sh /etc/init.d/
Then this command:
update-rc.d /etc/init.d/bluetooth_auto.sh defaults
Try that, if it works we can check to automate Bluetooth connection.
Hello Youness,
Thank you! This has been frustrating me for the last two weeks!
I’m so close, yet so far! I’m getting the error you mention in the article:
Failed to set card profile to ‘headset_head_unit’.
I’ve restarted and re-synced the bluetooth device: (https://www.amazon.co.uk/gp/product/B076HRH34T/ref=oh_aui_detailpage_o03_s00?ie=UTF8&th=1)
But, I still seem to get that error every time. I’ve tried a couple of things I found digging through some old forum posts, but nothing seems to fix the problem.
I’m not sure what to try next, I was hoping you may know? Here’s the pacmd card listing: https://gist.github.com/anonymous/6fd573116eb37fcf1a917301ebfe8725
The profile headset_head_unit does appear in the listed profiles, but I can’t set it as the active profile for some reason, I can set it to a2dp and off however.
Could it possibly be because the listed protocol is (HSP/HFP) as opposed to being solely HSP?
Thanks for any help and for all the effort you’ve put into solving this problem so far!
Your device should support HSP just like mine from what I see in the logs.
Did you try to just re-connect it? Or you completely remove it and pair it again? Do a complete remove and pair again, this kind of bugs in random and many reasons can lead to it.
Also, did you connect it to a PC for example to check that there is no additional steps, like entering PIN code or something like that?
So, in the pacmd card listing it denotes that both a2dp_sink and headset_head_unit are both ‘unknown’ to be available:
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
However, I am able to switch the card profile and default-sink to a2dp_sink and play the audio file. But again when I try to switch the profile to headset_head_unit it fails with the above error.
Oops! We seem to have posted replies simultaneously.
So, I just tried connecting it to my computer and managed to both play and record audio when it’s connected. I’ve also just tried this on my phone and managed to do the same, both without requiring a passcode or any authentication step. The device simply connects.
What I’ve tried in terms of removing the device is to open bluetoothctl and remove the device from there. Is this what you’re referring to?
Yes that’s it. Remove and pair again solved my bug.
I’ve tried this multiple times and it doesn’t seem to be solving the issue for me.
Here’s what I’m doing step by step, also FYI I’m using a Raspberry PI Zero W with Raspbian Stretch Lite.
1. SSH into the Raspberry PI
2. Enter bluetoothctl
3. Power on, agent on, default agent
4. Scan on (wait for the device to appear)
5. Exit bluetoothctl (I’ve also tried this by not exiting, but instead opening a second SSH connection).
6. sudo killall bluealsa (This reports as no process found to stop)
7. pulseaudio –start
8. bluetoothctl
9. pair, trust, connect (all successfully, the device itself pings to notify a successful connection)
10. Set up a2dp, download the file and play the ogg file. The device plays the audio file perfectly.
11. Correct audio routing
12. Attempt to set profile to headset_head_unit
And I then receive the same error again.
1. bluetoothctl
2. remove device
3. reboot
Repeat and I get the error again?
6- I think that Stretch lite comes with not audio manager for lightweight distro, that’s maybe why it reports no process found.
12- You try to switch to “off” between ad2p_sink and headset_head_unit?
The Pi and Pi Zero W have the same Bluetooth chip, but no idea if they have the same hardware design. If not, this is just frustrating and can’t be addressed by my kind of amateur skills… 🙁
Do you have a Raspberry Pi 3?
Re: Youness February 12, 2018 at 9:05 pm (http://youness.net/raspberry-pi/how-to-connect-bluetooth-headset-or-speaker-to-raspberry-pi-3#comment-2859)
|
| 12- You try to switch to “off” between ad2p_sink and headset_head_unit?
|
I’m able to actively switch between off and ad2p_sink, but not between off and headset_head_unit or a2dp_sink and headset_head_unit.
|
| Do you have a Raspberry Pi 3?
|
Yes, I’m going to try using Raspain Stretch with the GUI rather than Strech Lite. If that fails I’ll try my Model 3 B+ and see if I get the same issue, if not at least we know whether the problem lies in Stretch Lite or the Zero W’s hardware design.
Thanks for the help so far!
Thank you too for letting us know about the results of your tests.
Hi,
I’m facing exactly the same issue than Connor.
Setup of a2dp and sound tests run perfectly.
However headset_head_unit setup leads to “failed to set card profile..”
I found interesting input on another forum https://bbs.archlinux.org/viewtopic.php?id=209979.
It seems to be linked with the fact that pulseaudio does support HSP but not HFP.
@Connor, I assume that if you run info in bluetoothctl, you’ll find that your device is HFP..
The guy found a patch and could fix the issue.. but it’s far too complex for me to understand everything.. 🙁
I’ll try anyway but I’m sharing the link in case you manage to apply that fix and share a rookie-proof description of the solution.
++
Hi,
HSP and HFP are two different profiles.
We mention them together because HFP is an HSP (audio) plus some AT commands to take the call, end it,…etc.
PulseAudio since version 6 supports HSP natively, while HFP requires additional support like oFono (that I never used).
Back to your problem, I don’t think that the problem is that you have only HFP, unless you have a headset dedicated to calls (I mean, you should have a green button to take a call, a red button to end it…), I think that you have HSP profile but you went into random bug that we all had, and that each one resolved by a mysterious solution like reboot the Raspberry Pi, remove and pair again the headset, try to switch to profile off, …etc.
As I say all the time we are using unstable Bluetooth solution so expect fuzzy bugs…
Good luck.
Thank you for your reply.
I tried many reboots / switchs to all profiles / praied a lot.. with no success.
However, I tried with another device, which could switch to headset_head_unit profile at the 1st try.
Recording worked well. 🙂
..Only issue is that the sound has a terrible metalic noise. I might not be able to perform the NLP tests that I initialy had in mind.
Thanks anyway for your great contribution to my project.
++
You’re welcome.
Try to adjust the input level (pavucontrol maybe?), and turn off WiFi because it impacts the Bluetooth streaming.
If you’re working on some speech recognition project, I think that HSP mono quality is enough and doesn’t have to be like for us humans 🙂
I don’t pay attention to that status because even if it is unknown I can use the profiles…
Hi youness
the problem continues with my bose
this evening it’s impossible to connect or remove the bose. I get error message about tre gdbus
May I send you a scrennshot about errors
The messages texts are :
remove device : removal failed – GDBus.Error:org.bluez.Error.NotReady: Ressource Not Ready
The other one:
Connecting Audio Device: Failed to connect to device-
GDBus.Error:org.bluez.Error.NotReady: Ressource Not Ready. Try to connect again..
But I tried for one and half hour.
Is it a bug?
Try reinstall bluetoothctl:
sudo apt-get –reinstall install bluez-utils
Hi youness
me again, sorry. But I’ld to understand how it’s work
My last trial :
I made the bluetooth script as above, I got an error about the LSB tags when I run the update.rc command
I start again the Pi3 and connection to bose started immediatly
I get rid of bluemindo and install aqualung
I run aqualung on a Music directory
But the pavucontrol doesn’t see the connected bose, so any music out in my ears
if I use the wire between the jack connector’pi and the bose’jack, I got audible music.
Do you know how we could get the bose-bluetooth line in the output-pavucontrol as soon as we have connected bose in the audio icon and in the bluetooth icon on the taskbar?
Sorry for such disturbing elements
Thanks a lot for any response.
Philippe
Hi Philippe,
Keep in mind that this is unstable setup, and with graphical interface it is more unstable, even if you see something displayed like icones it doesn’t mean that it is working…
In order to get Bluetooth in pavucontrol as soon as it is ON you have to create script that start automatically PulseAudio and also Bluetooth and you need also to have the module switch on connect like here: https://wiki.archlinux.org/index.php/Bluetooth_headset#Setting_up_auto_connection
I’ll try to do a script like that in the weekend.
I’ve tried the script you suggested as well as turning turning on the module switch I can get the ogg to play but then after I reboot it doesn’t work 🙁
I tried putting the created script in rc.local as well as the location you suggested, doesn’t make a difference. I can’t connect after a reboot.
Thanks for this article. I actually had this working “right out of the box”, which makes the problems even more annoying. I had jessie running, and the only thing I did was to bluetoothctl pair and connect my Bluetooth speaker, and it connected, and STAYED connected. I could play mp3s of the command line, and use text-to-speech which was part of the project.
Then suddenly, while testing, the audio stuck and repeated (broken record, extremely fast), and I had to turn off the Bluetooth speaker. Since then, I have not been able to pair again using the default alsa. I since upraded to stretch, it only worked using pulseaudio, but sound is very choppy. It sure would have been nice to have a simple and working A2DP and HSP.
I’m not sure how did you do to make it in Jessie with ALSA, for me the possible way it to use bluealsa in Stretch. Are you familiar with that? You can set up a config file then your speaker will work all the time in A2DP using bluealsa.
I’m writing a post for bluealsa, but I need more time to test it.
That will be great! It’s best to use the standard libraries, I guess. You are probably right, it must have been with pulseaudio. I had a 6 month break from my project, so I can’t really remember how it was set up. But I find it strange how Bluetooth audio worked perfectly, and then suddenly, out of the blue (tooth ;)) it stopped working, even connecting didn’t work.
Well, I don’t know how did you upgraded from Jessie to Stretch, but I think that now bluealsa is started by default and that is what blocked your Bluetooth. Try this command: sudo killall bluealsa, if it works it means bluealsa is taking place of PulseAudio, so follow the post to get back your PulseAudio A2DP.
Thanks for your replies.
Actually, it stopped working before I updated! The reason I went with the update was to see if that fixed things. sudo killall bluealsa gives: no process found
Ok, and PulseAudio is started?
Hi youness
Thanks a lot for all your answers
The bose is now running, how?
using what you say by console.
I uninstall bluealsa… may be a bad idea for another app?
If I try to resume
switch on the bose
start bluetoothctl and the steps power on agent on default-agent : we wait for yes
scan on sees the bose in some seconds, pair, trust and connect even if we havn’t answers «on» with pair and trust, connect has to get connected in any case.
open pavucontrol
in parallel : pacmd list-cards in which we wait the bose recognition
and the 2 other commands
pavu reacts to the pacmd commands
If we start pulseaudio in console, the streaming flow is bad because the console prints out the levels of the streaming and creates interruptions.
Running good for 3 hours, fine! The dream!
For me, an improvement in order to click on something once would be better for start recognition and real connection of the bose. I can wait now I learned the console steps.
Bye! Pleasure to meet you!
Philippe
Good improvement!
Dear Youness, first of all i want to express my gratitude for sharing your knowledge/time with us.
i have read all your project since the begin and applied to my situation.
every tink whent ok and i was able to pair and connect the device in both protocol (hsp a2dp), i succeded to record and play a recorded audio…great…
i would like to automate the connection after reboot , and i saw some indication that you suggested and i’ll try to applicate.
what is not very clear to me is what in the procedure is permanent and what must be automated at reboot.
for example, this command should be repeated at every boot?: sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01
i try to explane my project that is now in the first step and maybe i’ll get some suggestion.
we are a group of motorcycle bikers, we ride in goup and we all have bluetooth devices in the helmets connected to the smartphone and some of us are also connected in intercom from bike to bike.
the range of the bluetooth in certain condition is not enough so we want to use rtx radios (uhf/pmr).
The project is to connect a common two way radio with the the bluetooth installed in the helmet.
the idea is to connect via bluetooth a raspberry to the interphone (done, to be automated) and than to physically connect the raspberry (probably wit an extra audio dongle) to the mic/spk connector of the radio.
when i am talking into the Helmet’s microphone, the audio should exit from a connector and enter in the mic connector of the radio.
what the radio receive a signal, the audio getting out from the spk connector should enter in the raspberry and streamed into the helmet.
Any suggestion? ……Tks in advance
Hi Fabrizio,
Sorry for late answer.
What can be automated are:
– Kill bluealsa
– Start PulseAudio
– Switch to Bluetooth after connection
I think this is enough, if you do that, just after turning ON the headset it will be connected to the Raspberry Pi.
The command hcitool is done one time.
For your project, you can connect a wired USB card, that has two jack for microphone and speaker, is that OK for you?
Then, you route the sinks and sources from USB card to Bluetooth card.
It is just a proposal I didn’t do it, so try it and check for other solutions too.
Fabrizio, other readers.
I’ll give a try for a script automating steps this weekend, I’ll then send you any update.
Hi Youness!
First of all I’d like to thank you for your work!
Did you have time to try to make a script to automate these steps?
Thanks!
Sorry not yet 🙁
Minor nit
For the install pulse audio commands, this looks incorrect:
sudo apt-get install pulseaudio pulseaudio-module-bluetoot
I think it should be bluetooth at the end, instead of bluetoot
Also, I would disable the internal bluetooth interface on the pi3
cd /boot
sudo nano config.txt
Add to config.txt:
#disable the internal bluetooth
dtoverlay=pi3-disable-bt
You may also need to do this (I haven’t tried it yet)
sudo systemctl disable hciuart.service
I just bought an asus bluetooth module, and plan to try your instructions to install it, thanks.
Hi Randy,
EDIT, thank for corrections.
Why you want to disable internal Bluetooth? The aim of post is to not use external Bluetooth dongle, but if you purchased one, yes I recommend you to use it as you will have better audio quality than internal Bluetooth.
The internal bluetooth on a pi3 or pi zero w can interfere with the internal wifi. When I had both enabled, I would get stuttering in the sound, quite annoying. If you use either an external bluetooth or external wifi, problem goes away. I think its a bluetooth driver issue.
Yes that’s what I’m telling people when they come with audio bad quality, it worth to take external Bluetooth for the moment.
[…] http://youness.net/raspberry-pi/how-to-connect-bluetooth-headset-or-speaker-to-raspberry-pi-3 […]
Hello,
Yes, I have the same issue with distorted audio.
I believe the problem may be caused by a sample format mismatch.
I can hear it when I loopback the audio.
What exactly is the following command in the final solution supposed to do?
“sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01”
Is there a byte-for-byte breakdown?
Is the sample format encoded in there somewhere?
-Cheers
JK
Hello,
I’m not sure the the problem is the command.
I don’t have a breakdown explanation of the command (I doubt that there is a datasheet to use it…) But if I get it I’ll update the post.
Will this work with an external bluetooth adapter such as
http://www.lemosint.com/bluetooth/bluetooth_serial_adapter_details.php?itemID=612
Im thinking about putting this in the office and hooking up my Dre PowerBeat3’s to it and running google home on the Pi. This way ive got Google home hooked up playing audio through my headphones and listening to commands from me on the attached mic
Yep give it a try.
Hi Youness,
I’m facing a weird situation: I have followed all the steps and I didn’t get any error. I got the sound when I types paplay /tmp/h2g2;ogg on A2DP, but no sound on HSP.
I tried to remove, reconnect, reboot… multiple time, but I doesn’t change a thing…
That’s really weird because I didn’t got any error…
Config, RP3 with doss soundbox.
Thanks a lot!
This is reported by several people and me too faced it, it comes and lefts with no logical reason. Sorry.
Hi,
Same problem as SouSouleBarbu. I followed all the tutorial, can hear h2G2.ogg, but cannot hear an MP4.
When I want to change in Blueman-Manager the audio profile to A2DP Sink, it return “Failed to change profile to a2dp_sink”.
But even on Headset Head Unit (HSP/HPF), on my Philips SHB7000 head set, no sound.
Best Regards from France,
Philippe
Hey Youness,
Ive given it multiple trys but keep getting the “failed to set card profile to ‘headset_head_unit’ ive removed the device and rebooted i can hear audio but cant record.. Any other suggestions ? these are powerbeat 3’s im trying with a pi 3
index: 1
name:
driver:
owner module: 24
properties:
device.description = “Theobeats”
device.string = “2C:33:61:D8:BC:B4”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “headphone”
bluez.path = “/org/bluez/hci0/dev_2C_33_61_D8_BC_B4”
bluez.class = “0x240418”
bluez.alias = “Theobeats³”
device.icon_name = “audio-headphones-bluetooth”
profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: no)
off: Off (priority 0, available: yes)
active profile:
ports:
headphone-output: Headphone (priority 0, latency offset 0 usec, available: unknown)
properties:
headphone-input: Bluetooth Input (priority 0, latency offset 0 usec, available: no)
properties:
more to add to my post above…
pi@raspberrypi:~ $ systemctl status bluetooth
● bluetooth.service – Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-03-10 23:13:26 UTC; 28min ago
Docs: man:bluetoothd(8)
Main PID: 524 (bluetoothd)
Status: “Running”
CGroup: /system.slice/bluetooth.service
└─524 /usr/lib/bluetooth/bluetoothd
Mar 10 23:13:26 raspberrypi bluetoothd[524]: Endpoint registered: sender=:1.9 path=/A2DP/SBC/Source/1
Mar 10 23:13:26 raspberrypi bluetoothd[524]: Endpoint registered: sender=:1.9 path=/A2DP/SBC/Sink/1
Mar 10 23:13:32 raspberrypi bluetoothd[524]: Endpoint registered: sender=:1.17 path=/MediaEndpoint/A2DPSource
Mar 10 23:13:32 raspberrypi bluetoothd[524]: Endpoint registered: sender=:1.17 path=/MediaEndpoint/A2DPSink
Mar 10 23:13:32 raspberrypi bluetoothd[524]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)
Mar 10 23:13:38 raspberrypi bluetoothd[524]: /org/bluez/hci0/dev_2C_33_61_D8_BC_B4/fd0: fd(29) ready
Mar 10 23:17:04 raspberrypi bluetoothd[524]: Unable to get io data for Hands-Free Voice gateway: getpeername: Transport endpoint is not connected (107)
Mar 10 23:17:33 raspberrypi bluetoothd[524]: /org/bluez/hci0/dev_2C_33_61_D8_BC_B4/fd1: fd(29) ready
Mar 10 23:26:24 raspberrypi bluetoothd[524]: Endpoint unregistered: sender=:1.9 path=/A2DP/SBC/Source/1
Mar 10 23:26:24 raspberrypi bluetoothd[524]: Endpoint unregistered: sender=:1.9 path=/A2DP/SBC/Sink/1
I am using raspberry pi zero w. with PA 10.0 and Bluez 5.43.
I have manage to use my headset in A2DP mode without problem.
But when I change to HSP profile no sound heard or mic record.
by using the hcitool command(sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01),
I was able to hear sound and record.
But my problem is that the sound is very bad and slow like motion.
I am suspecting it has something to do with the pi zero w chip(BCM2835)
according to this link:https://www.raspberrypi.org/magpi/pi-zero-w/
can anyone help me with relevant hcitool command for this chip?
Thanks in advance!
Thank you for the real good work. I only required the A2D2P-support and due to your post it works the first time without sticking around for me. Using Raspberry pi zero w with Riva Turbo X on Raspbian Stretch. I issued the sound beeing slow motion alike, too. Hope to fix it in this weekend.
I still don’t get sound on Bluetooth speaker/headset. I do get connected.
After giving command (one of the first steps described): ‘sudo killall bluealsa’, I get ‘Invalid Command’
So can not follow your Tutorial any further..
Also ‘pacmd list-cards’ or further ‘pacmd’ are not recognized and I get ‘Invalid Command’
http://youness.net/raspberry-pi/how-to-connect-bluetooth-headset-or-speaker-to-raspberry-pi-3
Hi,
Got a bit further, but now get (where: ’90:1F:F1:3C:AF:41′ is my Bluetooth speaker ‘S10’):
pi@raspberrypi:~ $ pa is too loncmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.
===
pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmpi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmpi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
anapi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
alsa.driver_name = “snd_bcm2835”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.d set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.d set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card fopi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card fpi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.ound by this name or index.pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.und by this name or index.
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberpi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.rypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offsepi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card foupi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.nd by this name or index.pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.t 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offsepi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.t 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card foupi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.nd by this name or index.set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.log-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm28pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.35 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-card-profile bluez_card.90:1F:F1:3C:AF:41 a2dp_sink
No card found by this name or index.
Hi Youness,
any updates about this ? The profile Headset Head Unit is always not available for me, no matter how many time i reset.
I did a xargs grep on the whole system and this line (headset_head_unit) is referred in two files :
Binary file /usr/lib/pulse-10.0/modules/libbluez5-util.so matches
Binary file /usr/lib/pulse-10.0/modules/module-bluetooth-policy.so matches
Hope this helps.
I have been looking myself in the file but nothing there that i modified impacted the behavior of pulseaudio
Salim
Hi Salim,
No updates on my side. If there is any success me or readers will share it.
Meanwhile use a dongle to get it work.
Ok then is there anyway for pulseaudio to be updated to 11.1 on Raspbian ? If you could share how to do this it would be nice. It seems like they talk about this issue on the patch notes.
You can compile PulseAudio from sources, I did it here: http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp, but no guarantee that this will solve your problem. Can you give me the link to the patch that you are talking about please?
Changes at a glance
Support for newer AirPlay hardware
USB and bluetooth devices preferred over internal sound cards
The default sink and source configuration is remembered better
Bluetooth HSP headset role implemented
Bluetooth HFP audio gateway role implemented (requires oFono)
Bluetooth HSP audio gateway and HFP hands-free unit roles can be enabled simultaneously
Upmixing can now be disabled without bad side effects
Avoid having unavailable sinks or sources as the default
Option to avoid resampling more often
Option to automatically switch bluetooth profile to HSP more often
Better latency regulation in module-loopback
Changed module argument names in module-ladspa-sink and module-virtual-surround-sink
Fixed input device handling on Windows
Improved bluetooth MTU configuration (warning! this causes some hardware to not work any more, see the details below for how to fix it)
GNU Hurd support
Applications can request LADSPA or virtual surround filtering for their streams
Support for 32-bit applications on 64-bit systems in padsp
https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/
Those are for 11.0, 11.1 is out atm.
Please let me know if you need more help, ill keep probing here.
I managed to update to 11.1 Pulseaudio, i will let you know tonight any changes.
Good luck!
I confirm same issue happens with 11.1… Failed to set profile
I have tried with PROFILE=sco with built in bluealsa, same issue.
In line 1799 of module-bluez5-device.c @ https://git.devuan.org/walshb/pulseaudio/blob/9d219dac2000a04b697106f01bf42498b2e90e42/src/modules/bluetooth/module-bluez5-device.c we can see “a2dp_source”, _(“High Fidelity Capture (A2DP Source)” …
What do you think? Is there a a2dp profile for input ?
I think that there is no problem with PukseAudio they already implemented the profiles since many releases, the problem for me is Raspberry Pi Bluetooth instability.
Youness,
Sorry to bother you that much. If the bluetooth firmware is the problem, here is https://github.com/seemoo-lab/nexmon
If you know someone that can modify the firmware and inject it using that tool would be great ( if of course the firmware is in fault)
Hi Yonuness,
I have tried with your steps many times with out any success. i am trying to connect MI bluetooth speaker (http://www.mi.com/in/mi-bluetooth-speaker-basic2-white/) using HSP. not able to set headset_head_unit profile. any kind of help/suggestions will be appreciated.
Thanks
Hello. I performed this configuration on my Raspberry Pi Zero W (with newest updates and upgrades) with two headsets and the result is the same. The record voice is somehow overdriven and digitized – just unrecognizable. So for the one hand it works for me – for the other – no.
This has been my experience. I was successful in configuring the RPI3 with a UEBOOM 2 and a MPOW headset and microphone. Unfortunately, the recorded voice is very bad (overdriven and digitized is a good description). Sadly, I probably need to go back to the Bluetooth dongle approach. I am running Wifi and bluetooth at the same time. Another poster mentioned the RPI3 Model B+ may have better performance.
The dongle remains the easiest solution for the moment.
I did get a chance finally to try this out on a RPI3 Model B+ to see if it would make any difference. I got the same result with poor quality on voice recordings. The Bluetooth dongle approach is still your best bet.
Just one other note. i tried this with both Wifi enabled and disabled. The poor sound quality of the recording is identical.
Excellent instructions.
They helped me solve my problem were the bluetooth adapter was not showing up in the card list.
one recommendation.
these instructions could be a little clearer. When killing the bluealsa we need to use the “exit” command to exit the shell or move to another terminal window. If exiting the shell we need to re-enter with “bluetoothctl” and exit again prior to the pacmd list-cards cmd… It lost me for a few minutes.
……
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
…
Again, overall excellent work.
John
Thinking this could be a good way for me to setup a RPI as an outdoor solar powered bluetooth microphone to pick up nature sounds and then have an inside bluetooth speaker setup to listen to the outdoors.
That sounds like a great idea. Check the reachability of Bluetooth if it is enough for you, otherwise you need another mean of transmission.
Hey – 1st, thanks – it works.
2d – I took the steps [ ie. bluetoothctl <<< "pair C9:5A:0…" etc killall …] and run as a script when I login. Problem is if my speaker is connected, it Disconnects. And I have to run it a second time. [ ya poor me ] but it's a pita. Is there a command where I can say: if ( BT == connected ) don't run script;
3d – thanks again.
c
I don’t know about such command sorry, but if I find something I’ll contact you.
It worked!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thanks!!!!!!!!!!
: )
How did you get it to work?? I followed the entire tutorial, rebooted several times with no luck.
I did the same steps as I wrote in the tutorial. If you want an alternative you can buy a Bluetooth-USB dongle.
pacmd list-cards
For HSP Support
sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01
Next use this command instead of the one mentioned in the tutorial (pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit)
pacmd set-card-profile 1 headset_head_unit
Card #1
Name: bluez_card.1C_52_16_15_EF_14
Driver: module-bluez5-device.c
Owner Module: 24
The two commands are equal, I use the card name instead of the index number because it keeps changing after re-connection.
Hello youness,
I followed your tutorial and tried rebooting repeatedly, i still get the error ,”failed to change profile to headset_head_unit.
please suggest a solution.
I am working with the latest version of raspbian stretch and pi 3
so thankful for all your work and time man! I just wanna know is there a way to set the audio output to the default jack while keeping the audio input through my bluetooth headset?
Yes of course you can do that, using the command pacmd to select default sink and source.
Hi Youness,
thanks for your article, it’s a great work.
My headset is – almost – working. Your opinion would be great :
– all your commands are working (few of them with a reboot like you said). The A2DP part is working, I have sound in my speakers (Suaoki T9S Bluetooth Motorcycle).
– when I try the commands for enabling HSP (for microphone if I understand), I haven’t any sound and the command “arecord” use Alsa [Connected to device alsa_output.platform-soc_audio.analog-stereo.monitor (index: 0, suspended: no)]. If i specify a device (with -d) I have a “Stream error: No such entity”.
Have you and idea to have both play & record with my headset ?
Thanks in advance 🙂
Hello Dominique,
Did you do the command: sudo hcitool cmd “0x3F 0x01C 0x01 0x02 0x00 0x01 0x01” ?
Yes,
I’ve re-re-read all the comments and I forget to precise that I use a USB-dongle. So it should be easier ? 😀
With USB dongle…you have to find the driver of this dongle for Linux, not all the time easy if it is an unkonwn brand.
.. and the command for record is parecord not arecord of course, typo 🙂
Yes.
is a driver needed ? If I have sound with a2dp, it would work for everything no ? I’m lost 🙂
Maybe you are lucky and your dongle is already supported by a generic driver in Linux distribution, but the best is to google the dongle to find how to install it in Linux. For example the dongle I used before, I had to create a specific file and copy it in the Raspberry Pi, check this old post http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp to see how I did.
I already read it and i have prayed for not have to do this 😀
The dongle is recognized on a fresh Raspbian Stretch (with GUI) and connect well, just for sound, not for mic :/
I have no idea.
Ok, so try to do it without the dongle maybe.
Another tip: Don’t trust the GUI sometimes it is not reflecting the real situation, the command line is the real status.
Oki thanks. No more luck with the built-in BT, same “errors”.
Give me the name of the dongle I’ll check for it later.
“Integral”. Big thanks
Sorry but I couldn’t find useful documentation for this brand.
I followed all your instructions and able to play and record from bluetooth speaker.
Now I trying “OK, Google” as mentioned in https://www.raspberrypi.org/forums/viewtopic.php?t=204865.
Now google’s python script is not recognizing the microphone, script is throwing error mic_failure_detector.cc.
Need your help in resolving this.
(env) pi@raspberrypiVenu:~/AIY-projects-python $ python3 src/main.py
/home/pi/AIY-projects-python/src/aiy/_drivers/_led.py:51: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.setup(channel, GPIO.OUT)
Say “OK, Google” then speak, or press Ctrl+C to quit…
[3716:3744:ERROR:mic_failure_detector.cc(140)] [assistant] Channel 1 has failed. Powers -inf and -inf
I can’t help you too much because I didn’t use this AIY stuff before, but here are some points to check:
– The AIY is using ALSA as audio manager? If yes, you have to re-route audio sinks and sources between ALSA and PulseAudio that is managing Bluetooth audio.
– This should be done in the source code so you will have to modify it there.
– Try to find in the code what they mean by Channel 1, is it the default ALSA input?
– Last to do, if you know how-to of course, is to try to switch to blue-alsa but I don’t ensure you any result.
Youness thanks for the tutorial!
Everything was successful and I played the h2g2.ogg successfully. My problem is after I reboot my retropie I cannot get the headphones to connect automatically. Is there a way to connect to registered devices? All I know of is the GUI, but when I select display registered devices or connect to registered devices I get a “Unit sixad.service could not be found” error.
I don’t know if it matters but this is a compute module so I’m using a usb bluetooth dongle.
This is something lot of people are asking me and I’m sorry I can’t do it for the moment. What I can advise you is to create a script that does the commands you did to set up the audio output. And use some tricks and timeouts to give Bluetooth the time so scan and find the headset.
If by any chance I wrote a script I’ll let you know by email.
Hello,
pulse audio doesn’t find the bluetooth speaker I am connected to, any suggestion?:
[SPK312]# info E8:07:BF:0F:DA:F5
Device E8:07:BF:0F:DA:F5
Name: SPK312
Alias: SPK312
Class: 0x240404
Icon: audio-card
Paired: yes
Trusted: yes
Blocked: no
Connected: yes
LegacyPairing: no
UUID: Headset (00001108-0000-1000-8000-00805f9b34fb)
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb)
[SPK312]# exit
[DEL] Controller B8:27:EB:FD:B3:37 raspberrypi [default]
pi@raspberrypi:~ $ pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/bcm2835_alsa/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $
If you are using the latest Raspbian versions, I think that the Bluetooth device is connected to blue-alsa, try to kill it before you use PulseAudio. I also mentioned this in the post.
[…] Source: How To Connect Bluetooth Headset Or Speaker To Raspberry Pi 3 […]
hi ive tryed following your tutorial but its not working the headset is connected and showing up but i cant get any audio output or microphone input.
pi@raspberrypi:~ $ pacmd list-cards
2 card(s) available.
index: 1
name:
driver:
owner module: 7
properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/bcm2835_alsa/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Analog Mono Output (priority 200, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
off: Off (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Analog Stereo
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#1: Monitor of bcm2835 ALSA Analog Stereo
ports:
analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
properties:
index: 3
name:
driver:
owner module: 27
properties:
device.description = “Gioteck LP-1”
device.string = “00:25:DB:15:AB:26”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “headset”
bluez.path = “/org/bluez/hci0/dev_00_25_DB_15_AB_26”
bluez.class = “0x200404”
bluez.alias = “Gioteck LP-1”
device.icon_name = “audio-headset-bluetooth”
device.intended_roles = “phone”
profiles:
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
off: Off (priority 0, available: yes)
active profile:
sinks:
bluez_sink.00_25_DB_15_AB_26.headset_head_unit/#2: Gioteck LP-1
sources:
bluez_sink.00_25_DB_15_AB_26.headset_head_unit.monitor/#4: Monitor of Gioteck LP-1
bluez_source.00_25_DB_15_AB_26.headset_head_unit/#5: Gioteck LP-1
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
headset-input: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $
i went through it again and everything connects fine but i dont get any record/playback
index: 2
name:
driver:
owner module: 25
properties:
device.description = “Gioteck LP-1”
device.string = “00:25:DB:15:AB:26”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “headset”
bluez.path = “/org/bluez/hci0/dev_00_25_DB_15_AB_26”
bluez.class = “0x200404”
bluez.alias = “Gioteck LP-1”
device.icon_name = “audio-headset-bluetooth”
device.intended_roles = “phone”
profiles:
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
off: Off (priority 0, available: yes)
active profile:
sinks:
bluez_sink.00_25_DB_15_AB_26.headset_head_unit/#1: Gioteck LP-1
sources:
bluez_sink.00_25_DB_15_AB_26.headset_head_unit.monitor/#2: Monitor of Gioteck LP-1
bluez_source.00_25_DB_15_AB_26.headset_head_unit/#3: Gioteck LP-1
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
headset-input: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
it work well , Great Help !!
Only a tiny issue that
the sound is good before set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.headset_head_unit
but after change the sound become worse & “slow” …
Maybe because you are using both Bluetooth and Wifi.
Hi Youness, Followed your guide and finally got my Bose SLM to stream audio from Rpi. Thank you!
You’re welcome.
Hey Youness,
I have been following the post for a while as I have been trying to get bluetooth input and output working for a while. After many hours and reinstalls and failed attempts, I took a break. But with the release of the RPi3b+ with the upgraded 4.2Bluetooth I was wondering if you or anyone who has been following your efforts and participating in the thread have found any difference with the new chip.
I didn’t check this version yet sorry.
Hello Youness
thanks for such a wonderful post. i have successfully connected a Bluetooth headset and recorded the audio (used pulse audio).
the problem is poor quality of the audio as some of the guys have mentioned.
i have tried to disable the wifi using
“sudo ifconfig wlan0 down”
before recording audio. and when audio is recorded i have enabled it
“sudo ifconfig wlan0 up”
but sound quality is still bad, please guide me what is the issue.
also i plan to use a usb Bluetooth dongle for better audio recording
https://www.aliexpress.com/item/-/32917016293.html
they claim it can be used with raspberry pi. please suggest me will it solve the issue ? as disabling wifi during audio recording didn’t helped.
Regards
Hello,
The Wifi shall be disabled all the time, not only when recording your voice, because the probelm occurs also while streaming the audio from Raspberry Pi to the headset.
I can’t recommend you a specific dongle, all I can say is buy a dongle that someone’s already used with Linux, this is what I did.
Thanks for your reply. But i am only recording the audio. After recording is done and audio file is saved, i am enabling wifi to send it to cloud.
After that i download file from cloud and listen it on my PC
In that case I don’t see why the quality is bad, since your Raspberry Pi is treating only Bluetooth stream…
And what if i use usb Bluetooth dongle? Will it be better in quality then the built-in one
As I did yes the quality was improved with the dongle.
Hi,
Thanks a lot for the detailed tutorial.
“So I rebooted, removed the Bluetooth device and started again from the pairing step.”
I did this 3 times but no luck. It throws ‘Failed to set card profile to ‘headset_head_unit’.
My device indeed has a mic and it works with my phone.
What exactly did you mean by ‘removed’?
Is it required to stop my Bluetooth device before going for second attempt?
Thanks in advance 🙂
There is a space in below command. I guess we don’t need that.
dpkg -l pulseaudio pulseaudio-module-bluetoot h
I meant removing the device from bluetoothctl list. Example: remove xx.xx.xx.xx… (this is equivalent of unpairing)
You’re right the space was an error.
I’ve got a Pi 3 b + and am trying to connect a Bluetooth speaker. This speaker works with other devices, I’m running Raspbian Stretch on the Pi. Using bluetoothctl the speaker is both paired and trusted. The problem is the speaker and the Pi do not automatically reconnect when the speaker is turned on. Suggestions?
hy dear, how to communicate mobile phone and Bluetooth headset through raspberry pi. please, give me solution.
Thank you, very nice work ! 🙂
Thanks for sharing this online, I couldn’t get my bluetooth speaker to work before but I followed your instructions and everything worked out exactly as you say so really great work for digging into this stuff, I know from my own experience that it can be a daunting task sometimes to get the most simple things to work as you anticipated because you’re a normal person and just expects at least something to happen as you’d normally do when you connect for example to your phone or tablet, right?
Really I can’t thank you enough because you saved me a ton of time figuring it out on my own, which is why I already gave up on getting the sound working, I don’t really need it however I do have a strong urge to always get the most out of everything.
Yeah, you’re one of the few good people online I think… Again, 1000x thx!
I wish you have a great day today, have a great new year and all the best…
Ricardo
Hi Ricardo,
Thanks for your kind words. I did this work for one reason that is saving others time that I wasted on my side, I’m glad you and other people can spend time on things more important than this issue.
Have a nice day too.
Everything was OK until I arrived at step ‘pacmd list-cards’.
There’s no mention about any kind of Bluetooth soundcard or device there (although I succesfully paired my August WS300 Bluetooth speaker thanks to your instructions).
Running everything on a Raspberry Pi 3 B+ with latest update of Raspbian Desktop.
Can you perhaps help me?
Here is the result of my ‘pacmd list-cards’:
3 card(s) available.
index: 0
name:
driver:
owner module: 6
properties:
alsa.card = “2”
alsa.card_name = “QuickCam Pro 9000”
alsa.long_card_name = “Logitech, Inc. QuickCam Pro 9000 at usb-3f980000.usb-1.2, high speed”
alsa.driver_name = “snd_usb_audio”
device.bus_path = “platform-3f980000.usb-usb-0:1.2:1.2”
sysfs.path = “/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.2/sound/card2”
udev.id = “usb-046d_0990_92EA4A29-02”
device.bus = “usb”
device.vendor.id = “046d”
device.vendor.name = “Logitech, Inc.”
device.product.id = “0990”
device.product.name = “QuickCam Pro 9000”
device.serial = “046d_0990_92EA4A29”
device.form_factor = “webcam”
device.string = “2”
device.description = “QuickCam Pro 9000”
module-udev-detect.discovered = “1”
device.icon_name = “camera-web-usb”
profiles:
input:analog-mono: Ingresso «Mono analogico» (priority 2, available: unknown)
off: Spento (priority 0, available: unknown)
active profile:
sources:
alsa_input.usb-046d_0990_92EA4A29-02.analog-mono/#0: QuickCam Pro 9000 Mono analogico
ports:
analog-input-mic: Microfono (priority 8700, latency offset 0 usec, available: unknown)
properties:
device.icon_name = “audio-input-microphone”
index: 1
name:
driver:
owner module: 7
properties:
alsa.card = “1”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/bcm2835_alsa/sound/card1”
device.string = “1”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
output:analog-mono: Uscita «Mono analogico» (priority 200, available: unknown)
output:analog-stereo: Uscita «Stereo analogico» (priority 6000, available: unknown)
off: Spento (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_audio.analog-stereo/#0: bcm2835 ALSA Stereo analogico
sources:
alsa_output.platform-soc_audio.analog-stereo.monitor/#1: Monitor of bcm2835 ALSA Stereo analogico
ports:
analog-output: Uscita analogica (priority 9900, latency offset 0 usec, available: unknown)
properties:
index: 2
name:
driver:
owner module: 8
properties:
alsa.card = “0”
alsa.card_name = “snd_rpi_googlevoicehat_soundcar”
alsa.long_card_name = “snd_rpi_googlevoicehat_soundcard”
alsa.driver_name = “snd_soc_googlevoicehat_soundcard”
device.bus_path = “platform-soc:sound”
sysfs.path = “/devices/platform/soc/soc:sound/sound/card0”
device.string = “0”
device.description = “snd_rpi_googlevoicehat_soundcar”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
profiles:
input:analog-stereo: Ingresso «Stereo analogico» (priority 60, available: unknown)
output:analog-stereo: Uscita «Stereo analogico» (priority 6000, available: unknown)
output:analog-stereo+input:analog-stereo: Duplex stereo analogico (priority 6060, available: unknown)
off: Spento (priority 0, available: unknown)
active profile:
sinks:
alsa_output.platform-soc_sound.analog-stereo/#1: snd_rpi_googlevoicehat_soundcar Stereo analogico
sources:
alsa_output.platform-soc_sound.analog-stereo.monitor/#2: Monitor of snd_rpi_googlevoicehat_soundcar Stereo analogico
alsa_input.platform-soc_sound.analog-stereo/#3: snd_rpi_googlevoicehat_soundcar Stereo analogico
ports:
analog-input: Ingresso analogico (priority 10000, latency offset 0 usec, available: unknown)
properties:
analog-output: Uscita analogica (priority 9900, latency offset 0 usec, available: unknown)
properties:
Did you kill the blue-alsa before pairing? I think it takes your soundcard and doesn’t let PulseAudio to use it.
Hi,
although I paired succesfully my August WS300 Bluetooth speaker when I type ‘pacmd list-cards’ it doesn’t show up in the list of available sound cards…
What shall I do now? 🙁
How do you know that you successfully pair it? It is in Bluetoothctl?
Finally! First of all, huge thanks to Youness! I spent 14 hours setting this all up. Sometimes I had a feeling that I just got lucky when things started to work, but nevertheless, it works now! I’m so satisfied!
I guess I had some problems with multiple accounts first (then I just deleted the second account and made all the changes from one account). Actually, nothing worked after I did all as Youness told (At this point I didn’t get any cards to show up when pacmd list-cards) but when I got frustrated and removed the Pulseaudio and installed it again all started to work. (that was the lucky part).
Most of the time went to figure out this script to automatically connect my Asus BT400 dongle to a Sony’s portable speaker (with mic). It would have been easy without mic..
Remember you still have to do some of the steps to come at this point! To list at least some of those:
Disabling the onboard bluetooth
Installing USB dongle drivers
Installing Pulseaudio and pulseaudio-module-bluetooth
Pairing, trusting and connecting the speaker
So here is the script!
1. Create a new file bluetooth_auto.sh
2. Copy, edit (MACs) and save.
#!/bin/bash
#Connect BT (Your bluetooth speaker or headset MAC address) (you may have to run the script once (just double click) before booting with the systemd to get this working. By adding this (bt connection) to the top I was able to get the script to work.)
bluetoothctl << EOF
connect xx:xx:xx:xx:xx:xx
exit
EOF
sleep 10
#Kill Bluealsa
sudo killall bluealsa
#Start Pulseaudio
#optional#pax11publish -r
pulseaudio –start
#Connect BT (Your bluetooth speaker or headset MAC address)
bluetoothctl << EOF
connect xx:xx:xx:xx:xx:xx
exit
EOF
sleep 5
sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01
#Your bluetooth speaker or headset MAC address to all of these.
pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit
pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.headset_head_unit
pacmd set-default-source bluez_ssource.xx_xx_xx_xx_xx_xx.headset_head_unit
exit 0
3. sudo chmod +x /your/file/destination/bluetooth_auto.sh
Now lets set up the systemd service
4. sudo nano /lib/systemd/system/bluetooth_auto.service
5. Copy and paste this to the file. Ctrl + X, Y, Enter. (destination has to be exact to the .sh file you just created!)
[Unit]
Description=My Service
[Service]
Type=idle
ExecStart=/your/file/destination/bluetooth_auto.sh
[Install]
WantedBy=multi-user.target
6. sudo chmod 644 /lib/systemd/system/bluetooth_auto.service
7. sudo systemctl daemon-reload
8. sudo systemctl enable bluetooth_auto.service
9. sudo reboot
Thank you!
Links to setting up the script.
https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/ (Method 4: SYSTEMD)
https://www.youtube.com/watch?v=eEuViHanjKI
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/
Finally! First of all, huge thanks to Youness! I spent 14 hours setting this all up. Sometimes I had a feeling that I just got lucky when things started to work, but nevertheless, it works now! I’m so satisfied!
I guess I had some problems with multiple accounts first (then I just deleted the second account and made all the changes from one account). Actually, nothing worked after I did all as Youness told (At this point I didn’t get any cards to show up when pacmd list-cards) but when I got frustrated and removed the Pulseaudio and installed it again all started to work. (that was the lucky part).
Most of the time went to figure out this script to automatically connect my Asus BT400 dongle to a Sony’s portable speaker (with mic). It would have been easy without mic.. By adding a bt connection command to the start I was able to get the script to work. “#pax11publish -r” is an optional line for pulseaudio start problems.
Remember you still have to do some of the steps to come at this point! To list at least some of those:
Disabling the onboard bluetooth
Installing USB dongle drivers
Installing Pulseaudio and pulseaudio-module-bluetooth
Pairing, trusting and connecting the speaker
So here is the script!
1. Create a new file bluetooth_auto.sh
2. Copy, edit (MACs) and save.
#!/bin/bash
#Connect BT (Your bluetooth speaker or headset MAC address)
bluetoothctl << EOF
connect xx:xx:xx:xx:xx:xx
exit
EOF
sleep 10
#Kill Bluealsa
sudo killall bluealsa
#Start Pulseaudio
#pax11publish -r
pulseaudio –start
#Connect BT (Your bluetooth speaker or headset MAC address)
bluetoothctl << EOF
connect xx:xx:xx:xx:xx:xx
exit
EOF
sleep 5
sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01
#Set up Pulseaudio (Your bluetooth speaker or headset MAC address)
pacmd set-card-profile bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit
pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.headset_head_unit
pacmd set-default-source bluez_ssource.xx_xx_xx_xx_xx_xx.headset_head_unit
exit 0
3. sudo chmod +x /your/file/destination/bluetooth_auto.sh
Now lets set up the systemd service
4. sudo nano /lib/systemd/system/bluetooth_auto.service
5. Copy and paste this to the file. Ctrl + X, Y, Enter. (destination has to be exact to the .sh file you just created!)
[Unit]
Description=My Service
[Service]
Type=idle
ExecStart=/your/file/destination/bluetooth_auto.sh
[Install]
WantedBy=multi-user.target
6. sudo chmod 644 /lib/systemd/system/bluetooth_auto.service
7. sudo systemctl daemon-reload
8. sudo systemctl enable bluetooth_auto.service
(you may have to execute the script (bluetooth_auto.sh) once (just double click) before booting.
9. sudo reboot
Thank you!
Links to setting up the script.
https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/ (Method 4: SYSTEMD)
https://www.youtube.com/watch?v=eEuViHanjKI
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/
Thanks for your great comment, I’ll try my best to test this script.
Hello!
Thank you very much for improving answers about this problem, it is really headache the issue!
However, trying to do the A2DP connection, with the command pacmd list-cards no results are shown.
The answer of my terminal is: 0 card(s) available.
Does it mean that the audio bluetooth which I connect to does not have A2DP card?
Please, I need more information!
Thank you in advance,
I.
Well… You shall see at least 1 card that is the default card of Raspberry Pi with ALSA…
If you don’t see a card with pacmd, it means that pulseaudio doesn’t see, or cannot see the device, it can be a problem of connection, or that another manager is using the device.
Did you kill bluealsa first?
Did you connect correctly the device and get the status OK?
This tutorial is 100% awesome. Thank you for presenting it!
You’re welcome.
Hi Youness.. I have been trying this for 2days… But with failures.. I am using RASPBERRY pi 3 model b+. Does anything changes for that??
I am trying to connect to HBS 730 using pi for voice recognition with SpeechRecognition module..
But failing each time to establish a HSP OR HFP connection.. Awaiting reply..
Regards…..
The “Speech recognition” module is using which manager? If it uses Alsa native API it is normal that things don’t work for you. In order to connect your device with a third-party software, it shall use pulseaudio.
Hi Youness.. I have been trying this for 2days… But with failures.. I am using RASPBERRY pi 3 model b+. Does anything changes for that??
I am trying to connect to HSB 730 headset using HSP OR HPF but failing….
Can you kindly help me about this?
Regards….
Also adding to previous post.. I uninstalled bluealsa rather killing it every time..
Could that be a problem?
No I don’t think that this is the problem.
Hi Youness,
I am attempting to set this up now with my Plattan ADV wireless headphones and I’m able to pair and trust the headphones. However, once I try to connect, it attempts to connect and then says failure : org.bluez.Error.Failed
I did not kill bluealsa because it said no such process running iirc.
If you could help me out that would be great!
Did you started pulseaudio?
Before making the speech recognition work I’m simply trying to record audio through mic. using HBS 730…. Failed a lot of time…
As a workaround i was trying to install PulseAudio11.1 from git..
but that shows….
pi@raspberrypi:~ $ git clone git://anongit.freedesktop.org/pulseaudio/pulseaudioCloning into ‘pulseaudio’…
remote: Counting objects: 66081, done.
remote: Compressing objects: 100% (13523/13523), done.
remote: Total 66081 (delta 55213), reused 62679 (delta 52484)
Receiving objects: 100% (66081/66081), 12.46 MiB | 156.00 KiB/s, done.
Resolving deltas: 100% (55213/55213), done.
pi@raspberrypi:~ $ cd pulseaudio
pi@raspberrypi:~/pulseaudio $ sudo apt-get build-dep pulseaudioReading package lists… Done
E: You must put some ‘source’ URIs in your sources.list
pi@raspberrypi:~/pulseaudio $
Please help me with a way out…
Getting frustrated with this
Ok, I propose that you start from scratch and do exactly as I did, I mean to be sure that you are not using a bad configuration or that you broke something on Raspbian.
After this, do step by step and know exactly what you are doing first. Pair, connect,…etc.
Meanwhile I’ll check for this HBS 730 maybe there is specific issue with it.
what ‘source’ shall I use?
…………….Regards..
May be I’m annoying you with this but FEEEEELING like hitting my head against the wall….
This is a long time problem and hundreds felt like you.
Yeh. Googling it basically returns to your posted solutions.. But that’s not working.. I’m not being able to getting it done..
What do you think? What might the problem!??
I looked for HBS 730, it had Bluetooth 3.0, it supports A2DP and HSP, so far it is not the problem. Now start again and make sure to know each step. My experience is that sometimes we make errors in the process.
Yeh i followed the exact steps..but still fails.. I am using the most recent version of
Raspbian Stretch with desktop
Image with desktop based on Debian Stretch
Version:November 2018
Release date:2018-11-13
Kernel version:4.14
Followed by update and upgrade… Not working
Try to make A2DP first, can you hear a music with it?
Upto connecting is all same but the last line
bluez_card.xx_xx_xx_xx_xx_xx headset_head_unit
Error
Failed to set card profile to ‘headset_head_unit’.
After hundred reboots also….
A2dp works fine with that i previously used that headset for months with my home theater
But these days by your process i tried the HSP/HFP first…
Could that be any issue! Though i think may be not..
I dont know…may be a ghost bug..
Ha ha ha..
And you did the specific command “hcitool cmd …” ?
What do you see when you list the cards with pacmd list-cards
Finally, why not using a USB Bluetooth dongle as I did in another post?
With anything can you directly connect to my system and check…?
I don’t know may be asking for a stupid thing.. But if you get time.. Will it be possible for you?
I don’t know if this is something possible or how…
Yes i also did the hcitool command..
I also tried using a dongle.. A cambridge semiconductor one.. But same problem.. Though the headset works perfectly with my vaio laptop running on Windows 10
Try to buy the same one I used, that’s what I did I order to find the correct procedure and lot of people did it after me too.
Ok then i will try after getting home making you control my RASPBERRY pi..may be 15mins max
Would you mind giving your watsapp number…
Im installing TEAMVIEWER on raspberry pi.. can you help please??
I can’t do live help there sorry.
ok no probs… thanks by the way..
ok then I would try connecting the a2dp first…
tried again with a2dp first. Works fine…
but failed with HSP
Did you try to change to profile “off” before changing to HSP?
systemctl status bluetooth
returns->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
● bluetooth.service – Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-03-11 19:56:52 IST; 10min ago
Docs: man:bluetoothd(8)
Main PID: 584 (bluetoothd)
Status: “Running”
CGroup: /system.slice/bluetooth.service
└─584 /usr/lib/bluetooth/bluetoothd
Mar 11 19:56:52 raspberrypi bluetoothd[584]: Endpoint registered: sender=:1.14 path=/A2DP/SBC/Source/1
Mar 11 19:56:52 raspberrypi bluetoothd[584]: Failed to set privacy: Rejected (0x0b)
Mar 11 19:56:56 raspberrypi bluetoothd[584]: Endpoint registered: sender=:1.24 path=/MediaEndpoint/A2DPSource
Mar 11 19:56:56 raspberrypi bluetoothd[584]: Endpoint registered: sender=:1.24 path=/MediaEndpoint/A2DPSink
Mar 11 19:56:56 raspberrypi bluetoothd[584]: RFCOMM server failed for Headset Voice gateway: rfcomm_bind: Address already in use (98)
Mar 11 19:57:59 raspberrypi bluetoothd[584]: Endpoint unregistered: sender=:1.14 path=/A2DP/SBC/Source/1
Mar 11 19:58:23 raspberrypi bluetoothd[584]: /org/bluez/hci0/dev_22_22_22_70_C7_2C/fd0: fd(24) ready
Mar 11 19:59:22 raspberrypi bluetoothd[584]: Unable to get io data for Headset Voice gateway: getpeername: Transport endpoint is not connec
Mar 11 20:04:11 raspberrypi bluetoothd[584]: /org/bluez/hci0/dev_22_22_22_70_C7_2C/fd1: fd(22) ready
Mar 11 20:04:16 raspberrypi bluetoothd[584]: 22:22:22:70:C7:2C: error updating services: Input/output error (5)
~
~
pacmd list-cards?
pactl list cards
Card #0
Name: alsa_card.platform-soc_audio
Driver: module-alsa-card.c
Owner Module: 6
Properties:
alsa.card = “0”
alsa.card_name = “bcm2835 ALSA”
alsa.long_card_name = “bcm2835 ALSA”
device.bus_path = “platform-soc:audio”
sysfs.path = “/devices/platform/soc/soc:audio/bcm2835_alsa/sound/card0”
device.string = “0”
device.description = “bcm2835 ALSA”
module-udev-detect.discovered = “1”
device.icon_name = “audio-card”
Profiles:
output:analog-mono: Analog Mono Output (sinks: 1, sources: 0, priority: 700, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: output:analog-mono
Ports:
analog-output: Analog Output (priority: 9900, latency offset: 0 usec)
Part of profile(s): output:analog-mono
Card #1
Name: bluez_card.22_22_22_70_C7_2C
Driver: module-bluez5-device.c
Owner Module: 24
Properties:
device.description = “HBS-730”
device.string = “22:22:22:70:C7:2C”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “hands-free”
bluez.path = “/org/bluez/hci0/dev_22_22_22_70_C7_2C”
bluez.class = “0x240408”
bluez.alias = “HBS-730”
device.icon_name = “audio-handsfree-bluetooth”
device.intended_roles = “phone”
Profiles:
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: off
Ports:
handsfree-output: Handsfree (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit, a2dp_sink
handsfree-input: Handsfree (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit
You can see that you have the headset_head_unit profile, and it is available: yes.
Now, try to change the profile to off: pacmd set-card-profile 2 off
Then try to change to HSP: pacmd set-card-profile headset_head_unit
What is the result?
trying now with
||/ Name Version Architecture Description
+++-====================================-=======================-=======================-=============================================================================
ii pulseaudio 12.2-4 armhf PulseAudio sound server
ii pulseaudio-module-bluetooth 12.2-4 armhf Bluetooth module for PulseAudio sound server
It still failed
I think I’ll give a try with a headset like you used
Can you help me with the model number of the headset you used
My headset HBS-730 working fine on Windows and also on android..
Checked today morning also…
I can figure it out,… Why not Raspberry pi..
Today I was able to record audio on pi using my mobile that has
headset_audio_gateway: Headset Audio Gateway (HSP/HFP)
pi@raspberrypi:~ $ bluetoothctl
Agent registered
[CHG] Device 04:92:26:99:16:EE RSSI: -54
[bluetooth]# scan on
Discovery started
[CHG] Device 04:92:26:99:16:EE RSSI: -42
[bluetooth]# pair 04:92:26:99:16:EE
Attempting to pair with 04:92:26:99:16:EE
[CHG] Device 04:92:26:99:16:EE Connected: yes
Request confirmation
pair 04:92:26:99:16:EE
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 04:92:26:99:16:EE Connected: no
[bluetooth]# pair 04:92:26:99:16:EE
Attempting to pair with 04:92:26:99:16:EE
[CHG] Device 04:92:26:99:16:EE Connected: yes
Request confirmation
[agent] Confirm passkey 906241 (yes/no): yes
[CHG] Device 04:92:26:99:16:EE Modalias: bluetooth:v001Dp1200d1436
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001103-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 04:92:26:99:16:EE UUIDs: 6455fffe-a146-11e2-9e96-0800200c9a67
[CHG] Device 04:92:26:99:16:EE ServicesResolved: yes
[CHG] Device 04:92:26:99:16:EE Paired: yes
Pairing successful
[CHG] Device 04:92:26:99:16:EE ServicesResolved: no
[CHG] Device 04:92:26:99:16:EE Connected: no
[CHG] Device D6:E4:CD:89:BC:37 RSSI: -86
[bluetooth]# trust 04:92:26:99:16:EE
[CHG] Device 04:92:26:99:16:EE Trusted: yes
Changing 04:92:26:99:16:EE trust succeeded
[bluetooth]# connect 04:92:26:99:16:EE
Attempting to connect to 04:92:26:99:16:EE
[CHG] Device 04:92:26:99:16:EE Connected: yes
Connection successful
[CHG] Device 04:92:26:99:16:EE ServicesResolved: yes
[ASUS_X00TD]# scan off
Discovery stopped
[ASUS_X00TD]#
[8]+ Stopped bluetoothctl
name:
driver:
owner module: 35
properties:
device.description = “ASUS_X00TD”
device.string = “04:92:26:99:16:EE”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “phone”
bluez.path = “/org/bluez/hci1/dev_04_92_26_99_16_EE”
bluez.class = “0x5a020c”
bluez.alias = “ASUS_X00TD”
device.icon_name = “audio-card-bluetooth”
profiles:
a2dp_source: High Fidelity Capture (A2DP Source) (priority 20, available: unknown)
headset_audio_gateway: Headset Audio Gateway (HSP/HFP) (priority 10, available: unknown)
off: Off (priority 0, available: yes)
active profile:
ports:
phone-output: Phone (priority 0, latency offset 0 usec, available: unknown)
properties:
phone-input: Phone (priority 0, latency offset 0 usec, available: unknown)
properties:
pi@raspberrypi:~ $ pacmd set-default-source bluez_source.04_92_26_99_16_EE.headset_audio_gateway
pi@raspberrypi:~ $ parec b.wav
^Z
[9]+ Stopped parec b.wav
pi@raspberrypi:~ $ parecord c.wav
Stream error: Entity killed
pi@raspberrypi:~ $
With your tests the conclusion is that your headset is not working with Raspberry Pi, but the Raspberry Pi setup working with another device. Now I think you should buy a headset that someone else already tested with Raspberry Pi, or buy a Bluetooth dongle. This is unfortunately a stressing case when we don’t know why headsets work and others no…
Yeh..
But the profile that worked for me is
HSP-AG..
Now I’ve to check if HSP works..
I’ve ordered https://www.amazon.in/gp/aw/d/B07GPL53D6/ref=ya_aw_od_pi?ie=UTF8&psc=1
working on CSR8645.. As my main project would be working on CSR8645..
Lets see…
What headset did you use for the headset mic…?
Can you suggest any..?
It is old headset Philips SHB5600 but this is not a 100% guarantee it will work. I recommend you to buy instead a USB Bluetooth dongle that is supported by Raspbian, I bought this one Asus BT400 because I found someone else did the installation in Linux. The post is here: http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp
Hi i’ve been trying to do step:
Set the Bluetooth device as output audio:
pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx.a2dp_sink
However, i keep getting
Sink bluez_sink.xx_xx_xx_xx_xx_xx.a2dp_sink does not exist.
any idea why i would get that? Followed all the previous steps with no issues.
Did you change xx_… with your own MAC address?
Yes i did.
exact command.
pacmd set-default-sink bluez_card.F4_4E_FD_A4_10_56.a2dp_sink
Ok and can you list the sinks you have?
pacmd list-sinks
I have noticed you don’t monetize youness.net,
don’t waste your traffic, you can earn additional cash
every month. There is one good way that brings decent money,
you can google it: money making by bucksflooder
At this line-
pacmd set-card-profile bluez_card.B3_52_38_AA_AE_45 headset_head_unit
Failed to set card profile to ‘headset_head_unit’.
I got this error i rebooted but still i got this error
please help me
You can try to switch the profile from a2dp to off, and then to hsp.
Hello,
I have a Raspberry Pi 3B+, and a Bluetooth speaker called the ‘SoundCore mini’ mfd by Anker. Unfortunately, Anker does not publish the specifications of this speaker, but during a phone call to Anker’s tech support they informed me the SoundCore mini supports profiles: A2DP, HFP and AVRCP.
I operate my RPi in “headless” mode without a GUI. My OS is Raspbian, and it is current. I have installed PulseAudio, and the following packages related to bluetooth are installed : bluez, bluez-firmware, pi-bluetooth.
Using the `bluetoothctl` tool, I have been able to identify my SoundCore speaker, and to “pair” with it. However, each time I “connect”, the connection is immediately broken. I have yet to be able to successfully connect and play music through this speaker from the RPi (tho’ it happily plays tunes from my phone).
I have two questions:
1. Will your approach allow me to play music with my “built-in” BT hardware (i.e. no BT dongle)?
2. Given the research and hard work you’ve done (very impressive!), is it your opinion that the BT hardware built into the RPi is lacking in performance and/or specifications. Put another way, would you ever buy a BT dongle that had the same specs and performance as the BT hardware in the RPi?
Finally, thank you for the prodigious effort you have put into this.
~S
Hello,
1- Yes, I have no doubt that Raspberry Pi with A2DP works fine, if you can’t do that, it is just a matter of software configuration, the main issue is when you try to connect your speaker while the PulseAudio session is taken by other source, or it is shut down after some time. I advise you to do a step by step try to figure out why the connection is not permanent.
2- From my experience, yes the built-in Bluetooth hardware in Raspberry Pi is not as expected and there is no clear support, in term or profiles, and in term of performance. I already bought a USB-Bluetooth dongle (it worked fine) and explained it in a previous post: http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp
You’re welcome, I’m glad (and I never expected) that this topic will be so much important for others 🙂
[…] Siehe: https://de.wikipedia.org/wiki/Bluetooth https://de.wikipedia.org/wiki/Bluetooth-Profile http://youness.net/raspberry-pi/how-to-connect-bluetooth-headset-or-speaker-to-raspberry-pi-3 […]
this didnt work for me and screwed up my whole audio, how do i roll this back, removing speaker and adding it again didnt work, it connects but there is no sound
I don’t see how this can screw anything else except the Bluetooth set up, since the audio will go back to the previous set up after disconnection or after reboot. If you are using Raspberry Pi with desktop interface try to switch back the audio output to audio jack of HDMI.
Can I use it with my google assistant on raspberry pi 3 b+
I think yes you can.
Hey Thanks,
Your instructions worked well for me. The only thing is it seems I’m getting only a mono sound (not sure though). Is there any way to confirm whether the output is mono or stereo? And if it is mono, is there a way to get stereo sound?
By default A2DP is stereo. HSP is mono.
Hello, could you write same instruction for Raspberry Pi 4? with auto startup after reboot
I don’t own a Raspberry Pi 4 to do that sorry.
Hi.
I would firstly like to thank you for such an amazing explanation and assistance on this matter.
I struggled with this for about a month.
Now I am able to establish a proper HSP connection with my Bluetooth earpiece.
I would per-apse like to also chip in by helping those who also manage to get a HSP connection
but failed to get a better audio quality like I did in the past.
Quoting bluetiger9: “..PulseAudio uses a hard-coded (e)SCO packet size of 48 bytes, instead of using the packet size negotiated at the eSCO connect (ex 60 bytes)…the SCO packets are received at a lower rate, which causes PulseAudio to send the SCO packets way too slow.”
Solution:
open: /etc/pulse/default.pa
on the line where it is written:
ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
endif
Add: autodetect_mtu=yes
It then become:
ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover autodetect_mtu=yes
endif
This will allow a dynamic sizing of the packet.
for more detail see: https://github.com/raspberrypi/linux/issues/2229
Thanks for this tip, for sure it will help others who visit the post!
Have you measured the latency between the microphone input on the headphones and the output on the pi?
No I didn’t do such measure.
Hi Youness
Great work and thank you. I have a raspberry pi 4 model b and have gone through the process of paring/removing/paring my Sennheiser CX 6.00 BT a couple of times. It does utilize a password “0000” which I only entered once and was never prompted for it again. I can’t seem to set the headset_head_unit profile. In the pacmd list-cards print it lists the profile as not being available: Headset Head Unit (HSP/HFP) (priority 30, available: no). I do find this interesting as the product supports HFP but it does not list HSP in the specifications – Do you perhaps have any suggestions on a solution?
Thanks and regards
Etienne Bauscher
I just googled your device, it supports HSP as well as HFP. I think this is due to Raspberry Pi issue not working with all devices. Did you tried a USB dongle for Bluetooth instead of built in Raspberry Pi ?
Hi Youness
I gave it one more try and it worked – Murphy’s Law.
Thank you in anycase.
Regards
Etienne
It works, Thank you so much Youness.
Hi Youness,
I am trying to connect my Raspberry Pi 3B+ to my Amazon Echo Do. I want to use my echo as speakers. The problem is, it is not allowing me to set a2dp_sink as output audio. It is giving me the error. “Failed to set card profile to ‘a2dp_sink’.”
I suspect it has something to do with the availability of the A2DP_Sink being “no” . Do you know how I may solve this issue? Thanks!
profiles:
a2dp_source: High Fidelity Capture (A2DP Source) (priority 20, available: unknown)
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 40, available: no)
off: Off (priority 0, available: yes)
This is very random issue and sometimes just playing with profiles solve it, going from off to a2dp, disconnect and reconnect… For me there is no reason for A2DP not working with Raspberry Pi and the Echo.
Have followed all of this, device list and paired devices show my device
Alsa is killed
No audio on youtube
I tried this multiple times and when I run the code:
part 1:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo reboot
part 2:
sudo apt-get install pulseaudio pulseaudio-module-bluetooth
dpkg -l pulseaudio pulseaudio-module-bluetooth
sudo killall bluealsa (error: bluealsa: no process found)
pulseaudio –start
sudo bluetoothctl
power on
agent on
default-agent
scan on
part 3:
pair ##:##:##:##:##:##
trust ##:##:##:##:##:##
connect ##:##:##:##:##:## (error: Attempting to connect to ##:##:##:##:##:## Failed to connect: org.bluez.Error.Failed)
It gives me 2 errors and does not work, what should I do?
Maybe the PulseAudio is ended while you are trying to configure the Bluetooth part.
Hi i have a cheap bluetooth headset. I follow every step in your tutorial and still get no audio or audio which is not audible. i alsa don’t get any errors. My headset works ok with smart phone. plz help
Is there a way to automate this whole proccess. I am making an app using python speech_recognition and pyttsx3. these require clear mic input. plz help on this too
For the automation, I can’t help much because it depends on how the Bluetooth communication is set and how much it takes. Sorry.
I can’t get audio input from mic. plz help.
I think your best way is to use a USB-Bluetooth dongle.
I don’t know this case still alive but I would like to share my experience about this issue. My main problem was low quality voice, I am using JBL 2 Go + USB Dongle (on board is disabled) and I know there is a micro inside. I don’t know why I am not an expert but based on my research from posts that you shared this speaker always connecting with HSP module. Fir this reason voice quality be *hitty…
Just I paired my speaker from GUI and I select BT for output voice. till now everything as expected, low quality sound and other problems.
I learned my mac based in these posts. I created my commands in notepad and I have created my bash script. Because the problem even when you apply the guide in every reboot speaker connects again with HSP…
Just you need to do is kill the process and connect the speaker again.
#!/bin/bash
sudo killall bluealsa
sleep 1
pulseaudio –start
sleep 1
bluetoothctl << EOF
connect cc_12_dd_ff_aa_bb
exit
EOF
sleep 10
sudo killall bluealsa
sleep 1
pulseaudio –start
sleep 1
pacmd set-card-profile bluez_card.cc_12_dd_ff_aa_bb a2dp_sink
sleep 1
pacmd set-default-sink bluez_sink.cc_12_dd_ff_aa_bb.a2dp_sink
echo "bye bye"
But just I failed about to make this as a service, I am pretty sure I have done all guidance bit and byte but no…
I don't know how can I check or see the logs but it does not work for me…
So with dongle now I can listen a better quality sound without any interruption.
Thank you for your valuable information.
Thank you! It worked perfectly!
[…] […]
Hi everyone,
I managed to connect my raspberry pi 3b+ to my car system, via Bluetooth and using A2DP. If I switch to a Bluetooth source I can listen to some music with very nice sound quality.
But, if I switch the source to Tuner, I can’t play anything. I guess it requires HFP support, but after reading some of the documents available I’m even more confuse …
I would like to play some notifications (wav files saying new mail arrived), I don’t even mind any “ring message”.
Tried ofono, hsphfpd, nOBEX but nothing seems to work for me…. I would like to just use the Raspberry, but any of the previous solutions required me to use an external modem (or sound card)…
Maybe someone can point me in the correct direction.
Thanks,
Leo
Hi,
Sorry for late answer.
What do you mean by tuner source?
[…] and select the correct profile with set-card-profile and set-default-sink. More info can be found here. Important: to exit pacmd, push the keyboard-shortcut Ctrl+d. Using the command exit or quit, […]
I can confirm as of 10 Sep 2020, this is a successful solution for connecting my RPi 3B+ to my Sony Headphones using onboard bluetooth for sound output. Didn’t try mic input. Basically the terminal commands to install Pulseaudio, pair device and A2dp sink to route audio. GUI doesn’t work, even with the latest Raspberry OS 32bit (which was previously called Raspibian). Probably can write a script with the known BT address of your headphones for easier repeated connection.
However, this seems to have broken something in Chromium as YouTube sound is now choppy when previously there was no problem. Only way to fix it seems to be a clean reinstall of Raspberry OS/Raspibian. Reinstall of Chromium didn’t fix it. Don’t know what broke. Local video/audio files played with VLC are fine.
In the end, i got myself a cheap external Bluetooth transmitter connected to my HDMI TV (HDMI sound out on the RPi) and abandoned the onboard Bluetooth of the RPi. I could also connect the external BT transmitter to the 3.5mm jack of the RPi directly but not sure if sound will be in Stereo (that’s another topic altogether).
TLDR; Get an external Bluetooth transmitter. This seems to be the fastest and easiest solution with the least problems. Onboard BT solution would be great if the Chromium issue can be fixed.
Yes the easiest way is to plug a Bluetooth USB dongle.
Posted some latest findings to fix Chromium Youtube stuttering but didn’t come out?
Just took some time to approve the comments.
[…] took a while to connect my Bluetooth speaker as a mic/speaker. This solution from Youness worked for me. Only one of the 3 speakers I had worked, but at least one did. To ensure that your […]
Hello,
Just wanted to know if it is possible to pair multiple headsets to one raspberry Pi.
thanks
I would say yes, but only one can be activated at a time.
Hi Youness. This is a brilliant post, with lots of very interesting and useful discussion. A big thank you.
A ‘quick’ question from me then. I’m thinking about making an intercom system, with an Rpi connected via Bluetooth to two headsets, so that 2 people can chat to each other in a noisy environment (on the deck of a boat), within the range limits of Bluetooth. Question – given the problems you and others have discovered, am I wasting my time?
Many thanks
Paul S
I’m not sure about the idea of connecting both headsets to the same Raspberry Pi. Maybe you can try to have two Raspberry Pis, connect them using WiFi, and then each one is connected to a headset. With this I think it is more feasible and the Wifi range is better than Bluetooth. Check also the project called talkiepi here: https://www.raspberrypi.org/blog/talkiepi-raspberry-pi-walkie-talkie/
Thank you, Youness!
Great article and worked great on my RPi4 with a Sony bluetooth headset.
If others have annoying mono sound to get out of the way first, too, please see:
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=257785&sid=p1572004#p1572004
Br,
Vegard
Hi, thank you so much for your post! i was looking around literally weeks to find this hcitool cmd…
You’re welcome!
Who would think that an over five year old post is still relevant, but it is! I have a new Raspberry Pi 4 Model b (8GB) with a Bose Revolve+ SoundLink Bluetooth speaker. I’d gotten to the point with other documentation of getting it paired and connected. (I had to go the CLI route, the BT app in the task bar would never show any BT devices). However, there was no sound. Following your guidance, I was able to actually get the speaker working!
I’m on Rapbian 11 (bullseye) and it seems that PulseAudio is the default now, so I didn’t need to start it or kill bluealsa. I didn’t try the HSP part as I’m just using this as a speaker.
Just wanted to post to say thanks to Youness, and so that others know this is still a viable solution!
Thank you, your words mean a lot for me, since I keep paying the blog hosting even if it is that old 🙂
I need to do a 2024 update to check what changed since last time, I hope Bluetooth in Raspberry Pi is better now.