Make use of the Raspberry Pi's Bluetooth capabilities to play audio and/or music over a wireless speaker, without using a dongle!
Bluetooth is a wireless technology standard, and it has been a feature on the Raspberry Pi since the Raspberry Pi 3 and Pi Zero W. You can use it to connect Bluetooth keyboards, mice, and other accessories: like speakers and headphones.
The new Raspberry Pi 3B+ even moves from Bluetooth 4.1 to 4.2, which brings faster and more reliable over-the-air data transmission.
In this tutorial we’ll take a look at hooking up a Raspberry Pi to a Bluetooth speaker. This enables you to play music wirelessly from your Raspberry Pi, turning it into an effective media centre.
You should be able to follow this Bluetooth audio tutorial with any Bluetooth-enabled Raspberry Pi.
And Bluetooth can easily be added to an older Raspberry Pi using a dongle, like this Nano USB to Bluetooth Dongle V2.0.
First, you’ll need some music files. You can stream audio online from a source such as YouTube, and many people have MP3 and other audio files. We downloaded Sampler EP Vol. 9 by Vulpiano Records Artists from Free Music Archive for this tutorial. Save the file to your Music folder. Use File Manager to locate the zip file, then right-click it and choose Extract Here.
It is possible to play the music files directly from Terminal using omxplayer. Open a Terminal window and enter omxplayer followed by the path to the music file, like this:
But it’s not a great visual option. We’d rather double-click MP3 files in the File Manager using the Desktop interface. For this we need a media player, and we’re going to use a popular one called VLC. Enter these commands in Terminal:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y vlc
During the installation you’ll be asked if you want to allow metadata network access. This is used to add cover artwork and track listings to your files. Tick or untick the box and click Continue.
Double-clicking the MP3 files in File Manager will open VLC and play the file.
OK, so we’ve got our music and a music player. Now it’s time to connect the Raspberry Pi to a Bluetooth speaker.
To do this you’ll need to put the speaker in pairing mode and pair the Raspberry Pi to the speaker. How you do this depends on the speaker itself. If your speaker has an interface, you’ll probably use the controls to put it into pairing mode. Many smaller speakers or headphones have a button that you hold down to put the device into pairing mode (typically you’ll see a flashing light).
A pop-up will display ‘Connecting to Bluetooth audio device’. Now double-click on of the music files in Files Manager. The VLC app will open and your music will start playing through the Bluetooth speaker.
When you restart the Raspberry Pi, you will need to reconnect to the Bluetooth speaker (this isn’t the same as pairing – it is still paired). Click on the Bluetooth icon, choose your speaker, and select Connect from the menu.
You can use the Bluetooth menu to disconnect, if you don’t want to use a device for the time-being. Or remove it entirely if you don’t want to use it again.
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!