We have a receiver in our living room that is almost exactly 50 years old. The Sony STR-V5 has a lot of oomph, is wired with wire-wrap connections like earlier space technology and will certainly work for another 50 years. The only problem was that its cinch inputs are no longer compatible with current devices that transmit wirelessly. This gave rise to the idea of building a slightly better Bluetooth receiver for the Sony with a matching retro look. The end result can already be seen here.
Bluetooth-Audio
Before this project, I had no idea about bluetooth. In my mind, it sounded pretty easy to transfer the audio and then play it back. Unfortunately, it’s not quite like that. Due to the limited data rate of a Bluetooth wireless connection, the data must be compressed. A “codec” does this. Of course, it has to be the same on the sending and receiving side. The oldest and currently the most widely used codecs are “AAC” and “SBC”. Audiophile users were not satisfied with the quality of this compression, so a number of new standards are trying to enter the market. In addition to “SBC” and “AAC”, “aptX”, “aptX HD” and “LDAC” are now also competing for the customer’s favor. Don’t forget: sender and receiver must support the same codec. For example, if you buy Bluetooth headphones with “aptX”, but the receiver speaks “LDAC”, only a connection with “SBC” is established, if it works at all.
Overall, the Bluetooth standard is quite complex and my interest in delving further into it is limited. The software uses “SBC”, which is supported by almost all devices.
Volume control
While programming, I noticed that the volume control with Bluetooth is the crux of the matter. The basic problem is that the audio samples are transmitted with 16 bits and usually 100% volume. In the receiver, the volume is now reduced to say 35%. That means we have to divide the audio samples roughly by 16. As a result, we have audio data with a resolution of only 12 bits. And that’s exactly how it sounds.
A simple solution to the problem is a 32 bit D/A converter. The received 16 bit samples are converted into 32 bit values by simply adding zeros. It doesn’t make a difference at first. In the second step, however, we can calculate the volume with the 32-bit value and then send it directly to the D/A converter. As a result, there is no loss of information at low volume, the 16-bit information is retained.
I recently wrote an article about the secrets of a pleasant volume control.
Components
The heart of the circuit is an ESP32 microcontroller from Espressif. The system not only offers plenty of computing power for 3.50 euros, but is also energy-saving. There are a lot of code examples from the manufacturer and lively discussions in forums, which make application development and troubleshooting easier.
A PCM5102A from Texas Instruments with 32 bit and 112dB signal-to-noise ratio is used as a high-quality D/A converter. It’s actually way too good for Bluetooth audio, but the advantages of 32-bit pay off when it comes to volume control.
The whole is complemented by two buttons for volume and reset, a 128×64 pixel OLED display and a breadboard. For this project, I use ready-made modules that only need to be connected to each other. This is of course much faster than drafting your own circuit board.
Circuit
Since I used finished modules for the project, the circuit is limited to a few connections between the central ESP32 module and the OLED display, the D/A converter and the two buttons. The whole thing is soldered together in an hour.
The circuit diagram is available here as a pdf.
Case
I built a small housing from glued plywood scraps, which has become very chic and goes well with the Sony receiver for my taste.
Software
The software is derived from the example “A2DP-SINK” from the ESP32 manufacturer Espressif. That shortened the development time a lot for me, as the complete and rather complex Bluetooth communication is already implemented in the example. I added processing of the audio samples for volume control and the conversion from 16 to 32 bits as described above. I also added the routines for the OLED display. The operating status, the connected device and a logarithmic level display are shown on the display.
In the end, the programming and troubleshooting took a lot longer than a weekend, as a lot of bugs had to be found and fixed.
I have published the full source code, the instruction manual and guidance for compiling the project on Github.
https://github.com/uhucrew/bt-receiver-pcm5102a