[GUIDE] Volumio Bluetooth receiver

This is a revised version of the original post by phweyland with some minor fixes and latest version of Bluez. You can find the original post here:
volumio-bluez-alsa-a2dp-bluetooth-support-t6130.html

What this can do:
Allow Raspberry Pi to receive Bluetooth audio (from phone) and play though your DAC.
What this can’t do:
Output audio to Bluetooth Speakers.

Limitations:
No pairing interface, you will need to pair manually.
You will need to disconnect your phone’s Bluetooth->Volumio connection yourself if you want to play from other sources after.

You can skip the latest Bluez version if you want but I found it is more stable to use.
I have tested this on Rpi 3, Rpi Zero W and Rpi 1 model B with CSR8510 dongle.
I recommend you use SSH from a computer it will make this very much a copy and paste exercise.

Login as volumio with your password you should be in /home/volumio

Install dependencies:

sudo apt-get update sudo apt-get install dh-autoreconf libasound2-dev libortp-dev pi-bluetooth sudo apt-get install libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc-dev

Compile Bluez 5.48: (The make process will take around 25min, just so you know)

[code]git clone git://git.kernel.org/pub/scm/bluetooth/bluez.git
cd bluez
git checkout 5.48
./bootstrap
./configure --enable-library --enable-experimental --enable-tools
make
sudo make install

sudo ln -s /usr/local/lib/libbluetooth.so.3.18.16 /usr/lib/arm-linux-gnueabihf/libbluetooth.so
sudo ln -s /usr/local/lib/libbluetooth.so.3.18.16 /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3
sudo ln -s /usr/local/lib/libbluetooth.so.3.18.16 /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.18.16[/code]

Compile Bluez-Alsa

cd git clone https://github.com/Arkq/bluez-alsa.git cd bluez-alsa autoreconf --install mkdir build && cd build ../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib make sudo make install

Configure Bluetooth subsystem:
Create file /etc/bluetooth/audio.conf

sudo nano /etc/bluetooth/audio.conf
add

[General] Class = 0x20041C Enable = Source,Sink,Media,Socket

Update file /etc/bluetooth/main.conf

sudo nano /etc/bluetooth/main.conf
add

[General] Class = 0x20041C

Automate BluezAlsa:
Set BlueAlsa as a service
Create file /lib/systemd/system/bluealsa.service

sudo nano /lib/systemd/system/bluealsa.service
Add

[Unit] Description=BluezAlsa proxy Requires=bluetooth.service After=bluetooth.service [Service] Type=simple User=root Group=audio ExecStart=/usr/bin/bluealsa [Install] WantedBy=multi-user.target

Enable BluezAlsa starts from boot:

sudo systemctl daemon-reload sudo systemctl enable bluealsa.service

Set bluealsa-aplay as a service:
Create file /lib/systemd/system/bluealsa-aplay@.service
hw1:0 is the hifiberry audio device I want to use. There may be better way to link it.

sudo nano /lib/systemd/system/bluealsa-aplay@.service
Add

[Unit] Description=BlueAlsa-Aplay %I -dhw:1,0 Requires=bluetooth.service bluealsa.service [Service] Type=simple User=volumio Group=audio ExecStart=/usr/bin/bluealsa-aplay %I -dhw:1,0 [Install] WantedBy=multi-user.target

Add UDEV rules
Create file /etc/udev/rules.d/99-input.rules

sudo nano /etc/udev/rules.d/99-input.rules
Add

KERNEL=="input[0-9]*", RUN+="/home/volumio/a2dp-autoconnect"

Tell Bluetooth how to create a bluetooth->Alsa connection:
Create file /home/volumio/a2dp-autoconnect

nano /home/volumio/a2dp-autoconnect
Add

[code]#!/bin/bash

at each BT connection/disconnection start/stop the service bluealsa-aplay

function log {
sudo echo “[$(date)]: $*” >> /var/log/a2dp-autoconnect
}
BTMAC=${NAME//"/}

if [ echo $BTMAC | egrep "^([0-9A-F]{2}:){5}[0-9A-F]{2}$" ]
then
if [ $ACTION = “remove” ]
then
log "Stop Played Connection " $BTMAC
sudo systemctl stop bluealsa-aplay@$BTMAC
elif [ $ACTION = “add” ]
then
log "Start Played Connection " $BTMAC
sudo systemctl start bluealsa-aplay@$BTMAC
else
log "Other action " $ACTION
fi
fi[/code]

Set the right access permissions:

sudo chmod a+rwx /home/volumio/a2dp-autoconnect sudo touch /var/log/a2dp-autoconnect sudo chmod a+rw /var/log/a2dp-autoconnect

REBOOT

After reboot, use bluetoothctl to connect to your bluetooth music source:

[code]sudo bluetoothctl

power on

agent on

default-agent

scan on => xx:xx of your device

pair xx:xx

trust xx:xx

exit[/code]

On your mobile, connect volumio. Should work.
Once the device is connected you should be able to play something …

6.Checking
To check if the services are all up and running: $ systemctl | grep blue
You should get something like that:

sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0 sys-subsystem-bluetooth-devices-hci0:11.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0:11 bluealsa-aplay@68:FB:7E:24:25:52.service loaded active running BlueAlsa-Aplay 68:FB:7E:24:25:52 -dhw:1,0 bluealsa.service loaded active running BluezAlsa proxy bluetooth.service loaded active running Bluetooth service system-bluealsa\x2daplay.slice loaded active active system-bluealsa\x2daplay.slice bluetooth.target loaded active active Bluetooth

Great guide! Had this up and running in a couple of hours. One alteration I made for running on a Raspberry Pi Zero W: as the wifi and bluetooth are on the same chip on these boards, you get quite choppy audio when playing back over bluetooth. To solve this, I added a couple of lines to a2dp-autoconnect to take the wifi interface down when a bluetooth connection is made and bring it back up when the connection is dropped. The modified script looks like this:

[code]#!/bin/bash

at each BT connection/disconnection start/stop the service bluealsa-aplay

function log {
sudo echo “[$(date)]: $*” >> /var/log/a2dp-autoconnect
}
BTMAC=${NAME//"/}

if [ echo $BTMAC | egrep "^([0-9A-F]{2}:){5}[0-9A-F]{2}$" ]
then
if [ $ACTION = “remove” ]
then
log "Stop Played Connection " $BTMAC
sudo ifconfig wlan0 up
sudo systemctl stop bluealsa-aplay@$BTMAC
elif [ $ACTION = “add” ]
then
log "Start Played Connection " $BTMAC
sudo ifconfig wlan0 down
sudo systemctl start bluealsa-aplay@$BTMAC
else
log "Other action " $ACTION
fi
fi

[/code]

I figured this would be fine as you can’t play from other sources whilst playing from bluetooth and bingo, no more choppy audio! This might also be useful on other similar devices (Raspberry Pi 3 etc.)

Shaun.

I have a pi3 and installed bluetooth as your steps. The bluetooth seems working fine and I can pairing my iphone and android phone to it, but no audio is output via my DAC. How to trouble shooting in this case?

Any chance we will see a BT plugin in a near future?

I never have done a Volumio Plugin before so I am not sure of the process, or if there are somewhere to host the Bluez-Alsa package. All the info needed to make it work is here so it should be easy enough for someone with plugin experience to make one. However, there will need to be an onscreen pairing interface too.

If you don´t have the HifiBerry DAC “hw1:0” won´t work and you don´t have Audio Output.
You can detect the your device here:

aplay -l

In my case the device is “hw5:0”.

Maybe this helps if someone has no Audio Output.

I managed to make device pair and I see volumio on my tablets bt-device listing, but nothing happens when I click it.

Also:

volumio@volumio:~$ systemctl | grep blue
sys-subsystem-bluetooth-devices-hci0.device
loaded active plugged /sys/subsystem/bluetooth/devices/hci0
● bluealsa.service
loaded failed failed BluezAlsa proxy
bluetooth.service
loaded active running Bluetooth service
bluetooth.target
loaded active active Bluetooth

[bluetooth]# info A0:32:99:BF:5A:51
Device A0:32:99:BF:5A:51 (public)
Name: Lenovo YT3-X50L
Alias: Lenovo YT3-X50L
Class: 0x005a011c
Icon: computer
Paired: yes
Trusted: yes
Blocked: no
Connected: no
LegacyPairing: no
UUID: Dialup Networking (00001103-0000-1000-8000-00805f9b34fb)
UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb)
UUID: OBEX File Transfer (00001106-0000-1000-8000-00805f9b34fb)
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
UUID: PANU (00001115-0000-1000-8000-00805f9b34fb)
UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)
UUID: Handsfree Audio Gateway (0000111f-0000-1000-8000-00805f9b34fb)
UUID: SIM Access (0000112d-0000-1000-8000-00805f9b34fb)
UUID: Phonebook Access Server (0000112f-0000-1000-8000-00805f9b34fb)
UUID: Message Access Server (00001132-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
Modalias: bluetooth:v001Dp1200d1436

Hello Everyone !

I have on my Raspberry pi 3 the latest version of volumio.

I have follow this link https://volumio.org/forum/volumio-bluetooth-receiver-t8937.html and i have succeed after many test

My mobile phone is correctly connect to my Pi3 but no sound comes out of the jack

Can you help me ???

Thanks

Ok, so I managed to solve these problems and now I can connect to the rpi3 with bluetooth. However I don’t get sound. I use the digione spidif hat.

Shouldn’t the same “-dhw:1,0” work for me just like in the tutorial? Or am I just confused?

And I do get sound using LMS and squeezeplayer. When I connect the bluetooth, audio stops on my tablet and I get the bluetooth volume control on the tablet, but still no sound through the rpi.

Any help would be nice.

"loaded failed failed BluezAlsa proxy "
Try recompile and re install BluezAlsa . Make sure you do a “sudo make install” instead of just make install.
Also recheck the configuration files.

Yeah, I already fixed those problems and now I can connect, but no sound :neutral_face:

Hey everyone,

I tried to follow this guide with my rp3 using the HiFiBerry DAC+. I can successfully connect to the pi via bluetooth and i also get Audio Output. But my problem is that after about a minute the music just stops playing and the green led on my HiFiBerry also turns off. The services seem to be still running though. Do you have and ideas how to fix this? :cry:

Hello Guys,

i did the tutorial and the installation going without any problems.

I can connected my device and all seems good.
BUT if i make a test if all services running up (systemctl | grep blue) i don´t get these lines:

bluealsa-aplay@68:FB:7E:24:25:52.service loaded active running BlueAlsa-Aplay 68:FB:7E:24:25:52 -dhw:1,0
system-bluealsa\x2daplay.slice loaded active active system-bluealsa\x2daplay.slice

What should i do to make these services running?

My Problem is that i dont hear anything. Although my Hardware Device is set correctly.

Excuse my bad english.

best regards

Peter K.

Maybe you wrote it with the “$”. Just write “systemctl | grep blue” and it will work.

You can do a “sudo make uninstall” with your Bluez and revert back to the RPi’s original version and see if that helps.

Hey,

thanks for answer.
It was a misunderstanding. I wrote the line without the $. I just copied it with.

best regards.

Peter K.

Just want to say thank you for sharing your work posting this guide.

I copied it to a Pi3 and Pzero with hifiberries and it works just perfect!

Hello,

I had the same problem at first: I was able to connect my smartphone to the volumio device but ‘systemctl | grep blue’ lacked exactly the same lines as you stated.
I completely repeated this tutorial to install the bluetooth streaming adapter with the single difference of choosing bluez checkout 5.49.
I get audio output as well as the lines I was missing.

Be sure to connect to the volumio device remotely through a program like putty and copy/paste the files/file additions directly onto the RPi to avoid using wrong symbols (like in the /home/volumio/a2dp-autoconnect, the line if [ echo $BTMAC | egrep "^([0-9A-F]{2}:){5}[0-9A-F]{2}$" ] seems really susceptible to errors).

kind regards,
Moritz J.