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.

sudo apt-get install bluetooth bluez-utils bluez-alsa

Add your user to the bluetooth group

sudo gpasswd -a pi bluetooth #replace pi with your user

After installing the packages, reboot your PI.

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

sudo hciconfig hci0 up

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

hcitool scan
Scanning ...
      <hadware_id> CLLSPKPCARG

After scanning and found, connect to it

bluez-simple-agent hci0 <hadware_id>

Output from the above command

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

RequestPinCode (/org/bluez/2211/hci0/dev_<hadware_id>)
Enter PIN Code: <pin_code>
New device (/org/bluez/2211/hci0/dev_<hadware_id>)

Now, test the audio

bluez-test-audio connect <hardware_id>

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

bluez-test-device trusted 00:11:22:33:44:55

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

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

bluez-test-device trusted 00:11:22:33:44:55 yes

Check again

bluez-test-device trusted 00:11:22:33:44:55

The result should be 1

Now, let’s configure the new sound card

Create a file .asoundrc in your home folder

vi ~/.asoundrc

Paste the following contents:

pcm.bluetooth {
      type bluetooth
      device <hardware_id>

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

vi /etc/bluetooth/audio.conf

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


Save and exit. Restart the bluetooth service

sudo /etc/init.d/bluetooth restart

Now, let’s try and play some mp3

Install mpg321, a command line music player

sudo apt-get install mpg321

After installing, just play some music

mpg321 -a bluetooth -g 15 02 Magic.mp3

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