Use bluetooth audio on Raspberry PI

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Use bluetooth audio on Raspberry PI

Post by pvm »

I created a wiki page on bluetooth audio on raspberry pi.
This currently shows how to play an mp3 file using bluetooth

I hope to extend this with information on domoticz integration and on making domoticz talk using google translate (hope some of you can help)
http://domoticz.com/wiki/BTAudio
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by ThinkPad »

I am not active on this forum anymore.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

Yes, i posted a link in that topic, the topic you mention is about pimusicbox, requiring an extra pi
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by Heisenberg »

Thnx pvm!
I followed the wiki and was wondering if it's possible to play a radio stream of mp3 file.
I tried the following url stream but it doesn't work:

Code: Select all

pi@domoticzpi ~ $ mplayer -ao alsa:device=bluetooth http://vtuner.com/setupapp/guide/asp/func/dynampls.asp?link=1&id=25743 -softvol -volume 10 -af resample=22100:0:0
[1] 3412
-bash: -softvol: command not found
edit: the url stream wasn't correct. I tried another stream and it works! :)
But how to execute and stop the stream when using a (virtual) switch within domoticz?
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

I updated the wiki with:
edit the mplayer configuration file to prevent loading lyrics (which is not needed and reports errors on my machine sudo nano /etc/mplayer/mplayer.conf and add (top top)
nolirc=yes
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

Heisenberg wrote: edit: the url stream wasn't correct. I tried another stream and it works! :)
But how to execute and stop the stream when using a (virtual) switch within domoticz?
You can create a script with the command to play audio and execute that from within domoticz (did not try yet). You will need the .asoundrc file in your /root directory
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

Updated the part on google translate to let domoticz speak
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by marigo »

How do you keep the bluetooth device connected (paired) to the raspberry or Domoticz.

When the bluetooth speaker is idle I hear: "the bluetooth device is ready to pair". If I run a script with a sound file within, then it pairs again, but then you hear: "the bluetooth device is connected".

Does someone have a solution for this issue?
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

I can only share my results...:
My speaker sounds 'pingpong' to identify it is connected and after the speech it waits 20 seconds and disconnects with a 'pongping' sound. It does however reconnect the next time and the next and ...
Sounds like your device is bahaving the same but the speech identifying it is connected is disturbing.... I do not now wether it is possible to keep it connected al the time....
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
marigo
Posts: 30
Joined: Sunday 31 May 2015 11:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands, Veenendaal
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by marigo »

Yes, I have the same behavior. It does work, but every time you have to trigger it. I have small mp3 files to inform about events within Domoticz, but when the device every time have to pair again, I can't hear the mp3 files.

Well, I think it is possible to stay paired, but I didn't found it yet. :) If I find it I'll will post it here.

Thank you for your WiKi

EDIT: I found this setup in ~/.asoundrc to direct all sound through the bluetooth device. (It's not to stay paired, but I think it's handy)

Code: Select all

## Redirect all sound via Bluetooth
pcm.!default {
        type bluetooth
        device 6E:C9:E9:88:DE:6C # change this MAC address to your speakers address
        profile "auto"
}
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

When this works correctly it sounds like a good update to the u are allowed to update / improve things :)
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by Derik »

mmm
Is there a option to play a internet radio stream?

And active this with a script/button...
Button 1 radio 3
Button 2 Qmusic
etc
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

Yes, specify the url you want to play in a script (start player in background with &), start that from the on script for the switch.
Create an off script to kill the media player
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Heisenberg
Posts: 135
Joined: Monday 27 January 2014 14:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by Heisenberg »

I created a musicplay.sh script to play a stream. This works fine.

Code: Select all


#!/bin/sh
mplayer -ao alsa:device=bluetooth http://stream1.slowradio.com -softvol -volume 5 -af resample=22100:0:0
However I can't stop this with musicstop.sh. Any suggestions?

Code: Select all

#!/bin/sh
mplayer -slave -quiet

Last edited by Heisenberg on Monday 21 September 2015 9:32, edited 1 time in total.
Raspberry Pi Type B
Raspberry Pi Type B2
RFXCOMtrx433e
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

The stop script should kill the shmplayer. ('man kill' for instructions)
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by deennoo »

Why don't you try to stream full ALSA sound ? (Microphone too, this way, no connections interupt)
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
pluggin
Posts: 45
Joined: Tuesday 26 May 2015 22:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Argentina
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pluggin »

When play mp3 files loose/cut the last part of the file only usign bluetooth speakers other way play fine. Any clues?
Razberry + 4 Eversrping HSM02 + 2 Aeotec Multi-Sensor + 1 Aeotec Micro Dimmer + 4 Aeotec Micro Smart Energy Switch, 2nd + 1 Remotec ZXT-120 + 1 Aeotec Smart Energy Monitor + 1 Everspring SE812 indoor Siren + 2 fibaro motion sensor + Aeotec water sensor
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by Derik »

Is there a option to play/switch to a internet stream?
Activate 1 dummy, to play mp3
A other dummy switch. To play a internet stream..

And is it possible to adjust the volume?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

pluggin wrote:When play mp3 files loose/cut the last part of the file only usign bluetooth speakers other way play fine. Any clues?
I guess this is done by your Bluetooth device, if you play an silent (or other not silent) not directly after it, what happens then?
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Use bluetooth audio on Raspberry PI

Post by pvm »

Derik wrote:Is there a option to play/switch to a internet stream?
Activate 1 dummy, to play mp3
A other dummy switch. To play a internet stream..

And is it possible to adjust the volume?
See post 14 a few above this one
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest