Turn your old speakers or Hi-Fi into Bluetooth receivers with a Raspberry Pi and this step-by-step guide

If you’ve got an old Hi-Fi or sound system with an AUX input, this project is for you. Try balenaSound, a starter project to quickly and easily add Bluetooth to an old Hi-Fi, speakers, or any other audio device using only a Raspberry Pi!


Contents

Before you start

Tutorial

  1. Setup the Raspberry Pi
  2. Deploy the project code
  3. Connect your speakers

Using balenaSound


Before you start

Introduction

A lot of people have older and probably still great, high-quality audio systems that no longer get used, simply because they’re inconvenient. We’ve decided to address that with this very simple project we're calling balenaSound. We will show you how to build your own Bluetooth audio receiver which connects to the auxiliary(AUX) input of any audio device to give it modern streaming functionality. You’ll then be able to stream music to your audio setup from your phone, tablet, or laptop.

All you need is a Raspberry Pi and a little bit of time. We’ve done all the hard work by configuring Bluetooth and setting everything up in a repeatable format to get you up and running with minimal effort. It’s the perfect introduction if you’ve never tried a project like this before.

We’re going to guide you through setting up the Raspberry Pi, deploying the balenaSound project code onto it and then show you how to connect your audio system and get started with streaming. Let’s get to it!


Hardware required

  • Raspberry Pi 3A+/3B/3B+/Zero W
  • An SD Card (we always recommend SanDisk Extreme Pro SD cards)
  • Power supply
  • 3.5mm audio cable to the input on your speakers/Hi-Fi (usually 3.5mm or RCA)
  • An audio system to connect
  • (optional) Digital-analogue-converter(DAC) HAT (e.g. Pimoroni pHAT DAC) for better audio quality

Note: the Raspberry Pi Zero cannot be used on it's own as it has no audio output. To use the Pi Zero you'll need the optional DAC HAT to get the project working.


Software required

  • A download of balenaSound from GitHub
  • Software to flash an SD card (balenaEtcher)
  • A free balenaCloud account to setup and manage the Pi
  • Download and install the balena CLI tools - to be installed on your computer, allowing you to install the project code on the Pi

Tutorial

Setup the Raspberry Pi

Once you’ve found all the hardware and prepared all the software, we’re going to start setting up the Raspberry Pi.

Sign up for a free balenaCloud account

The first thing you’ll need to do is sign up for an account if you haven't done so already. If you’ve already got a GitHub or Google account you can use that to login and bypass the signup process.



Create a balenaCloud application

Add an application selecting the correct device type for the device you’re using, choosing Starter as the application type, then hit Create New Application. Using the starter application will provide you with all of the features of the microservices application and is free up to and including your tenth device.

This will take you to the dashboard for your newly created application, where you can move on to the next step and add your device. The name you give your application is up to you, but you'll need to remember it for later when you push your code.

Add a device and download the balenaOS disk image from the dashboard

Once your application has been created, you can setup and add a device within that application by clicking the green 'add device' button. When you add a device you specify your device type, which is important that it matches the device you’re using, and if you are connecting to a wireless network you can set your WiFI SSID and passphrase here too.

balenaOS 2.38 or higher is required for this project and do not select 64-bit OS

Note: we've used a Raspberry Pi 3 in the image below but be sure to select the correct device type for the device you are using!

This process creates a customized image configured for your application and device type and includes your network settings if you specified them.

Note: When you're first getting started, a development image will be most useful, as it permits a number of testing and troubleshooting features. More details on the differences between development and production images can be found here. If you're confident you can go ahead and deploy the production image straight away.

Flash your SD card with the balenaOS disk image and boot the device

Once the OS image has been downloaded, it’s time to flash your SD card. You can use balenaEtcher for this.

Once the flashing process has completed, insert your SD card into the Raspberry Pi and connect the power supply.

When the device boots for the first time, it connects to the balenaCloud dashboard, after which you’ll be able to see it listed as online and move onto the next step.

Troubleshooting: It should only take a few minutes for the new device to appear in your dashboard, If your device still hasn't shown up on your dashboard after a few minutes, something has gone wrong. There's an extensive troubleshooting guide in the documentation, with lots of information on why this could be, but if you still can't get your device online, come on over to the forums where we’ll be able to help out.


Deploy the project code

Now you’ve got your Raspberry Pi online within the balenaCloud dashboard, it’s time to deploy the project code and turn it into a Bluetooth audio device!

Download the project from GitHub

As we mentioned in the software required section, you’ll need to grab a copy of the balenaSound project from GitHub. You can download the ZIP from GitHub as shown below but if you’re familiar with Git you can use git clone in the normal way.

Important note for Windows users: if you're using Windows the combination of git clone and balena push can cause issues due to line ending changes; we recommend using a combination of either the zip download of the project and balena push or if you'd like to use git clone then also use the git deployment method git push instead of balena push.

Push the project code to your Raspberry Pi

As you’ve installed the balena CLI on your computer, downloaded the balenaSound code from GitHub, and have your Raspberry Pi online in the balenaCloud dashboard, it’s time to push the code and get things running!

From within the unzipped project directory, execute balena push <appName>, where appName is the application name you set earlier in the guide. For example: balena push balenaSound.

If everything worked out correctly, after a few minutes your device information screen in the dashboard should look something like this, showing the service running.

At this point you’re ready to move on, connect things up and give it a try!


Connect your speakers

Most Hi-Fi systems and powered speakers will include an auxiliary (AUX) input for connecting things such as your newly-created balenaSound device. To do this you’ll need to ensure you have the right cables. The audio output on the Raspberry Pi (and the PHAT DAC) is a 3.5mm stereo audio jack, and most AUX inputs are going to be either the same or perhaps more commonly a phono/RCA input, which are the individual red and white connectors. Therefore you’re going to need a cable to work with your setup. The AmazonBasics range is a good place to start looking, the cables are good quality without costing too much.


Using balenaSound

Give it a try

Once you’ve got your Pi powered up and your speakers connected, you’re ready to go! Perform a scan for Bluetooth devices on your phone, tablet or laptop and you should see your balenaSound device ready to connect.

BalenaSound presents itself to your device as a Bluetooth audio receiver, so that once pairing is complete you can now send any audio output from your device to your old speakers!


What next?

So, you’ve got the project running and are jammin’ to your old hi-fi system with a new lease of life! What now? Here are some ideas…

Customize your device name

What’s that? Don’t like the balenaSound xxxx name? We’ve got you covered! Simply add a device environment variable in the balenaCloud dashboard called BLUETOOTH_DEVICE_NAME and your device will reboot with a new name.

Upgrade your audio with a DAC

The Raspberry Pi isn’t known for great audio quality; fortunately this has been addressed with a lot of manufacturers producing DACs for the Raspberry Pi. One I have tested and like for both its small size and low price is the Pimoroni PHAT DAC.

To use this you’ll need to make a couple of changes to the device configuration in the balenaCloud dashboard. The first one is to disable the on-board audio by editing the existing RESIN_HOST_CONFIG_dtparam variable to set ”audio=off”. We then add an additional custom configuration variable called BALENA_HOST_CONFIG_dtoverlay with a value of hifiberry-dac.

This essentially enables the I2S sound interface on the Raspberry Pi GPIO pins, enabling the external DAC to receive and process the audio output.

Try the HDMI out

If you've got an amplifier or receiver that has an HDMI input, you can also use the HDMI output of the Raspberry Pi to transfer a digital audio signal.

Until next time...

Thanks for taking the time to check out our guide, we hope you had success with the project and added Bluetooth to some old speakers or a Hi-Fi. If you had trouble getting the project running or have any other feedback we’d love to hear it; everything helps to improve our projects and tutorials for next time.

You can always find us on the forums at https://forums.balena.io, on Twitter @balena_io, on Instagram @balena_io or on Facebook.

comments powered by Disqus
Terms of Service | Privacy Statement | Master agreement | Copyright 2019 Balena | All Rights Reserved