Internet Radio

by TheWheel2 in Circuits > Audio

33 Views, 0 Favorites, 0 Comments

Internet Radio

I love music. I could do without DJs who have nothing to say and somehow manage to say it anyway. So I built an internet radio around an ESP32-S3. A single knob lets me change the volume or switch stations, and I can also control the radio from my browser.

The trickiest part was keeping the music going when a stream hiccups. This project shows how the radio buffers the audio, reconnects when a stream stalls, and can switch to another station if the connection keeps failing.

Supplies

Build an Internet Radio With an ESP32-S3

I love music. I could do without DJs who have nothing to say and somehow manage to say it anyway. With hundreds of stations at your fingertips, internet radio makes it easy to find one that plays more music and does less talking. So I built my own receiver around an ESP32-S3.

Put the Hardware Together

The radio uses a TFT-LCD-Display-EC11 module with an ESP32-S3 Piggyback Board mounted directly behind it. The display shows the station, volume, and track information when the station provides it.


A PCM5102A DAC takes digital audio over I²S and delivers analog stereo to an amplifier or powered speakers.


Make Two Controls Do the Work

Turn the rotary encoder to adjust the volume. Press it briefly to browse and select a station, or hold it down to open the three-band equalizer. The separate push button gives you access to technical information and settings.

The radio also serves a web interface on your local network. You can change the volume or station from your browser, and the front-panel display updates right away. The web interface also lets you add, edit, remove, and export stations. The station list lives in a JSON file in LittleFS. The last selected station, equalizer settings, and Wi-Fi credentials are stored in NVS.

Turn an Internet Stream Into Sound

The firmware runs networking, playback, and the controls as separate tasks. The network task opens a direct MP3 or AAC stream over HTTP or HTTPS and writes the incoming audio to a ring buffer in PSRAM. The playback task reads from that buffer, decodes the audio to PCM, applies the equalizer and volume, and sends it to the DAC. Track information is extracted before decoding, and a WebSocket connection keeps the browser and radio display in sync.

Keep Playing When a Station Stalls

The buffer buys the radio time when data arrives unevenly. I disabled Wi-Fi power saving and adjusted the TCP settings to help it refill after a brief delay. If the first connection attempt fails, the radio retries. If a playing stream stalls and the buffer stays empty for about five seconds, the radio reconnects to the same station and waits for the buffer to refill before resuming.


If the trouble persists, the radio checks its Wi-Fi connection and restarts the stream. After four failed recovery attempts, it looks for another station whose sortField starts with the same letter. That lets you group stations so the radio has a suitable fallback.

Install It and Tune In

Build and flash the firmware and LittleFS image with ESP-IDF, or use my web flasher with a compatible browser and a USB data cable. On first boot, the radio creates a temporary Wi-Fi network so you can enter your own network details. Later firmware updates can be installed over the air on your local network.

Want to see how the pieces fit together? The full article includes the hardware, firmware, and audio-path diagrams, screenshots of the controls and web interface, an example station list, and a closer look at what happens when a stream stalls. Read the full build on my website.