Ubuntu – How to configure 2 bluetooth speakers with 2 bluetooth dongles

14.04bluetoothpulseaudiosound

I normally stream to my computer speakers and to a bluetooth speaker by using pulseaudio. So far no major problems. But then I though about connecting a second bluetooth speaker.

I use the bluetooth connection provided by a Kensington bluetooth v4.0 dongle, but when I tried to connect the 2 speakers, the second one connected and disconnected immediately. After some research I concluded that my bluetooth interface only supports one A2DP streaming simultaneously, so the solution was or to buy a multi-stream dongle (not sure if those exist) or trying to use a second bluetooth dongle on parallel (that's what I'm trying).

My idea was the following: I connect speaker 1 to dongle 1, I connect speaker 2 to dongle 2, I configure pulseaudio to stream to both speakers simultaneously, then I sit and relax. Well… I cannot make it work.

I see the 2 hci0 and hci1 when I run hciconfig, but when together I cannot detect any devices. I tried disabling one of the dongles with hciconfig to connect with the other one and test, but it doesn't work. Both dongles work perfectly if they are connected alone on the PC, but I cannot make them work simultaneously. I also tried blueman but I get the same behavior that from command line. So my questions would be:

  • Is it possible to configure 2 bluetooth dongles simultaneously on Ubuntu 14.04?
  • Is it possible to stream audio to 2 bluetooth interfaces simultaneously?

If any of the question has a "YES" answer, I will really like to know how.

Best Answer

Ok, I have discovered that it is possible and I discovered how:

  1. I installed all bluez (bluez + bluez-*) packages and purged any other application related to bluetooth (blueman, bluewho, etc.). I do not know if this is strictly relevant, but until I didn't do this I couldn't manage to connect to the speakers.

    I also installed all the pulseaudio utilities and configured the simultaneous output virtual device.

  2. Connect your 2 dongles. They will get the names hci0 and hci1

  3. You should check that the devices are not blocked with:

    rfkill list

    If you find any blockage on the bluetooth interfaces (this command will also show your wifi) you need to unblock it (check rfkill man page to proceed).

  4. Check that there are no devices paired to your bluetooth interfaces with:

    bt-device -a hci0 -l

    bt-device -a hci1 -l

    If there are paired devices I preferred to delete all previous pairings before continuing with:

    bt-device -a hciX -r XX:XX:XX:XX:XX:XX

  5. Check that your devices can be reached from the dongles by discovering them with:

    hcitool -i hci0 scan

    hcitool -i hci1 scan

  6. With the previous step you will get the bluetooth mac addresses of the devices (the string that looks like XX:XX:XX:XX:XX:XX). With those numbers you should pair the speakers with (I added a 1 and 2 at the end of the mac addresses to identify the 2 different speakers):

    bt-device -a hci0 -c XX:XX:XX:XX:XX:X1

    bt-device -a hci1 -c XX:XX:XX:XX:XX:X2

  7. Connect to the speakers for audio with:

    bt-audio -a hci0 -c XX:XX:XX:XX:XX:X1

    bt-audio -a hci1 -c XX:XX:XX:XX:XX:X2

At this moment you should be able to find the 2 speakers at the PulseAudio Volume Control GUI, there you may play and adjust the latency, volumes, etc.


Extra Information:

Hi, this is a little update for those of you that are reading and up-voting this post.

If you are trying to connect multiple speakers with the idea of a multi-room audio system, Bluetooth might not be the best solution at all. It turns out that the timing on a Bluetooth audio streaming drifts depending on the interference you find between the source and sink, this makes that after some minutes you end up with the music playing at different instants in each one of the speakers. Even if you perfectly adjust the latency (a parameter that allows you to set a delay between sinks), after some minutes the audio will drift notoriously among the different sinks.

As I wanted to set a multi-room audio system, this solution did not really worked out and at the end I was able to find some relatively inexpensive devices that explicitly support multi-room audio over wifi instead of this original cheap idea of using multiple Bluetooth dongles.

Related Question