Bluetooth on Raspberry - Audio streaming
In this post I would like to show how to install a bluetooth dongle to stream music from the Raspberry pi to bluetooth loud speakers. As I didn’t have bluetooth loud speakers I bought a cheap receiver bluetooth in eBay to stream music.
1) Characteristics
Based on the sellers mail this is what this little bluetooth can do. This bluetooth is to be connected to the LOUD SPEAKERS, no to the Raspberry. For the Raspberry you need another bluetooth dongle.
2) Installation
First of all you need to detect if the bluetooth dongle in your Raspberry is properly detected.
In my case I get.
After that you have to install some tools to set up the raspberry
Add the default user “gusa” to the lp group (you will be able to see bluetooth sources and to change some bluetooth settings) :
Change the default bluetooth audio settings :
Add/Complete the following line in the [General] section :
Done it reboot the system.
Make the usb dongle works:
Scan for your bluetooth loud speakers :
Once it is done you will get a mac address or BT ADD or BlueTooth Address of the bt device. Your Bluetooth device will have a different id.
This command will show you your local mac address.
In my case
Next, you will use bluez-simple-agent to pair the device. My device can be paired with the passphrase 0000.
Normally you can use this instead the last line I used:
And then you will be asked:
Now if you want to make the remote device be able to connect back to you without user authorization:
Check if id is already trusted:
The result will be 0 for not trusted and 1 for trusted. Now connect with alsa adding to YOUR user:
This content :
3) Streaming music
Restart the bluetooth service to start streaming music:
3.1) Mplayer
Finally just install for example Mplayer and play like : You have to select audio output as Alsa device with the bluetooth you set up before. You have to resample the music to avoid fulling the buffer.
3.2) CMUS
CMUS is a music player for the terminal.
In order to set up the Raspberry to run the audio using the alsa bluetooth device set up before open CMUS, press 7 and change this parameters like this.
3.3) MPG321
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 *)