Raspberry PI Bluetooth Wireless Speaker

Recently I’ve acquired a Conceptronic 2-Way Audio Wireless Speakerphone (Bluetooth)  and I wanted my PI to connect to the speakers for a small project and after an afternoon struggling with it, here’s how I’ve managed to connect them using only alsa and command line tools.  No GUI tools are used.

The bluetooth module I’ve used is an Edimax EB-DGC2 ! It’s obsolete, but it was the only one that worked with the bluetooth audio. I was first testing with a Conceptronic CBT2NANO (v2.0), but it didn’t work and I’ve switched to the EDIMAX


Now, connect the USB bluetooth dongle and install the required packages.

Add your user to the bluetooth group

After installing the packages, reboot your PI.

Start your bluetooth device (hope the bluetooth service is already running)

Turn the wireless speaker on and ready to connect and scan for devices

After scanning and found, connect to it

Output from the above command

NOTE: In the PIN CODE, use 0000 (four zeros – it worked for me)

Now, test the audio

NOTE: This was the step were i had a lot of python exceptions and had to change the bluetooth dongle. After that, everything worked fine

You should hear a couple of bips from the speaker – that’s good

Now, let’s trust the device, so it connects every time the PI boots

Check if it’s already trusted

The result will be 0 for not trusted and 1 for trusted

If it’s 0, let’s make it trusted

Check again

The result should be 1

Now, let’s configure the new sound card

Create a file .asoundrc in your home folder

Paste the following contents:

Save and exit

NOTE: For some people probably it won’t work and it’s necessary to copy the file to /etc and rename it to asound.conf

It’s necessary to edit the bluetooth audio configuration and change some configurations

and add the following to the [General] section of the file

Save and exit. Restart the bluetooth service

Now, let’s try and play some mp3

Install mpg321, a command line music player

After installing, just play some music

Some explanation of the switches:

-a bluetooth  : The audio device (the one we just add)

-g xx : The gain (audio volume – You can change it in runtime with / and *)

And your bluetooth speaker should be up and playing. And every time your PI reboots, it shouldn’t have any problem to connect !

I want thank to Jonas Kramer for it’s excellent walkthrough about Linux and A2DP that you can find here : LINUX, BLUEZ, A2DP, ALSA

Another thanks to linuxpixie for the changes to bluetooth audio. You can find them here: How to: Bluetooth Speakers without Pulseaudio

15 Replies to “Raspberry PI Bluetooth Wireless Speaker

  1. Great tutorial!

    It’s works for me but when i want to put that in a python script like that :

    —–
    #!/usr/bin/python

    import os

    os.system(‘mpg321 -a bluetooth -g 15 mymusic.mp3’)
    —–

    it’s doesn’t work…

    Have you any idea?

    Without the ‘-a bluetooth’ option, it’s work with the hdmi sound of my screen.

    Thank’s in advance 😉

    Math

    1. Hi Math !
      Thank you for the comment.

      Yes, I had the same problem… Python doesn’t work well with the bluetooth audio system.
      I cannot remember the specifics, but I know is something to do with pygame. But, in your case, using the os.system I cannot say what it could be…. In another tutorial, I’m playing with hoover and build a rudimentary player. At first I was trying to use python (with pygame) and output the sound to the bluetooth speaker, but no success… I had to give up and use the jack output…

      Sorry I can’t help you !

  2. Hello, I have make all you said, when i boot my headset said bluetooth connected, but, when i play files in mpg321 i have no sounds. what hapenned?

    And, it is possible to play on bluetooth with other program (VLC, CMUS, etc..)?

    Best regards

    1. Hello Etienne.

      Is it possible that you have the audio output through bluetooth muted or with almost no sound ?

      Have you tried to run the mixer and check the audio levels ?

      With other programs, i guess it could be done, as long you can change (in the programs) the audio output to the bluetooth speaker. I haven’t tried, but if you try, please say something !

  3. Can you tell which bluetooth dongle worked with your pi ? I tried the

    Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

    dongle and got exceptions when connecting with bluez-test-audio-

    1. Hi Rainer !

      In the beginning of the post, I wrote that I’ve tried with two dongles – An Edimax EB-DGC2 (this one worked) and a Conceptronic CBT2NANO v2 – This one didn’t worked..

  4. Nice Tutorial, thanks!
    Works very fine!
    But I want to stream audio to my car radio, which doesn’t support A2DP!
    I can connect to the car’s bluetooth handsfree, but the raspberry doesn’t stream the audio.
    Is it possible to simulate a call, so that my car can receive the audio?

    Best regards!

    1. Hello Sven.
      Thank you.
      I really don’t know how would the RPi simulate a phone call to your car.Even if possible… Need to do some googling !
      Best regards

    1. Hi Joe !

      Probably – it is a software thing, not hardware. But never tried on Jessie ! Do it and share your findings !

  5. Hello I seem to be having a problem with the authentication. when I run bluez-simple-agent hci0 it just says authentication rejected does anyone have a solution to this

  6. Hello! bluez-alsa is not available in jessie, so this is not an option anymore. I am trying to set this up on my retropie. Do you have an idea of what I could do?

Leave a Reply to felleg Cancel reply

Your email address will not be published. Required fields are marked *