[GUIDE] Volumio Bluetooth receiver

Guides to let you easily discover and enjoy Volumio

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.

[GUIDE] Volumio Bluetooth receiver

Postby KKMan » Sat Feb 10 2018 01:15

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:
Code: Select all
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: Select all
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



Compile Bluez-Alsa
Code: Select all
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

Code: Select all
sudo nano /etc/bluetooth/audio.conf

add
Code: Select all
[General]
Class = 0x20041C
Enable = Source,Sink,Media,Socket



Update file /etc/bluetooth/main.conf

Code: Select all
sudo nano /etc/bluetooth/main.conf

add
Code: Select all
[General]
Class = 0x20041C


Automate BluezAlsa:
Set BlueAlsa as a service
Create file /lib/systemd/system/bluealsa.service
Code: Select all
sudo nano /lib/systemd/system/bluealsa.service

Add
Code: Select all
[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:
Code: Select all
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.

Code: Select all
sudo nano /lib/systemd/system/bluealsa-aplay@.service

Add
Code: Select all
[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
Code: Select all
sudo nano /etc/udev/rules.d/99-input.rules

Add
Code: Select all
KERNEL=="input[0-9]*", RUN+="/home/volumio/a2dp-autoconnect"


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

Code: Select all
nano /home/volumio/a2dp-autoconnect

Add
Code: Select all
#!/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


Set the right access permissions:
Code: Select all
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: Select all
sudo bluetoothctl
# power on
# agent on
# default-agent
# scan on => xx:xx of your device
# pair xx:xx
# trust xx:xx
# exit


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:

Code: Select all
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
Random avatar
KKMan
Sunday DIYer
Sunday DIYer
 
Posts: 32
Joined: Tue Jan 02 2018 16:48

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.


[GUIDE] Volumio Bluetooth receiver

Postby shaunmlowry » Sun Feb 18 2018 19:18

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: Select all
#!/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



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.
Random avatar
shaunmlowry
Fresh off the boat
Fresh off the boat
 
Posts: 1
Joined: Sun Feb 18 2018 19:10


[GUIDE] Volumio Bluetooth receiver

Postby swanduron » Wed Feb 21 2018 06:40

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?
User avatar
swanduron
Fresh off the boat
Fresh off the boat
 
Posts: 3
Joined: Tue Jun 06 2017 10:26


[GUIDE] Volumio Bluetooth receiver

Postby DEEF » Fri Feb 23 2018 15:09

Any chance we will see a BT plugin in a near future?
Random avatar
DEEF
Fresh off the boat
Fresh off the boat
 
Posts: 1
Joined: Fri Feb 23 2018 15:08


[GUIDE] Volumio Bluetooth receiver

Postby KKMan » Fri Feb 23 2018 20:24

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.
Random avatar
KKMan
Sunday DIYer
Sunday DIYer
 
Posts: 32
Joined: Tue Jan 02 2018 16:48


[GUIDE] Volumio Bluetooth receiver

Postby mcgerman » Wed Feb 28 2018 14:30

KKMan wrote: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.


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:
Code: Select all
aplay -l


In my case the device is "hw5:0".

volumio@volumio:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 5: Alpha [Sound Blaster Tactic(3D) Alpha], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0


Maybe this helps if someone has no Audio Output.
User avatar
mcgerman
Fresh off the boat
Fresh off the boat
 
Posts: 3
Joined: Wed Feb 28 2018 14:08


[GUIDE] Volumio Bluetooth receiver

Postby Vctr » Mon Mar 12 2018 14:39

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
Random avatar
Vctr
Fresh off the boat
Fresh off the boat
 
Posts: 7
Joined: Thu Feb 22 2018 14:43


[GUIDE] Volumio Bluetooth receiver

Postby Vctr » Mon Mar 12 2018 14:55

Vctr wrote: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
Random avatar
Vctr
Fresh off the boat
Fresh off the boat
 
Posts: 7
Joined: Thu Feb 22 2018 14:43


[GUIDE] Volumio Bluetooth receiver

Postby Baptou_88 » Mon Mar 12 2018 19:21

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
Random avatar
Baptou_88
Fresh off the boat
Fresh off the boat
 
Posts: 1
Joined: Mon Mar 12 2018 19:13


[GUIDE] Volumio Bluetooth receiver

Postby Vctr » Mon Mar 12 2018 20:01

Vctr wrote: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



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.

volumio@volumio:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndallodigione [snd_allo_digione], device 0: Allo DigiOne HiFi wm8804-spdif-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0



Shouldn't the same "-dhw:1,0" work for me just like in the tutorial? Or am I just confused?
Random avatar
Vctr
Fresh off the boat
Fresh off the boat
 
Posts: 7
Joined: Thu Feb 22 2018 14:43

Next

Return to Guides

Who is online

Users browsing this forum: No registered users and 0 guests