1 year ago

Play audio on a Bluetooth speaker with Raspberry Pi 3

Make use of the Raspberry Pi 3’s brand new Bluetooth capabilities to play audio and/or music over a wireless speaker, without using a dongle!

An oft-requested feature, Bluetooth support on the Raspberry Pi 3 board – along with its wireless LAN capability – has been pretty well received in the Pi and maker communities at large. How can you use it, though?

In this tutorial, we’ll cover the basics of how to get your Bluetooth up and running on the Pi 3, and how to connect to a Bluetooth speaker so you can play all your smooth Sonic Pi tunes that you’ve been learning from Sam Aaron’s tutorials.

STEP-01 Set up the Raspberry Pi

While Bluetooth is on the Raspberry Pi 3, you need to install a few bits of software to make sure it works properly. It’s best to start by making sure your version of Raspbian Jessie (this won’t work on Wheezy) is up to date. Open the terminal and begin with:

Follow this up by installing the Raspberry Pi Bluetooth software and the excellent Blueman Bluetooth manager:

You may need to reboot after this, but you’ll probably be fine to carry on to the next step.

STEP-02 Set up your Bluetooth speaker

Make sure your Bluetooth speaker is all charged up and ready to go, then switch it on. Ours has a satisfying beep once you do so. If there’s a syncing button or sequence for it to start searching to pair with devices, press it/do it and head back to the Raspberry Pi. If you want to check whether the speaker is actually looking, you could always find out if a mobile phone or tablet is able to see it. Don’t pair with it, though, as that might cause problems in the future.

STEP-03 Connect the speaker up

Open up Blueman by going to the program menu, Preferences, and Bluetooth Manager. As long as the speaker is still trying to sync, clicking Search should make it show up in the interface. Right-click on it, then hit Pair. It should connect to the device, shown by a few information bars on the connection strength – if it then suddenly disconnects straight afterwards, you may need to right-click on it again and hit Connect. Test it out by playing a video on YouTube; it may work straight away like this!

STEP-04 More setup

Depending on how your Pi is set up, the Bluetooth audio might not work at step 3. If this is the case, it’s best to install some extra software to try to get it working. Open up the terminal again and install PulseAudio and its Bluetooth module:

If you open the PulseAudio panel now, it may not show much information, especially whether or not you can switch to the Bluetooth speaker. You’ll more than likely need to reboot the Raspberry Pi – do that now!

STEP-05 Connecting with PulseAudio

After the Raspberry Pi has booted back up, check the Volume Control option in the Sound & Video category of the program menu. On output devices, it should list bcm2835 ALSA as the default output. Go and connect or re-pair with the Bluetooth audio device and it should then be picked up as an option in the Volume Control. Try playing a YouTube video again: you may need to mute ALSA and set the Bluetooth device as a fallback, but it should start playing the audio!

STEP-06 Bluetooth uses

There are some quite obvious uses for Bluetooth speaker connections: not all monitors have audio out, so this solves that issue. This means videos, games, and music (especially the kind from Sonic Pi) are now available to you. You could also incorporate it into a project and create an internet radio player for yourself, activated with the touch of a button. It could be used in a scary Halloween decoration that houses multiple screams and whispers. There’s a lot you can do with this new functionality!

Subscribe and never miss an issue

Get a free Pi Zero W with every twelve-month print subscription

Get a a brand new Raspberry Pi Zero W, a case for it, and a selection of adapter cables with a twelve-month print subscription to The MagPi!

  • mfraz74

    Is it possible to do this from the command line only? I have a headless installation which means there’s no point installing blueman.

  • Barry Byford

    You can do the pairing with ‘bluetoothctl’ on the command line.

  • arthoheen

    I tried this (till step 3 with a Mi Bluetooth speaker) a week ago, but was unable to connect it, after pairing the speaker. I’d paste the exact error in a while.

  • arthoheen

    This works perfectly. I’m using a Mi Bluetooth speaker.

  • Supra

    Using RPI3, Jessie(2013-03-18), kernel 4.4 v7+, python 3.4
    How did u get the sound?
    Failed to connected.
    I can see in pulseaudio in order to play on youtube. But I can see signal strength coming thru, but no sound from analog output.
    I appreciate your help.

  • Ken Howells

    I have a Pi 3 with Jessie and a JLab Crasher BT speaker that I use all the time with my Android phone. On the Pi 3 the Crasher gets listed and disappears right away in blueman. In bluetotthctl I was able to spot the Crasher’s MAC address and got it to report that it was paired but connect always fails with a ‘no such file’ message. Blueman did list my Windows 10 machine when it was on. Any ideas?

  • arthoheen

    Try disabling the other (default analog) audio output from Pulse Audio, and then connect Bluetooth.

  • Supra

    Thanks! Its working well.

  • arthoheen

    Try disabling the other (default analog) audio output from Pulse Audio, and then connect Bluetooth.

  • Ken Howells

    I switched to the newest Raspbian release, heralded as having even better Bluetooth support, that was announced a couple of days after this article and my posting. The gui Bluetooth device search still only showed the bt speaker for a few moments but after a couple of tries I was able to click on it and then ‘pair’. The speaker was listed under audio devices by MAC address instead of a name and I was able to get sound out of the speaker.

  • Erman Anıl Ağoğlu

    Hello I am a newbie at rasp.

    Successfully matched by my bt speaker.

    But get the message connection failed – use the audio menu to connect to this device.

    Can not open “pulseaudio volume control” I get the error message: ” fatal error: unable to connect to pulse audio : ok”

    Thanks..

  • Laura Trevail

    I have the same error message.

  • Laura Trevail

    I got it to work by using an older version of noobs (pre the bluetooth update). May be stuff conflicting, I don’t know? It took me a few attempts but it is now connected and working.

  • oclabbao

    I don’t know if this is too late, but I experienced the same issue with rpi3 and latest raspbian jessie.
    Apparently, pulseaudio doesn’t load at boot up. So I first run “pulseaudio –start” in command line, then I was able to pair, connect, and play audio on my bt speaker successfully.

  • Dan

    Did step-01 successfully… hit reboot and the LCD screen went white. Now I can’t get it to boot with or without the LCD screen?

  • Alex

    Hello, i have a philips bt100 and i can’t connect it,when i click connect it says “connection failed:no such file or directory and when i click the pulse audio volume control it says “fatal error unable to connect to pulseaudio:OK”

  • Graham Toal

    I get the exact same errors with the Amazon Echo. What did you do to get working (if you did)? I’ll try steps 4 onwards next and if that doesn’t help, some of the advice from the posters below.

  • Graham Toal

    yes, step 4 was needed and “pulseaudio –start” *as user pi* at startup. It looks like everything is there and paired OK but I don’t get any sound, and the PulseAudio ‘output devices’ tab only lists “analog output” under Port. Should something like ‘bluetooth output’ appear there too?

  • Graham Toal

    Solved. I had accidentally started a copy of PulseAudio as root, as well as as ‘pi’. Killing the root instance and re-pairing now shows the Echo as the only sound device.

  • Graham Toal

    How about setting up the default audio device from the command line? I got all this working eventually, but on the first reboot I had to do it all again manually, which appears to be a bit hit-or-miss as to whether it works every time. Isn’t there a command line procedure that can do it all, every time, reliably? I thought computers were supposed to be deterministic! 🙂

  • Graham Toal

    Although I got this working (for a time, before it broke again), and could play youtube videos or run ‘sonic pi’ and get to the bluetooth Amazon Echo well enough, when I used ‘festival’ for speech (which is why I wanted to use the Echo speakers, to send myself audio alerts), it still went to the headphone jack loudspeaker. Do I need to do something with jackd as well? (Or are there any festival users here who know how to configure festival specifically, to output to a BT speaker?)

  • Graham Toal

    omxplayer plays on the headphone jack. clicking on an mp3 in the browser plays on the BT speaker; mplayer (after apt-get install mplayer2) give silence and these errors, although it appears to be playing.
    AO: [pulse] Init failed: Connection refused
    AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
    [AO_ALSA] Unable to find simple control ‘Master’,0.

  • Amelia Day

    Hey Graham! I’m working on a home project where I’m trying to make the audio output go to a Bluetooth speaker. I was seeing that you got this to work, and you actually had the same issues as me…I was wondering what you mean by “killing the root instance”. Could you show me a step-by-step? Also, I say be your later comment that you posted that you were having some issues. Did you get it to work again? Thanks!

  • Graham Toal

    use “ps auxww” to see if there is a copy of pulseaudio running that is owned by root, and if there is, “kill -9” the PID of the process. But unless you started one accidentally the same as I did, you probably don’t need to do that. I have it working at the moment, but it’s very unreliable. For instance it was working last night but when I came back this morning the sound was unintelligible – I had to kill the pulseaudio volume control and restart it to fix the sound. Pairing is unreliable, and sometimes it goes silent and I have to unpair/re-pair to get it to work again. I get the impression that BT support is bleeding edge. I haven’t worked out how to get everything reinstated on a reboot and it takes me about 15 minutes to manually reconnect and restart by trial and error. I suspect this is a project to be shelved until BT support is more robust.

  • Alex

    i’ll try to do what you did and reply to see if it worked

  • Alex

    Still not working for me, and now i saw another problem, my card is 16 gb and on the rasp it says there are 8 gb left. on the laptop it says that there are 130 mb left

  • Graham Toal

    On the laptop you’re looking at the windows partition; on the raspi you’re looking at the linux partition. Have you run raspi-config to extend the linux partition to use the available space?

  • Alex

    i think not, how do i even do that?

  • SylvainSeb

    Hi, can you tell me which speaker are you using ? The one on the picture.
    Thanks Sylvain

  • D3r

    Hello,
    I have an issue with playing audio to my bluetooth speaker from the rpi3(pixel). I’m able to connect my bluetooth speaker and it is able to play the audio but randomly stops playing(sometimes plays for upto 1 hour, sometimes stops after 5mins); then the bluetooth module also crashes. This issue happens every time I connect my bluetooth speaker. It is very frustrating and I am not sure how to proceed to find out what is causing this problem.
    I would appreciate some help in resolving this issue.

  • Graham Toal

    I was having an annoying problem with sound stuttering when playing over bluetooth on a Pi3. I found on another forum that the cause is an incompatibility between using BT and Wifi at the same time. By using “ifconfig wlan0 down” before playing a sound over BT, the problem went away entirely. Not that this is a viable solution, but it does confirm the problem.

  • miguel rtp

    Try to go to the bt100 and when in bluetooth mode, press the bluetooth button for 8 seconds. Afer pressing this button if you hear a beep, it means that the bt100 is in discoverable mode. Then try to repair again. It worked for me.

  • Yes! I was having problems setting BT up.
    Its all working now.

  • Dslade47

    Hello,
    Is it possible to do the same with WIFI ? I have Pure Jongo S3 WIFI/BT speaker and and would want to play audio files from my Raspberry Pi 2 to the speaker using WIFI.
    Thanks in advance.

  • Topo

    Hi Graham, did you get this working? Everything from the GUI works fine, but I’m unable, so far, to connect to my Echo from CLI.

  • Graham Toal

    Nope, never did. I’ve just been very careful not to unplug the Pi in the last three months 🙂 (And indeed I just yesterday took receipt of a LifePo4 battery backup addon for the Pi to minimise the downtime and allow me to move it more easily – it’s currently still plugged in to the extension strip where I had been experimenting with it that day in my living room next to the Echo.) I hope I can still remember all the runes that were needed to make it work!

  • Jordan De Sotle

    Fatal Error: Unable to connect to PulseAudio: OK, is what I get when I try to go into the sound and audio menu. My device is on, the bluetooth is running but it wont let me get to the panel in the settings. Also when I try to connect to my device, It says Connection Failed: No such file or directory. Can someone help?

  • BillR

    We had the same issue and we had to run step one again. After we did that we got it to work.

  • Andrew Hitchcock

    Hmm this didn’t work for me.

  • Robbie Joseph William Willett

    Will this work for retropie so I can get better sound playing my emulators and watching kodi

  • Johannes Bakker

    Hello,

    I have rpi 3 and a bluetooth headset.
    I want to get the voice from my bluetooth headset.

    I compiled and installed the PA 6.0.
    And I installed bluez package with 5.23.

    Now I can’t access my bluetooth headset.

    login as: pi
    pi@192.168.1.201‘s password:

    The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.

    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    Last login: Mon Jan 2 12:53:24 2017
    pi@raspberrypi:~ $ pac
    pacat pack200 pacmd pactl
    pi@raspberrypi:~ $ pactl –version
    pactl 6.0-rebootstrapped
    Compiled with libpulse 6.0.0
    Linked with libpulse 5.0.0
    pi@raspberrypi:~ $ sudo dpkg -l bluez
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name Version Architecture Description
    +++-==========================-==================-==================-==========================================================
    ii bluez 5.23-2+rpi2 armhf Bluetooth tools and daemons
    pi@raspberrypi:~ $

  • Sena Agili

    Hello,
    Can someone please help me with a project I am looking to create for my coworkers. Basically, my plan is to create a bluetooth speaker hooked up to a raspberry pi. I want to have the raspberry pi constantly check a static website that will constantly be updated with a number (eg: 1-10) and I want to assign a certain song or sound to play for each number. Any tips on how to go about doing this would be great.

  • computer 2006

    When I open PulseAudio it said: Fatal Eror.
    I’m wondering if you can help me.

  • Avery Mcguire

    Why not just go the easy route and stream your audio through vlc or something?

  • Stefan Giesberg

    I am trying to run the pi3 headless with BT-Speakers. The new Jessie makes it easy to connect via the GUI, but I cannot get it to automatically discover and connect to the bluetooth speakers. How can I configure it so that it only boots into the commandline and automatically scans for the speakers and once those are switched on connects them and uses them for audio-output?

  • Graham Toal

    I don’t think it is possible. The BT linking can be done OK but I haven’t been able to get the audio device in the correct output mode any way except manually (and that, only after repeated attempts). If you succeed, please post.

  • Graham Toal

    one of the problems I must have been having without realising it, until this more recent attempt, was that the bluetooth connection was setting up the Pi as a speaker to the Alexa rather than vice-versa. it became obvious when I also had a wired speaker plugged in to the pi. So you need to find that setting very quickly after making the BT connection and force it to be in the right direction. This is still not sufficient to make the whole process repeatable and reliable however.

  • Martin Shungoh

    first activate pulse audio server from command line pulseaudio – – start

  • computer 2006

    Activate pulse audio with the command pulseaudio –start

  • Alan James

    Using a freshly minted copy of Jessie, I have successfully paired with a couple of bluetooth devices, but when choosing one, it instructs me to ¨use the Audio menu to connect to this device¨. Where can I find that?

  • Erik Jonker

    At the bottom right on the speaker icon, right click it and you will see your paired device, select it as your audio device (on mine by default it is set to hdmi)

  • Alan James

    thank you, I hadn´t tried the right click.

  • Popart 2015

    This is the problem with Linux, the most simple things are just a pain…

  • Mattias Brunschen

    The “right click trick” works fine.
    But when I switch off the BT speaker and switch it on again, the connection is lost, so I have to re-connect (using this right click trick).
    Any ideas how to do this by command line, so that the re-connect would be scriptable?

  • Alain Desjardins

    I followed this on retropie and it rendered my image useless. Now to see if I can figure out how to undo the damage.

  • Ok so I installed the Pixel desktop and with the pulse audio stuff I could connect to my bluetooth speaker.
    But it crashed my system after 5 minutes each time.
    And when I switch back to the RetroPie interface it crashes even quicker, or the speaker disconnects.
    I’ve looked across the web and tried lots of different ways, I don’t think this is an easy one and you’re probably better off using aux for the moment.

  • anonymous

    I attempted these steps and Blue Man gives an error that the directory does not exist at the bottom of the window. Of course, I have no idea what directory it’s looking for. I can say, blue tooth works fine with my blue tooth keyboard. I’ve installed pulse audio, etc. My Audio Options only ever shows the ALSA option; nothing else ever shows up. Sure would like to make this work.

  • Sreenivasan AC

    I was getting some error, and it worked after executing the following command

    pulsestart –start

  • masterkenobi

    Should mentioned earlier this guide is for Raspbian with GUI, not for headless Raspbian.

  • Dex

    See I have a really stupid problem. My bluetooth speaker works on the browser with say youtube videos, but when I run my command line application, the audio is absent. Any suggestions?

  • pi user

    same problem

  • Donald Weston

    I have tried selecting my speakers from the drop-down with a right click, but I still receive this error message:

    GD.Bus.Error:org.bluez.Error.Failed: Resource temporarily unavailable. Please try again.

    I did as I was told, but the error message repeats. What have I done wrong/not doing?

  • Donald Weston

    When I click it from the Devices pop-up (BT GUI, top right of the screen), I get this error:

    Connection Failed: No such file or directory

  • Donald Weston

    Well after one million reboots, setup new device, pair…suddenly it has successfully connected with the speakers, but there is no sound from the speakers. Volume is turned UP!

    Working on it….

  • Donald Weston

    Received signal strength: 50% (optimal)
    Link quality: 100%
    Transmit power: 53% (optimal)

    The orange icon and the rss feed icon in the alternates with a small dark screen

  • Abhay Bhargav

    same problem and pulseaudio doesn’t open at all, says unable to connect