Pivek
Posts: 3
Joined: Fri Apr 17, 2020 5:44 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Fri Apr 17, 2020 5:50 pm

DrFunk,

thank you for this wonderful tutorial. I have already created bluetooth speaker using your post.
Here is my contribution: https://github.com/Pivek/bluetooth-sound-events

This fork of another script will allow you to expand bluetooth speaker with two more functionalities:
  • It will play sound on boot, when Pulseaudio will be started and Bluetooth daemon will be capable for handling A2DP connection
  • It will play sound on every successful connect/disconnect action to Raspberry Pi Bluetooth device immediately after adding/removing Interface for A2DP connection. D-Bus is used for monitoring these events
I hope my little contribution will be helpful :)

alfeuchtwa
Posts: 1
Joined: Sat Apr 18, 2020 3:09 am

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Sat Apr 18, 2020 3:18 am

Hi, I'm having a hard time following which is a note and which is a command to enter. For example after I run bluetoothctl the next line is
[NEW] Controller XX:XX:XX:XX:XX:XX raspberrypi [default] I'm assuming that the [NEW] is a note but not sure about [default]. Either way nothing works once you are in [bluetooth]#

Any tips would be helpful. Thank you

pi@raspberrypi:~ $ bluetoothctl
[NEW] Controller XX:XX:XX:XX:XX:XX raspberrypi [default]
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# agent on

Pivek
Posts: 3
Joined: Fri Apr 17, 2020 5:44 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Sat Apr 18, 2020 1:10 pm

Are you familiar with shell scripting and prompts? "#" or "$" is a prompt after which you enter commands. Everything else is an output from commands and services.

penfold00
Posts: 3
Joined: Mon May 04, 2020 9:52 am

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Mon May 04, 2020 10:33 am

_Audio Stuttering / Bluetooth-WiFi conflict?_

Hey,

thank you for the clear and simple Tutorial! I followed it up to the end of step 2 so far, so I'm being able to test the functionality. I can connect my device(s) and play audio via the Pi's output.

I'm getting a nice stereo sound, but the audio stutters irregularly. It clearly feels like a problem conerning the bluetooth transmission.
I'm even surprised nobody here brought this up so far, since stuttering audio seems to be a broad problem people get using the RPi as a bluetooth sink.
It seems, that for most people, the problem is that Bluetooth and Wifi usage conflict and cause disturbance. This problem is well documented on the RPi3 and I guess the RPi Zero W that Wifi and Bluetooth. See, for example, here: https://github.com/raspberrypi/linux/issues/1402

Obviously, I thought this might be the deal for me as well - so I deactivated Wifi temporarily using "sudo ifconfig wlan0 down" and reconnect to my bluetooth device to test again. Unfortunately disabling WiFi did not help and now I'm confused what to try next.
I will try an external bluetooth dongle, but I'd actually like to use the onboard chip, since I don't intend to use wifi + bluetooth at the same time (although I want to use them both, just not simultaneously) - thus I think it should be possible without a dongle.

But now, I can't find any hint, what to try, since disabling WiFi seems to do the trick for almost everyone, so I don't find other proposals.
Do you have any other idea, how I can proceed (using onboard Bluetooth), or how I can further test the issue?
Also, do you think using BlueALSA instead of Pulseaudio might change anything?



I'm using the Raspberry Pi 3 Model B Rev 1.2, running the latest Raspbian Buster lite.
Thanks for your help!

penfold00
Posts: 3
Joined: Mon May 04, 2020 9:52 am

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Mon May 04, 2020 1:17 pm

[deleted, double posted, sorry.]
Last edited by penfold00 on Mon May 04, 2020 6:32 pm, edited 1 time in total.

Pivek
Posts: 3
Joined: Fri Apr 17, 2020 5:44 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Mon May 04, 2020 4:25 pm

I had same issues. I had to adjust Pulseaudio settings. There is a link in the main topic for that.

CharlesDeLetang
Posts: 5
Joined: Wed Sep 21, 2016 10:19 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Wed May 06, 2020 11:36 am

Hi ! I think it's some problem with RPI4... Don't work for me with RPI4 and hiffy berry Amp +

It's strange because kodi sound work with Amp + but after install like your tuto i have no sound on raspbian...

penfold00
Posts: 3
Joined: Mon May 04, 2020 9:52 am

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Sun May 17, 2020 12:15 pm

penfold00 wrote:
Mon May 04, 2020 10:33 am
_Audio Stuttering / Bluetooth-WiFi conflict?_
[...]
I'm getting a nice stereo sound, but the audio stutters irregularly. It clearly feels like a problem conerning the bluetooth transmission.
Hey,

I want to update you on my audio stuttering problem and share some troubleshooting info.

First of all - using an external bluetooth dongle works like charm, so that's defenitely a simple solution (see Tutorial above, point 6) .
Anyway, I tried to get it running using the onboard bluetooth since I kind of just wanted it to work.

Here's some stuff you might want to try.
  • Pulseaudio troubleshooting
    Follow the instructions in the link mentioned under point 9 in the tutorial in this thread. There's several things you can try that might work. It's explained quite well. This is the link: https://wiki.archlinux.org/index.php/Pu ... io_quality
    I would start here, since I feel everything else kind of forces you to kill WiFi which many of us do not want to do.
  • Turn off WiFi.
    Using WiFi and Bluetooth at the same time can cause transmission problems, at least in Pi3 and Pi Zero W. If you don't need to use WiFi turn it off. Find more info here: https://github.com/raspberrypi/linux/issues/1402
    An easy way to do so temporarily is "sudo ifconfig wlan0 down" - WiFi will be back up after reboot (or after "sudo ifconfig wlan0 up" if you're still connected).
    If you want to turn it off permanently you'll find information for example here: https://raspberrypi.stackexchange.com/q ... n0-on-pi-3
  • If you've turned off WiFi, you might additionally want to try turning off bluetooth discoverable and scanning in order to disable further unnecessary bluetooth activity.
    To do so temporarily just type "scan off" and "discoverable off" in "bluetoothctl". If this helps, I'm sure you'll find a way to make it permanent.
  • If disabling WiFi didn't help, I found 2 interesting options in the github issue above (#1402):
  • This trick concerning the kernel module brcmfmac seems to have helped quite some people: https://github.com/raspberrypi/linux/is ... -394540405 You might want to read the following comments to understand, what to do and what it does - I don't really get it..., anyway it did improve the quality for me, just not enough.
    (Please also mind that you might have to put the suggested file in /lib/modprobe.d/ and not in /etc/modules.d/ as it is mentioned in some comments after the one linked here.)
  • The next try which is referred to as "NVRAM fix" will not be relevant to most, since it has been implemented in Raspian starting August 2018. Anyway, you'll find information on that here and in the following comments: https://github.com/raspberrypi/linux/is ... -413554448
  • For Raspberry Pi 3B Rev 1.2 (and below I guess) / Reduce baudrate
    This might be of the most importance, because I think you can't surpass this if you are using a Pi 3B Rev 1.2, just as I am. I tried all of the above and while a lot of it did help a bit and decreased stuttering / loss, it just didn't do the trick.
    Eventually I found there is a problem specifically with the 3B Rev 1.2 and a simple workaround by reducing the baudrate, which helped me completely get rid off stuttering.
    You'll find more information and the solution here: https://github.com/balenalabs/balena-so ... -587851502 and here https://github.com/raspberrypi/linux/is ... -344911712
    The fix explained there is to reduce baudrate from 921600 to 460800 in /usr/bin/btuart.
    As I said, this was the only thing that helped me, so I was glad to find that - Although I do not know if it might affect audio quality a bit (I did not really hear a difference right away, but I couldn't test it without rebooting and thus did not have a direct comparison)

I hope that might help some of you and reduce search time, especially for 3B Rev 1.2 users like me.

groff
Posts: 2
Joined: Wed Jun 24, 2020 7:06 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Wed Jun 24, 2020 7:17 pm

Thanks for the tutorial.
How to set playback via I2S (card pcm5102), I use rpi zero W
Any help would be greatly appreciated :)

groff
Posts: 2
Joined: Wed Jun 24, 2020 7:06 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Wed Jun 24, 2020 7:26 pm

Thank you for this wonderful tutorial.
How to set playback via I2S (card pcm5102), I use rpi zero W.
Any help would be greatly appreciated

jkiddo
Posts: 1
Joined: Thu Jul 09, 2020 8:59 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Thu Jul 09, 2020 9:01 pm

This worked like a charm - I had some difficulties as I did this on a Pi model 2 with external BT dongle, but all in all it ended up being great! Thx!

Mika Hawkins
Posts: 7
Joined: Sun Aug 16, 2020 5:10 pm
Location: Australia

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Sat Sep 05, 2020 5:17 pm

Hi,
Thank you positng in Raspberry forums,

I found this guide a very important source for pi beginners but I also have the same issue as CharlesDeLetang getting I am also not getting sound on raspbian. Also I have found some raspberry pi zero projects here, I think you must share something on this too so, that it would be very beneficial for begineers like me.

I hope this was useful...
Regards,
Mika Hawkins

fruitoftheloom
Posts: 24451
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Sat Sep 05, 2020 8:22 pm

Mika Hawkins wrote:
Sat Sep 05, 2020 5:17 pm
Hi,
Thank you positng in Raspberry forums,

I found this guide a very important source for pi beginners but I also have the same issue as CharlesDeLetang getting I am also not getting sound on raspbian. Also I have found some raspberry pi zero projects here, I think you must share something on this too so, that it would be very beneficial for begineers like me.

I hope this was useful...
Regards,
Mika Hawkins

The issue in many cases is PulseAudio is the issue, remove anything relating to PulseAudio and see if sound works again.


History:.When Raspbian Stretch was released PulseAudio was replaced by BlueAlsa, therefore the audio is Alsa based.
There is a known conflict listed on the BlueAlsa developers GitHub.


I personally always check before installing software that PulseAudio dependencies are not a requirement and luckily my BT Speaker just worked in RaspiOS32 & RaspiOS64.
Thinking outside the box is better than burying your head in the sand...

fivanovic
Posts: 1
Joined: Tue Oct 13, 2020 9:21 pm

Re: Another How to turn your Pi in a Bluetooth Speaker Tutorial

Tue Oct 13, 2020 9:45 pm

kozervar wrote:
Mon Feb 17, 2020 9:26 pm
Hi
I've followed steps in this thread and I was successful. Problem was with controling volume by phisical smartphone buttons. I've solved it by editing

Code: Select all

 sudo nano /lib/systemd/system/bluetooth.service
and adding a2dp plugin to ExecStart

Code: Select all

ExecStart=/usr/lib/bluetooth/bluetoothd --plugin=a2dp
after that restart and it should work ;)
Hey, what edits did you make to the bluetooth.service part?

Return to “Media centres”