When I moved to my new place in the beautiful canton of Valais – I did not re-activate my old Turntable and Amplifier and just left them in a corder.

Today I decided to reactivate my devices again but to my disappointment I could hear only some scratching sounds form my loudspeakers when I turned the different controls.

I took my Technics SU-Z2 amplifier apart, cleaned it from the dust and applied plenty of Contact Spray to the dials and switches and I am very happy: it’s working again!

SU-Z2

My old Amplifier is cool, but I also wanted to have some modern functionality as well like
– Streaming Music from the Internet
– Streaming over Bluetooth from my Mobile Phone

DAC Hardware

The ESP32 is a cheap choice to build a simple Music Player because it supports Bluetooth and WIFI out of the box together with I2S communication. So I ordered a Pcm5102 Dac Decoder I2S Player Assembled Board from China.

I did not want to wait for the DAC device to arrive and fortunately we can also use the built in DAC of the ESP32 to generate the sound.

Web Radio Software

If you have a ESP32-LyraT board available you can use the esp-adf framework which provides an impressive set of functionality.

The easiest way to get a working solution if you have a regular ESP32 is to use one of the following projects
https://github.com/karawin/Ka-Radio32
https://github.com/Edzelf/ESP32-Radio
https://github.com/MrBuddyCasino/ESP32_MP3_Decoder

Ka-Radio32

To keep things simple, I decided to install the Ka-Radio32 because it already comes with the binaries and does not need any build.
So I just downloaded the binaries and flashed them with

git cline https://github.com/karawin/Ka-Radio32.git

cd Ka-Radio32/binaries

esptool.py \
–chip esp32 –port /dev/cu.SLAB_USBtoUART –baud 460800 –before default_reset \
–after hard_reset write_flash -u –flash_mode dio \
–flash_freq 40m –flash_size detect \
0x1000 bootloader.bin \
0x10000 KaRadio32.bin \
0x8000 partitions.bin

 

Then I Connected my MacBook to the new SSID WifiKaRadio to perform your initial configuration which was available on http:// 192.168.4.1.

The cool thing is that you can configure the application via the Web GUI to use the internal DAC from the ESP32. I added a Streaming URL: e.g. http://23.92.61.218:9002/ und connected the DAC pins G26/G27 and GND with the AUX input of my Amplifier w/o additional hardware.

I confirm that this is working together with my Technics SU-Z2!

Building my Own Solution

Now it was time to write some code for my own solution which should provide the following functionality:
– Compatible with Arduino IDE
– Internet Radio Streaming
– Streaming via Bluetooth

I decided to use the following Audio library which makes the solution very easy:

Here is an example Sketch which streams a MP3 from a radio URL using the interal DAC of the ESP32:

#include <arduino.h>
#include “AudioFileSourceICYStream.h”
#include “AudioGeneratorMP3.h”
#include “AudioOutputI2SNoDAC.h”</arduino.h>

// Enter your WiFi setup here:
const char *SSID = “mySSID”;
const char *PASSWORD = “pwd”;

// Randomly picked URL
const char *URL = “http://strm112.1.fm/blues_mobile_mp3”;

AudioGenerator *audio;
AudioFileSourceHTTPStream *file;
AudioOutputI2S *out;

void setup() {
Serial.begin(115200);
delay(1000);

WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PASSWORD);

// Try to connect to Wifi forever
while (WiFi.status() != WL_CONNECTED) {
Serial.println(“…Connecting to WiFi”);
delay(1000);
}
Serial.println(“Connected”);

audioLogger = &Serial;
file = new AudioFileSourceICYStream(URL);
file->SetReconnect(5, 0);
out = new AudioOutputI2S(0, 1); // (0,1) is using the internal DAC
audio = new AudioGeneratorMP3();
audio->begin(file, out);
}

void loop() {
if (audio->isRunning()) {
audio->loop();
}
}

 

This was pretty simple!.

Im my next blog I will show how to stream bluetooth e.g. from a Mobile Phone to the ESP32 using the Arduino IDE…


0 Comments

Leave a Reply

Your email address will not be published.