maihoaomv
Posts: 32
Joined: Wed Oct 08, 2014 5:16 pm

Bluetooth audio streaming to bluetooth headset / headphone

Sat Apr 11, 2015 6:44 pm

ok. more or less got "bluetooth audio streaming" to rpi per post on this fourm to work on the android xoom. still need to set it up to connect to the android phone but that is a project for another time.

i'm hard of hearing so i use a bluetooth headset attached to a set of headphones when i watch tv. what i'd like to be able to do is connect the rpi to the headset and stream music to the headset which is pretty much the opposite of said post.
i have 2 of these headsets; bluedio i4 (tv) and bluedio i4s (fantastic headsets for the price by the way). both which, according to the spec, are capable of a2dp with the difference being that one is version 2 and the other ver 3, i believe, capable of 2 connections rather than 1. for the purpose of listening to music i'll be using the i4s in order to avoid re-connection problems to the tv with the i4. i'm using a ver 4 bluetooth dongle on the pi.

if it's possible to do, i need some help with setting it up.
thanks

User avatar
Douglas6
Posts: 4918
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming to bluetooth headset / headpho

Sun Apr 12, 2015 1:56 am

Sending audio to an A2DP speaker/headphone is pretty simple, if using ALSA only. If you don't yet have BlueZ installed, go ahead and install it:

Code: Select all

sudo apt-get install -y --no-install-recommends bluetooth bluez-utils bluez-alsa python-gobject
Enable the needed Bluez profiles in audio.conf

Code: Select all

sudo nano /etc/bluetooth/audio.conf
and add the following line under the [General] section header:

Code: Select all

Enable=Source,Sink,Media,Socket
Then reboot the pi to let it think about what you've said.

Code: Select all

sudo reboot
If you haven't yet, pair and trust your speaker/headphones. First, put the speaker in 'discoverable' mode (consult the documentation for your speaker). Then scan for its Bluetooth device address:

Code: Select all

hcitool scan
Here are the results for my SuperTooth Disco speaker (stupid name, I know):

Code: Select all

Scanning ...
        AA:BB:CC:DD:EE:FF       ST DISCO R58
Copy the returned Bluetooth device address. I'll be using AA:BB:CC:DD:EE:FF throughout. Now, while still in discoverable mode, pair the speaker:

Code: Select all

sudo bluez-simple-agent hci0 AA:BB:CC:DD:EE:FF
It should ask you for the PIN code. Again consult your documentation, but it's probably '0000' or '1234'. The pairing agent should then release the agent and give you the new BlueZ device path. Trust the device so that it can autoconnect:

Code: Select all

sudo bluez-test-device trusted AA:BB:CC:DD:EE:FF yes
Now we'll create a ALSA PCM device to play audio on. Edit or create a new asound.conf file:

Code: Select all

sudo nano /etc/asound.conf
and add the following:

Code: Select all

pcm.bluetooth {
    type bluetooth
    device AA:BB:CC:DD:EE:FF
    profile auto
}

ctl.bluetooth {
    type bluetooth
}
Test the ALSA device

Code: Select all

aplay -D bluetooth test.wav
I haven't done alot of testing with this, but it seems to work OK.

If you're using PulseAudio, things get a bit trickier, but the potential is there. I'll add to this thread if/when I get it all figured out.

maihoaomv
Posts: 32
Joined: Wed Oct 08, 2014 5:16 pm

Re: Bluetooth audio streaming to bluetooth headset / headpho

Sun Apr 12, 2015 7:03 pm

i can't get this to work. i installed the packages as indicated. scan sees both headsets. when i pair with either headset it doesn't ask for pairing code (s/b 0000). ok so it gets no error and it appears to trust it. when i do sudo hcitool cc 13:04:11:21:14:9E there is no error and it appears to connect and the led goes into the periodic flash (~4sec) but, the headset doesn't do the 10 quick flashes to indicate a connection is made. sudo hcitool con returns nothing. i don't have anything else to test it on so i'm lost.
thanks
(this response is a bit rushed, wife is up next)

User avatar
Douglas6
Posts: 4918
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth audio streaming to bluetooth headset / headpho

Sun Apr 12, 2015 7:41 pm

A2DP devices are all a little different. But using ALSA, it will make the connection for you. Don't bother with the 'hcitool cc'. Try the aplay command, as above.
If you do want to connect manually, try

Code: Select all

sudo bluez-test-audio connect AA:BB:CC:DD:EE:FF

maihoaomv
Posts: 32
Joined: Wed Oct 08, 2014 5:16 pm

Re: Bluetooth audio streaming to bluetooth headset / headpho

Sun Apr 12, 2015 11:52 pm

it worked once i tried the aplay with a .wav file. i also was able to get it to work with mpd by adding the following to the mpd.conf file:

Code: Select all

# Bluetooth ALSA output:
#
audio_output {
        type            "alsa"
        name            "Bluetooth"
        device          "bluetooth"
        #device         "hw:0,0"        # optional
        format          "44100:16:2"    # optional
        #mixer_device   "default"       # optional
        #mixer_control  "PCM"           # optional
        #mixer_index    "0"             # optional
}
i now have a bluetooth output option with the "droid mpd" app i'm using on the phone. up next is getting rpi setup so i have the option to stream other players such as pianobar and mpg321 to the headset if i want. but that is a project for later.

i think i'm starting to get a handle on how this works.
thank you very much for all your help.

dodger4
Posts: 13
Joined: Sat Nov 15, 2014 5:24 pm

Re: Bluetooth audio streaming to bluetooth headset / headpho

Wed Aug 05, 2015 5:30 am

I can't seem to get any sound from my Bose Mini II Soundlink speakers.

I have edited the audio.conf file, created the asound.conf file (is that correctly in the /etc top directory, or should it be in /bluetooth subdirectory?)

The speakers are paired and connected (at least the synthetic voice tells me it is: "connected to raspberry pee") That connection is handled by the bluetooth GUI (Blueman device manager 1.22) and did it seamlessly after I installed blueman.

test.wav cannot be found, from the root ls -R test.wav, so aplay doesn't make a sound.

In Bleuman, I select headset service or A2DP sink (send audio) but neither works. Selecting A2DP tells me "Device added successfully, but failed to connect"

hang on, I turned the speakers off, then on again, and the A2DP service tells me it's connected...but I still don't have any sound. Playing an mp3 with LX Music

What am I missing please?

dodger4
Posts: 13
Joined: Sat Nov 15, 2014 5:24 pm

Re: Bluetooth audio streaming to bluetooth headset / headpho

Wed Aug 05, 2015 5:39 am

As a matter of idle curiosity, how does this Bluetooth pairing/connection redirect audio to the bluetooth adapter, rather than the 3.5 mm analog jack or the HDMI as set in rasp-config?

User avatar
jhansx
Posts: 38
Joined: Tue Apr 04, 2017 4:38 pm
Location: Green River, Wyoming

Re: Bluetooth audio streaming to bluetooth headset / headphone

Sun Feb 25, 2018 4:34 am

The Mpow Judge bluetooth headphones do not generate an option after installing with the GUI and the Bluez software fives an obsoleted error code when installation is attempted and sudo bluez gets a bash.
Help!

Return to “General discussion”