84 Responses

  1. Rfb
    Rfb at | | Reply

    Hey,
    Thanks for the guide. I have the Pi3 and my Bluetooth speaker would work fine out of the box untill ran rpi-update and it broke my bluetooth connectivity. My speaker would connect and stay connected but would not be detected as a speaker. Don’t know why. I’m not that linux savvy. I think this pacmd set-default-sink bluez_sink.xx_xx_xx_xx_xx_xx , did the trick because I was using the BT gui to connect.
    Anyways, thanks to your guide I was able to get my pi 3 to play audio via Bluetooth again. My problem now is the speaker only stayed connected for about an hour then it stopped playing. Actually the speaker was still connected but the audio stopped passing through the bt speaker and defaulted to the line out of the rpi. Again , I have no idea why.

    I’d appreciate if you could help me out with that.

  2. Eric
    Eric at | | Reply

    I like your writeup so far. I spent weeks myself arriving to where you are. I gave up on trying to build PA6. I hope you can get through it and post the solution. I’m hoping some Linux gurus will likely figure it out and get it onto the Jessie distro soon and save us (i.e. you) all the trouble.

  3. Catalin Gavriluta
    Catalin Gavriluta at | | Reply

    Hi,
    I think coincidence has it that as you were updating Step 2 today, I was going through the same hassle… I am stuck in the same point as you: able to hear sound with the A2DP profile but, the HSP/HFP remains silent. I’ll keep digging and keep you updated in case I find something.

    Thanks for putting this together,
    Catalin

  4. Catalin Gavriluta
    Catalin Gavriluta at | | Reply

    What i noticed is that in bluetoothctl if you run
    info XX:XX:XX:XX:XX:XX (the address of your headset)
    and
    show (to get the information of the controller)

    The UUIDs are identical in all of the cases, except Headset. Is the same in your case? Is this important? (I actually have no idea what UUIDs are and what are they used for… my linux knowledge started with me buying the RPI some months ago… 😀 )

  5. Catalin Gavriluta
    Catalin Gavriluta at | | Reply

    Actually one is Headset: UUID starting with 0x1108 and the other is Headset AG: (Audio Gateway) UUID starting with 0x1112

  6. Julien
    Julien at | | Reply

    Hello.

    Thank you for your great TUTO.

    Step 1 was perfectly reproduced on my pi .

    But after following step 2 instructions, I’m not able to connect anymore to my Bluetooth device : connect function under bluetoothctl returns bluez failed. It did not before installing pulseaudio6.

    Do you have any idea please ? It seems that with the purge of previous pulseaudio (5.X) , the module pulseaudio-module-bluetooth was remove too, and is not installed with the build of pulseaudio 6. I can install it, because it will reinstall pulseaudio (5.x) too.

    Thank you very much.

  7. Julien
    Julien at | | Reply

    Thank you very much for your answer. But i think i miss someting : even with a the Raspbian Jessie Lite (2016-09-23) which comes without pre-installed PulseAudio, i get the error when trying to connect under bluetoothctl:

    Failed to connect: org.bluez.Error.Failed
    (pairing is ok and pulseaudio is running)

    With previous version (pulseaudio 5) it was working.

  8. Julien
    Julien at | | Reply

    Hello,

    sorry i just saw we were using different HW : you are perfomring on a PI 3 with the integrated bluetooth and im on a pi zero with an usb bluetooth dongle.

    Maybe it explains the difference.I spent the night on it, without any success. It’s a shame.

    1. Dustin Smith
      Dustin Smith at | | Reply

      Hey buddy. I think you ran into the same issue as me and it is because of the part where he installed the different libraries for the bootstrap.sh. There is a line that has a bunch of missing info. In the tutorial it is written

      “sudo apt-get install libudev-dev libsbc-dev libbluetooth-dev libx11-xcb-dev libasound2-dev
      instal libsystemd-dev libsamplerate0-dev”

      but it should be written
      “sudo apt-get install libudev-dev libsbc-dev libbluetooth-dev libx11-xcb-dev libasound2-dev
      sudo apt-get install libsystemd-dev libsamplerate0-dev”

      This fixed my problem and it was the same thing that is happening to you apparently.

  9. Johannes Bakker
    Johannes Bakker at | | Reply

    Hello,

    I try to connnect the bluetooth headset by using bluez.
    But I don’t want to GUI interface, only want to connect the headset on terminal.

    So I used the some command as following.

    1) Scan BT headset

    # hcitool scan

    BT headset : 11:22:33:44:55:66

    2) connect the headset to my rpi3
    # hcitool cc 11:22:33:44:55:66
    # hcitool auth 11:22:33:44:55:66
    # hcitool enc 11:22:33:44:55:66 0000

    But I can’t see connected headset.

    How to connect BT headset by using hcitool and hciconfig?

  10. Todor
    Todor at | | Reply

    Hi,

    I have similar problem with Raspberry Pi 3: Failed to connect: org.bluez.Error.Failed. I’m using the build-in bluetooth module and cannot connect my device. IMO this is problem with pulseaudio and now I’m trying to remove version 6. Could you help with that? I recently started to use Raspberry and not sure what must I remove to uninstall pulseaudio.
    Also I’m planning downgrade of blueZ to version 4.x because it supports HSP.

  11. Todor
    Todor at | | Reply

    Hi,

    Can I use make uninstall to remove the installed pulseaudio?

  12. Todor
    Todor at | | Reply

    Hi,

    I tried to execute “sudo make uninstall” but the output is “make: *** No rule to make target ‘uninstall’. Stop.” Could you help me with the uninstallion, maybe the script has another target for removal?

  13. Blaze
    Blaze at | | Reply

    Hi,

    I am in the same situation. Trying to get pulseaudio works with HSP profile but I have taken a slightly different approach. So, I have actually rebuilt BlueZ from 5.23 to 5.37. After skimming through the changelog of BlueZ from 5.23-5.37, I have noticed that BlueZ patched a few bugs for A2DP and also the D-Bus interface. Instead of Pulseaudio 6, I have manually built PulseAudio 8.

    The reason I chose BlueZ5.37 and PulseAudio8 is because my labtop is using Linux Mint Mate and both A2DP and HSP works! Yeah! So, I am trying to go from this approach. At the moment, its still not working though… but will keep you updated!

  14. Yahya
    Yahya at | | Reply

    Thank you so much guys , :'( i though i was alone in this world until i see this page
    I was trying all this stuff for months , i try it on desktop and it work, i try even all the available PI OS and never worked , i end up to use arch linux and a compiled ofono / pulse-audio but you should activate some configurations , example : pre-compiled ofono package has not Bluetooth module activate and you should recompiled with that argument (something like that).

    I can make calls but the sound is just not working what the hell is missing.

  15. Yevgeniy
    Yevgeniy at | | Reply

    Hi Youness,

    i have the same issue here, A2DP works fine, but HSP does not work. I have not found any solutation yet 🙁

    @Yahya: afaik HSP should work without oFono, at least this is what the changelog for PulseAudio6 says: https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/6.0/ (native HSP with Bluez5)

    Yevgeniy

  16. raspberry pi 上的pulseaudio | 风中摆酷

    […] pi3上测试自己编译高版本的pulseaudio,参考: http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi […]

  17. Robert Brown
    Robert Brown at | | Reply

    Thank you for this, it was quite helpful. My only suggestion is rather than manually compiling pulseaudio 6, if you add Debian backports you can just apt-get install the packages. This avoids dependency hell with things like pulseaudio-module-bluetooth.

    First add GPG keys for the backports:
    gpg –keyserver pgpkeys.mit.edu –recv-key 8B48AD6246925553
    gpg –keyserver pgpkeys.mit.edu –recv-key 7638D0442B90D010
    gpg -a –export 8B48AD6246925553 | sudo apt-key add –
    gpg -a –export 7638D0442B90D010 | sudo apt-key add –

    Then follow directions here to add to your apt sources:
    https://backports.debian.org/Instructions

    You should now see 7.x versions when you do this:
    apt-cache policy pulseaudio

    Now add packages:
    apt-get install pulseaudio=7.1-2~bpo8+1 pulseaudio-module-x11=7.1-2~bpo8+1 pulseaudio-module-bluetooth=7.1-2~bpo8+1 libpulse0=7.1-2~bpo8+1 pulseaudio-utils=7.1-2~bpo8+1 libpulsedsp=7.1-2~bpo8+1

    Finally back to your tutorial:
    dpkg -l pulseaudio

    Should show 7.1-2~bpo8+1.

  18. Robert Brown
    Robert Brown at | | Reply

    Not sure yet re: dbus – I have the audio output working now via the pulseaudio 7.x packages. I’m down a different rabbithole now to compile a cli softphone (pjsua) so I can try a full-duplex phone call. Still working on that one.

  19. PK
    PK at | | Reply

    Did anyone success in bluetooth mic working, I have upgraded now to pulseaudio 7 and has HSP enabled but still mic is not working only speaker is working good.

  20. Cody
    Cody at | | Reply

    Unsure how active this board is, but I followed the guide and cannot get my bluetooth headset to connect. I can get all the way through pair and trust, but it will not connect. What am I doing wrong?

    Thanks

    Satch

  21. Keaton Freude
    Keaton Freude at | | Reply

    Hey All —

    A colleague and I have been following this article (and many others on the internet) closely in order to get A2DP & HFP/HSP working on Raspberry Pi. We’ve finally collected enough information from the various corners of the internet, obscure release notes and testing to put together a full end-to-end workflow to get both A2DP SRC and HFP/HSP AG working (that is playing music/voice from Raspberry Pi to a compatible headset).

    Some info: I have tested A2DP with a Nokia headset which supposedly supports A2DP & HSP. I tested HFP/HSP with a small in-ear Nokia earpiece which supports both HSP & HFP.

    The steps in this article are very close to the correct working steps, though there are a number of things you must check.

    In our use case we started with the Raspbian Jessie Lite Image found here: https://www.raspberrypi.org/downloads/raspbian/

    I flashed it onto an SD, inserted into Raspberry Pi and booted the pi. I did a number of things to make it more accessible for me: (enable SSH, set localization, set keyboard settings, etc). So I was working from a very minimal image with very little changes.

    NOTE: At this point there should be _no_ installation of PulseAudio present.

    I then performed the following steps:
    – apt-get update
    – apt-get upgrade
    – wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-6.0.tar.xz
    – tar xvf pulseaudio-6.0.tar.xz
    – apt-get -y install intltool libtool libcap-dev libjson0-dev libsndfile1-dev libudev-dev libsbc-dev libbluetooth-dev libx11-xcb-dev libasound2-dev libsystemd-dev libsamplerate0-dev libspeexdsp-dev libdbus-1-dev
    – cd pulseaudio-6.0 && ./configure –disable-x11 –disable-bluez4 && make -j 8 && make install && ldconfig
    – apt-get install pulseaudio-module-bluetooth

    That last step makes _no_ sense to me, but it IS required. The version of PulseAudio in the default raspbian repo is 5.0. That last apt-get is going to install pulseaudio 5.0, along with required dependencies. When you build pulseaudio from source and install it, its going to install into: /usr/local/…
    while the apt-get is going to install pulseaudio 5.0 in /usr/…

    Next I installed ofono:
    apt-get install ofono

    NOTE: The ordering of things above is sort of strange, I’m sure other orders work but I am writing my exact steps in case the order does end up mattering.

    Next you’ll want to add your user(s) to the pulse-access group:
    adduser pulse-access
    In my case the user is the default pi.

    Now we need to make some config changes. Note that the configs stored in “/usr/etc…” are not going to be used. The version we installed from source is going to look at: “/usr/local/etc…” so we will be modifying files found there.

    sudo nano /usr/local/etc/pulse/default.pa

    Find the line “load-module module-bluetooth-discover” and change to: “load-module module-bluetooth-discover headset=auto”

    Add the following line to the very bottom of the file:
    load-module module-switch-on-connect only_from_unavailable=false

    Save and exit default.pa

    sudo nano /usr/local/etc/pulse/daemon.conf
    Find the line: ; exit-idle-time = 20. Remove the semicolon and change the 20 to -1 (this will make sure pulseaudio doesn’t exit while you setup your device).
    Save and exit daemon.conf

    Another thing which _may_ matter which I have not tested (I plan to soon) is loading the snd-aloop module. I currently have the following command issued upon boot (via init.d):
    modprobe snd-aloop

    At this point I would reboot the system as we are done with configuration. Again, NOTE: that modprobe snd-aloop may need to be done every boot. You can try it out and see if its not needed, I plan to do so soon.

    After reboot we need to make sure that ofonod and pulseaudio are both running. It is very important to run both pulseaudio and ofonod in user-mode not root. This means you should be logging into your machine as non-root. I logged in as pi.

    First, lets make sure both pulseaudio and ofonod are stopped.
    sudo killall pulseaudio
    sudo killall ofonod

    Then we want to start both:
    I like to check that the correct version of pulseaudio is being picked up. You can check with:
    pulseaudio –version
    if it prints pulseaudio 6.0 then we are good.

    Issue the following two commands to get both pulseaudio and ofonod running:
    pulseaudio –start
    ofonod

    Both should be running in the background now. Next we need to pair and connect our headphones/headset. You can swap between a2dp and hsp/hfp on headphones which support both modes. In my testing I made sure that I used A2DP-enabled headphones for A2DP tests and HFP-only headset for HFP test. I need to test with some dual-profile headphones and report back on commands to swap.

    Lets pair and connect your bluetooth device. Put your bluetooth device in discoverable/pairable mode. Then run bluetoothctl
    When in bluetoothctl issue the following commands:
    pairable on
    discoverable on
    scan on
    agent on
    default-agent

    Wait for your headphones to be discovered then type:
    pair (NOTE: bluetoothctl supports tab-complete on commands and MAC addresses to save some time).
    After pairing is done:
    connect
    Connection should work! If it doesn’t, check again that pulseaudio is still running (ps axg | grep pulse) and that ofono is still running (ps axg | grep ofono). Also ensure they are run from the non-root account.

    If the connection succeeds, go play some music using whatever. I used aplay to play a .wav file I copied onto my raspberry pi. I heard A2DP audio on my A2DP headset and terrible quality music on my HSP/HFP headset 🙂

    There’s a lot of steps here and a lot of overlap with the instructions in the main post. I may have missed something. If you can report back your experience I’d be happy to follow up.

    -Keaton

  22. Keaton Freude
    Keaton Freude at | | Reply

    Hey,

    Yeah, I was incorrect about requiring ofono. Originally we had intended to support HFP (HSP audio + phone operations) but we decided we didn’t care enough to get it working.

    I know that pulseaudio-module-bluetooth is in the PA sources, I wrote in my original comment that the step makes no sense. However I tested it very carefully and found that the apt-get install step is required. Not specifically for that module, but most likely one of its dependencies (there are quite a few). From a fresh image if I omit that step, A2DP does not work. Very baffling to me personally.

    headset=auto is definitely required. If I remove this line and restart PA, my HSP no longer works correctly. I know that it _shouldn’t_ be required, but for me at least it was definitely required.

    I have tested HSP on a Nokia BH104, and a set of speakers (Big Jam Box). For A2DP I tested against Nokia BH 503 headphones and again on the Big Jam Box speakers.

    I am listening to some awful mono quality music on my BH 104 right now. pactl list cards shows:
    headset_head_unit as my profile. It also shows 1 sink 1 source.

    Mic In is working correctly with no additional setup. Volume is a bit low and the mic on this particular bluetooth headset is a pile of garbage, but I can hear myself when playing back the wav file I saved with: arecord

    Thanks,
    Keaton

  23. stephen littman
    stephen littman at | | Reply

    Youness,
    Have you tested?

  24. Glen
    Glen at | | Reply

    You rock buddy,

    After sifting through all the crap google gave me, i just needed your “pulseaudio –start” above (Ripper!!)

    Cheers
    Glen20

  25. g10dras
    g10dras at | | Reply

    Installing PulseAudio from jessie-backport solve my problem.
    A2DP and HSP both works.

    sudo nano /etc/apt/sources.list
    ### add this line at last
    deb http://ftp.debian.org/debian jessie-backports main

    gpg –keyserver pgpkeys.mit.edu –recv-key 8B48AD6246925553
    gpg –keyserver pgpkeys.mit.edu –recv-key 7638D0442B90D010
    gpg -a –export 8B48AD6246925553 | sudo apt-key add -gpg -a –export 8B48AD6246925553 | sudo apt-key add –
    gpg -a –export 8B48AD6246925553 | sudo apt-key add –
    gpg -a –export 7638D0442B90D010 | sudo apt-key add -gpg -a –export 7638D0442B90D010 | sudo apt-key add –
    gpg -a –export 7638D0442B90D010 | sudo apt-key add –

    sudo apt-get update
    sudo apt-get autoremove

    sudo apt-get autoremove pulseaudio pulseaudio-utils -y
    sudo apt-get autoremove pulseaudio-module-bluetooth pulseaudio-module-x11 pulseaudio-module-zeroconf -y
    sudo apt-get autoremove install paman pavucontrol pavumeter -y
    sudo apt-get autoremove install libpulse0 libpulsedsp

    sudo apt-get -t jessie-backports install pulseaudio pulseaudio-utils -y
    sudo apt-get -t jessie-backports install pulseaudio-module-bluetooth pulseaudio-module-x11 pulseaudio-module-zeroconf -y
    sudo apt-get -t jessie-backports install libpulse0 libpulsedsp
    sudo apt-get -t jessie-backports install paman pavucontrol pavumeter -y

    dpkg -l | grep -v deinstall | grep PulseAudio

    ii paman 0.9.4-1+b1 armhf PulseAudio Manager
    ii pavucontrol 2.0-3 armhf PulseAudio Volume Control
    ii pavumeter 0.9.3-4+b1 armhf PulseAudio Volume Meter
    ii pulseaudio 7.1-2~bpo8+1 armhf PulseAudio sound server
    ii pulseaudio-module-bluetooth 7.1-2~bpo8+1 armhf Bluetooth module for PulseAudio sound server
    ii pulseaudio-module-x11 7.1-2~bpo8+1 armhf X11 module for PulseAudio sound server
    ii pulseaudio-module-zeroconf 7.1-2~bpo8+1 armhf Zeroconf module for PulseAudio sound server
    ii pulseaudio-utils 7.1-2~bpo8+1 armhf Command line tools for the PulseAudio sound server

    sudo nano /etc/pulse/daemon.config
    exit-idle-time = -1

    pulseaudio –k
    pulseaudio -D

  26. Patrik
    Patrik at | | Reply

    Hi Youness,

    Thank you for sharing this.

    Not sure about HSP, but HFP works with Pulseaudio 7 when used with this program: https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=96979
    I am however not able to get Pulseaudio 7 to start separately without the program. It could be that some config files are missing.

    Cheers,
    Patrik

  27. Buya
    Buya at | | Reply

    Hi Youness,

    I’ve gone through your instruction and got the follow. It looks that HSP is enabled which i consider (if i’m wrong please correct me) as both the output and input are available. However there was no sound available in/out. Any idea?

    What i’ve got:
    2 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 = “/devices/virtual/sound/card0”
    sysfs.path = “/devices/virtual/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.0.analog-stereo/#0: bcm2835 ALSA Analog Stereo
    sources:
    alsa_output.0.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
    ports:
    analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
    properties:

    index: 1
    name:
    driver:
    owner module: 25
    properties:
    device.description = “RB-T7”
    device.string = “00:15:13:53:93:BA”
    device.api = “bluez”
    device.class = “sound”
    device.bus = “bluetooth”
    bluez.path = “/org/bluez/hci0/dev_00_15_13_53_93_BA”
    bluez.class = “0x002540”
    bluez.alias = “RB-T7”
    device.icon_name = “audio-card-bluetooth”
    profiles:
    headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
    off: Off (priority 0, available: yes)
    active profile:
    sinks:
    bluez_sink.00_15_13_53_93_BA/#1: RB-T7
    sources:
    bluez_sink.00_15_13_53_93_BA.monitor/#1: Monitor of RB-T7
    bluez_source.00_15_13_53_93_BA/#2: RB-T7
    ports:
    unknown-output: Bluetooth Output (priority 0, latency offset 0 usec, available: unknown)
    properties:

    unknown-input: Bluetooth Input (priority 0, latency offset 0 usec, available: unknown)
    properties:

  28. Buya
    Buya at | | Reply

    Youness,

    Thank you for all the work you’ve done here! Appreciated!
    Thanks for the prompt reply, too!

    Buya

  29. Tim
    Tim at | | Reply

    Hi Youness,

    Really nice tutorial.

    I am a NOOB and I am trying to connect my JBL Go BT speaker to my RPI3. I want my speaker to connect at a certain time and have it play a livestream… As a radio alarm clock… Not sure if it will ever work but I like to try.

    Currently I am able to connect my RPI to my BT speaker through bluetoothctl and pulseaudio –start.

    Problem 1:
    After being connected, when Ienter the command ‘pacmd list-cards’ I only see one BT card…

    Problem 2:
    When I use the command mplayer http://stream… the stream starts running but there is no audio coming out of my BT speaker.

    Any thoughts?!

  30. Nico
    Nico at | | Reply

    Hi,

    Thanks for this post, it’s very usefull.
    However, I have a RPI 2B with a fresh Jessie install but I don’t have any bluez_card.xx_xx_xx_xx_xx_xx when I list cards 🙁

    [bluetooth]# info xx:xx:xx:xx:xx:xx
    Device xx:xx:xx:xx:xx:xx
    Name: UE ROLL 2
    Alias: UE ROLL 2
    Class: 0x240404
    Icon: audio-card
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Vendor specific ([…])
    UUID: Serial Port ([…])
    UUID: Audio Source ([…])
    UUID: Audio Sink ([…])
    UUID: A/V Remote Control Target ([…])
    UUID: Advanced Audio Distribu.. ([…])
    UUID: A/V Remote Control ([…])
    UUID: PnP Information ([…])
    Modalias: bluetooth:v000ApFFFFdFFFF

    pi@raspberrypi:~ $ pacmd list-cards
    2 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 = “/devices/virtual/sound/card0”
    sysfs.path = “/devices/virtual/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 100, 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.0.analog-stereo/#0: bcm2835 ALSA Stéréo analogique
    sources:
    alsa_output.0.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Stéréo analogique
    ports:
    analog-output: Sortie analogique (priority 9900, latency offset 0 usec, available: unknown)
    properties:

    index: 1
    name:
    driver:
    owner module: 23
    properties:
    device.description = “UE ROLL 2”
    device.string = “xx:xx:xx:xx:xx:xx”
    device.api = “bluez”
    device.class = “sound”
    device.bus = “bluetooth”
    device.form_factor = “headset”
    bluez.path = “/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx”
    bluez.class = “0x240404”
    bluez.alias = “UE ROLL 2”
    device.icon_name = “audio-headset-bluetooth”
    device.intended_roles = “phone”
    profiles:
    a2dp_source: High Fidelity Capture (A2DP Source) (priority 10, available: unknown)
    a2dp: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
    off: Éteint (priority 0, available: yes)
    active profile:
    ports:
    headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
    properties:

    headset-input: Headset (priority 0, latency offset 0 usec, available: no)
    properties:

    Any suggestion would be appreciated 🙂

  31. Nico
    Nico at | | Reply

    I found myself the answer.
    If you don’t see the bluez_sink card, try this :

    pactl set-card-profile 1 a2dp

  32. Uriel Guy
    Uriel Guy at | | Reply

    Here is my script for auto connect to my bluetooth speakers. I haven’t optimized the sleep times yet, can probaby be done with grep.

    #!/bin/bash

    pulseaudio –start
    sleep 2

    {
    sleep 1;
    echo “power on”
    sleep 1
    echo “agent on”
    sleep 1
    echo “default-agent”
    sleep 1;
    echo “remove 00:11:67:11:11:B7”
    sleep 1
    echo “scan on”
    sleep 15
    echo “scan off”
    sleep 1
    echo “pair 00:11:67:11:11:B7”
    sleep 1
    echo “trust 00:11:67:11:11:B7”
    sleep 4
    echo “connect 00:11:67:11:11:B7”
    sleep 5;
    echo exit
    } | bluetoothctl

    sleep 2
    pacmd set-default-sink bluez_sink.00_11_67_11_11_B7

  33. Dennis Chacko
    Dennis Chacko at | | Reply

    I’ve been sifting through the comments, and i would like to know has the bluetooth audio input worked yet?
    @Youness are you close to completing step 2?

  34. Emil Borconi-Szedressy
    Emil Borconi-Szedressy at | | Reply

    Youness have you tried using an external Bluetooth dongle?
    I was able to get HFP+A2DP to work on a RPI3, but only with external bluetooth, the one build in just did not work for the HFP profile. There was no sound what so ever.

    Also do you have any idea on how can we load the module-echo-cancel for HFP?

    I’m trying to build a handsfree based on the RPI, I kind-a got it working but I’m facing 2 problems:
    1) Echo
    2) Stability

    For me the easiest way to get it all working was one of the following 2:
    a) Use Jessie-Backports (comes with Pulseaudio 7.1 )
    b) Use Stretching repo (comes with PulseAudio 10.0)

    Again another thing, for some reason Raspberry Pi Zero, same setup as the Pi 2 or Pi 3 but there is no audio when using HFP only some garlicky sound. Tried compiling PulseAudio for the Pi Zero same result, so Pi Zero might not be a working solution.

  35. Victor
    Victor at | | Reply

    First of all, thanks for the tutorial. I was simply trying to get output to a bluetooth speaker. But now I’m having the issue where I can’t switch the sound back to the analog output. Not sure why, I switched the sink back over to the analog, its not muted. Not sure what the issue is. Sorry I’m super new to linux tinkering

    pi@rpi-vtrevino:~$ pacmd list-sinks
    1 sink(s) available.
    * index: 0
    name:
    driver:
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY FLAT_VOLUME DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9009
    volume: front-left: 56210 / 86% / -4.00 dB, front-right: 56210 / 86% / -4.00 dB
    balance 0.00
    base volume: 56210 / 86% / -4.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 0
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
    Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 341.33 ms
    card: 0
    module: 6
    properties:
    alsa.resolution_bits = “16”
    device.api = “alsa”
    device.class = “sound”
    alsa.class = “generic”
    alsa.subclass = “generic-mix”
    alsa.name = “bcm2835 ALSA”
    alsa.id = “bcm2835 ALSA”
    alsa.subdevice = “0”
    alsa.subdevice_name = “subdevice #0”
    alsa.device = “0”
    alsa.card = “0”
    alsa.card_name = “bcm2835 ALSA”
    alsa.long_card_name = “bcm2835 ALSA”
    device.bus_path = “/devices/virtual/sound/card0”
    sysfs.path = “/devices/virtual/sound/card0”
    device.string = “hw:0”
    device.buffering.buffer_size = “65536”
    device.buffering.fragment_size = “65536”
    device.access_mode = “mmap+timer”
    device.profile.name = “analog-stereo”
    device.profile.description = “Analog Stereo”
    device.description = “bcm2835 ALSA Analog Stereo”
    alsa.mixer_name = “Broadcom Mixer”
    module-udev-detect.discovered = “1”
    device.icon_name = “audio-card”
    ports:
    analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
    properties:

    active port:

    Not sure if anything stands out here. Still messing around with it myself.

    Im sure someone has had this issue and wants to be able to switch back and forth.

    1. Victor
      Victor at | | Reply

      Ok so I figured out something… Not sure what that is exactly. But it answers some questions and raises new ones. Wasn’t getting any sound from doing ‘mpg123 sound.mp3’ but then I tried omxplayer and the clip played. I see that omxplayer doesn’t use ALSA, so I guess it doesn’t configure the same way.

      I changed my raps-config back to auto detect mode and tried to play the mp3 but it was just scratch noises. But then I killed pulse audio and the sound clip played fine.

      Things i’ve learned: Life is precious. And I’m still confused

      1. Victor
        Victor at | | Reply

        So now I see my blue tooth device when I list-cards
        pi@rpi-vtrevino:~$ pacmd list-cards
        2 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 = “/devices/virtual/sound/card0”
        sysfs.path = “/devices/virtual/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 100, available: unknown)
        output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
        off: Off (priority 0, available: unknown)
        active profile:
        sinks:
        alsa_output.0.analog-stereo/#0: bcm2835 ALSA Analog Stereo
        sources:
        alsa_output.0.analog-stereo.monitor/#0: Monitor of bcm2835 ALSA Analog Stereo
        ports:
        analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
        properties:

        index: 4
        name:
        driver:
        owner module: 27
        properties:
        device.description = “AMPLIFi 75 9f”
        device.string = “00:07:80:0C:D5:9F”
        device.api = “bluez”
        device.class = “sound”
        device.bus = “bluetooth”
        device.form_factor = “hifi”
        bluez.path = “/org/bluez/hci0/dev_00_07_80_0C_D5_9F”
        bluez.class = “0x200428”
        bluez.alias = “AMPLIFi_75_9f”
        device.icon_name = “audio-card-bluetooth”
        profiles:
        a2dp: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
        off: Off (priority 0, available: yes)
        active profile:
        ports:
        hifi-output: HiFi (priority 0, latency offset 0 usec, available: unknown)
        properties:

        hifi-input: HiFi (priority 0, latency offset 0 usec, available: no)
        properties:

        but not when I list sinks -__-

  36. Victor
    Victor at | | Reply

    Ok so that
    pactl set-card-profile 4 a2dp

    Worked, sorry for spam. The index on the sound card keeps going up every time I reconnect to the speaker on blue tooth. I didn’t notice, also didn’t have to do that step the first time… Sorry and thanks

  37. John
    John at | | Reply

    what a huge waste of time for this…..pulse 5 no 6 no wait 7 no lets backport it wtf?
    it is had to believe that such a relatively minor feature is not usable, or reliable.
    Welcome to open source hell…. we will probably have to wait for the Pi4 or 5.
    Just forget the integrated bluetooth for now

  38. Jerry Xu @Shanghai
    Jerry Xu @Shanghai at | | Reply

    Hi, Youness, thank you for this CLEAR tutorial! I got what I need from this post.
    The A2DP part works on Raspbian Jessie and bluetooth speaker.
    The audio quality is not that satisfied via ALSA, it’s even worse after starting pulseaudio daemon. Next, I will try usb audio device, hope the audio quality could be better for a DIY Music alarm clock.
    Also, thank you Uriel Guy, you shell script works too.

  39. Zmeu
    Zmeu at | | Reply

    Tried this with a JBL Charge 3 and Keaton’s guide. Initially only worked in a2dp mode if I switched the profile. I was getting this:

    headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
    off: Off (priority 0, available: yes)

    Neither output or input worked on the headset_head_unit profile.

    dmesg | grep -i bluetooth
    bluetooth hci0: Direct firmware load for brcm/BCM20702A1-0b05-17cb.hcd failed with error -2

    I noticed there was an issue with my hci0, so I started googling for possible issues with HSP with my usb bluetooth dongle (Asus bt400) and found this:
    https://workingninja.com/installing-asus-bt400-raspberry-pi-raspbian-wheezy

    Updated my firmware by following those steps. Rebooted, reconnected to the speaker. Now I can run:

    parecord -v test.wav
    paplay -v test.wav

    And I can hear my recording through the BT speaker.

    Other steps I randomly did, not sure if they had anything to do with it:

    sudo apt-get reinstall bluez bluez-firmware
    apt-get reinstall pulseaudio-module-bluetooth
    (then I reran the pulse audio 6 install AFTER the reinstall of pulse audio 5)
    cd pulseaudio-6.0 && sudo make install

    Here’s what my pactl list cards looks like now:

    Card #2
    Name: bluez_card.B8_69_C2_40_83_26
    Driver: module-bluez5-device.c
    Owner Module: 24
    Properties:
    device.description = “JBL Charge 3”
    device.string = “B8:69:C2:40:83:26”
    device.api = “bluez”
    device.class = “sound”
    device.bus = “bluetooth”
    device.form_factor = “speaker”
    bluez.path = “/org/bluez/hci0/dev_B8_69_C2_40_83_26”
    bluez.class = “0x240414”
    bluez.alias = “JBL Charge 3”
    device.icon_name = “audio-speakers-bluetooth”
    Profiles:
    headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
    off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: headset_head_unit
    Ports:
    speaker-output: Speaker (priority: 0, latency offset: 0 usec)
    Part of profile(s): headset_head_unit, a2dp_sink
    speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec)
    Part of profile(s): headset_head_unit

Please comment with your real name using good manners.

Leave a Reply