[GUIDE] Volumio Bluetooth broadcaster (REQUIRES PULSEAUDIO)

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 broadcaster (REQUIRES PULSEAUDIO)

Postby micx » Tue Jul 24 2018 20:54


I just successfully made Volumio play music simultaneously on my wired speaker, and wirelessly on a Bluetooth speaker! ;)

NOTICE: I'm using Volumio with PulseAudio. This modification is covered by my earlier topic: volumio2-rpi-zero-with-phatbeat-dac-and-pulseaudio-t8493.html , however it is hardware-specific. Following guide will not work for default ALSA sound manager!

So here is a quick guide, I hope I will not skip any step I performed on my way. I would be more than glad if anyone could try that guide, and let me know if anything is missing!

1. Install necessary packets from APT repository:
Code: Select all
apt-get install bluez bluez-tools bluez-firmware pi-bluetooth blueman pulseaudio-module-bluetooth

2. Download latest BlueZ sources, prepare dependencies, unpack, change directory:
Code: Select all
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
apt-get install libdbus-1-3 libc6 libusb-dev libdbus-1-dev libglib2.0-dev libudev1 libudev-dev libical-dev libreadline-dev libsbc1
tar xvf bluez-5.50.tar.xz
cd  bluez-5.50

3. Apply patch for hciattach from there: https://gist.github.com/pelwell/c8230c48ea24698527cd
4. Build and install latest BlueZ - it will overwrite the old BlueZ from APT repository, which is good!:
Code: Select all
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-deprecated
sudo make install

5. Give your user ('volumio' in my case) rights for using bluetoothctl without root rights. To do that, append code below into /etc/dbus-1/system.d/bluetooth.conf next to similiar existing entry:
Code: Select all
<policy user="volumio">
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.MediaEndpoint1"/>
    <allow send_interface="org.bluez.MediaPlayer1"/>
    <allow send_interface="org.bluez.Profile1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.bluez.LEAdvertisement1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>

6. Create /etc/bluetooth/main.conf file and write to it:
Code: Select all
Class = 0x20041C


7. Make sure your /lib/systemd/system/hciuart.service looks like below, or create it (triple exec might not be required with patch above, I patched it only partly):
Code: Select all
Description=Configure Bluetooth Modems connected by UART

ExecStartPre=-/usr/bin/hciattach /dev/ttyAMA0 bcm43xx 921600 noflow
ExecStart=-/usr/bin/hciattach /dev/ttyAMA0 bcm43xx 921600 noflow
ExecStopPost=-/usr/bin/hciattach /dev/ttyAMA0 bcm43xx 921600 noflow


8. Make sure your /lib/systemd/system/bluetooth.service looks like below, or create it:
Code: Select all
Description=Bluetooth service



9. Enable both services:
Code: Select all
systemctl enable hciuart
systemctl enable bluetooth

10. Add following UDev rules:
Code: Select all
# Set bluetooth power up
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", RUN+="/bin/hciconfig %k up"

Code: Select all
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci0:[0-9]*", RUN+="/usr/local/bin/on-bt-speaker-connect"

11. Create /usr/local/bin/on-bt-speaker-connect file with following content, but replace slaves attribute content with names of your PulseAudio sinks (get them using command: pactl list:
Code: Select all
sleep 5
pacmd load-module module-combine-sink sink_name=combined slaves=alsa_output.pivumeter,bluez_sink.30_21_92_11_2D_AA
pacmd set-default-sink combined

12. Add execution rights to it:
Code: Select all
sudo chmod +x /usr/local/bin/on-bt-speaker-connect

13. Reboot
Code: Select all

14. Run bluetoothctl, start scanning, find your device address, pair it and trust it:
Code: Select all
volumio@volumio:~$ bluetoothctl
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller 43:43:A1:12:1F:AC Discovering: yes
[NEW] Device 30:21:92:11:2D:AA BTS-06
[bluetooth]# pair 30:21:92:11:2D:AA
[bluetooth]# trust 30:21:92:11:2D:AA
[bluetooth]# connect 30:21:92:11:2D:AA
[bluetooth]# quit

15. Reboot, and voila! 8-)

Now, whenever you turn on your BT speaker, the script will be called that will change sinks in PulseAudio, and enable simulatanous output to your wired speaker and BT speaker! If you disconnect, it will continue to play on the wired speaker. Volume setting in Volumio affects only the wired speaker, for BT speaker you set in on the speaker. There is a delay between both, so it's not suitable for boosting the sound within the same room. I've personally used it for waterproof speaker under the shower! :)

If you face any issues on the way with this guide, and you are not giving up easily, always go through output of:
Code: Select all
sudo journalctl

It helped me a 100 times! Grepping by 'blue' or 'pulseaudio' is helpful as well ;)

Good luck, and enjoy!!! :mrgreen:
User avatar
Fresh off the boat
Fresh off the boat
Posts: 6
Joined: Sat Dec 30 2017 12:57

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

[GUIDE] Volumio Bluetooth broadcaster (REQUIRES PULSEAUDIO)

Postby speedturtle » Mon Mar 23 2020 15:03

is this guide workable on x86 version of Volumio?
If not, how to make it?
User avatar
Fresh off the boat
Fresh off the boat
Posts: 8
Joined: Tue Jan 15 2019 07:22

Return to Guides

Who is online

Users browsing this forum: No registered users and 1 guest