DIY Bluetooth to Aux

My car isn’t the newest (2014 Vauxhall Corsa D) and lacks Bluetooth connectivity. A common solution to this is to have a Bluetooth to aux device. These can easily connect to the cigarette lighter or USB of a car and provide Bluetooth functionality.

I tried a few popular options from Amazon but they all had their caveats. They all have something just off about them. I’ve had one always start at 50% volume so when you switch to the radio your ears get blasted, another would only start when you held the power button, regardlss of if it received power from the USB cigarette lighter or not.

At this point I decided I wanted to make my own, maybe I’m too picky on the functionality I want. Maybe these issues are non-issues… but I work in the Embedded Automotive field so, I decided I wanted my own solution.

The Hardware

My microcontroller of choice here is the ESP-32. It has a built-in Bluetooth chip capable of BLE and Classic Bluetooth. The ESP-32 is an upgraded version of the popular ESP8266 that I’ve used for countless other projects. The specs are roughly the same, but the part I was most interested in was the now included Bluetooth chip.

For audio output, I needed a DAC (Digital to Audio converter). Once the audio signal was received over Bluetooth it needed to be converted to analogue, hence the DAC. The ESP-32 features a built-in DAC, but it’s only 8 bit (compared to the usual 16 bit) so we’d lose a lot of quality there. Instead, I opted for the PCM5102 chip. With this we can push our data over I2C and have it outputted via an Aux port, saving me the trouble of adding this in.

The Software

For implementing audio data over Bluetooth, we need to look at the Bluetooth Specifically, specifically Bluetooth profiles. These profiles are standard protocols that define how we talk over Bluetooth and what data we pass. The one of importance to this project is A2DP (Advanced Audio Distribution Profile).

Espressif provides an example for A2DP which we can use as a template to build our functionality with. The example provides the ability to connect and pass data out to a DAC via I2S.

I built on this to give the following functionality.

  • Automatically connect to the last connected device (saved in NVM)
  • The Bluetooth device name is my car’s registration plate
  • Volume control for iOS has been fixed
  • Additional bass boost because the output seemed a bit flat

Source code for the project is here.

This got me pretty much to the same functionality that existing market bluetooth to aux adapters provided. I wanted more than that though, I wanted to integrate with my steering wheel controls.