ESP32Cube Logo
Sign In
How to Play Internet Radio Stations with ESP32

How to Play Internet Radio Stations with ESP32

esp32cube
May 16, 2026
Tutorial
1384 views

This post provides a step-by-step guide of play Internet radio on an ESP32-S3.

AIWiFiAudio

Introduction

In this tutorial, we will be using an ESP32-S3 to play internet radio stations. First, we need connect the ESP32-S3 to the internet using a WiFi module. Then, we will use the audio library to stream the radio station's audio to the ESP32-S3.

Step 1: Connect the ESP32-S3 to the internet

In order to make things simple, we will configure the Wifi ID and password in code.

#include "Arduino.h"
#include <WiFi.h>

String ssid =     "*****";
String password = "*****";

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

  WiFi.begin(ssid.c_str(), password.c_str());
  while (WiFi.status()!= WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  // put your main code here, to run repeatedly:
}

Step 2: Install the audio library

The audio library is a powerful library that allows us to stream audio data to the ESP32-S3. We will use this library to stream the radio station's audio to the ESP32-S3.

To install the audio library, we need to add it to the platformio.ini file.

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = audio

Step 3: Stream the radio station's audio to the ESP32-S3

Now, we will use the audio library to stream the radio station's audio to the ESP32-S3.

#include "Arduino.h"
#include <WiFi.h>
#include <audio.h>

#define I2S_DOUT            9
#define I2S_BCLK            3
#define I2S_LRC             1

String ssid =     "*****";
String password = "*****";

Audio audio;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status()!= WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");

  audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
  audio.setVolume(64);

// radio station's audio stream URL
    audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
}

void loop() {
    audio.loop();
    vTaskDelay(1);
}

In the setup() function, we initialize the audio library and set the output and input devices to AUTO. Then, we start the radio station's audio stream using the audio_stream_start() function.

In the loop() function, we start the radio station's audio stream using the audio_stream_start() function and then stop it after 10 seconds using the audio_stream_stop() function.

Conclusion

In this tutorial, we have learned how to use the audio library to stream internet radio stations to the ESP32-S3. We have also learned how to connect the ESP32-S3 to the internet using a WiFi module.

Share this article

Comments

0

Please sign in to post a comment.

No comments yet.

Related Articles

ESP32 Arduino Button Input: Practical Guide and Debouncing

Tutorial·172 views

ESP32 + WS2812B LED Strip + 18650 Battery: Rechargeable RGB Lighting Device

Tutorial·244 views

ESP32 LED Chaser (Running Light) Experiment

Tutorial·121 views

Control GPIO Output: Light Up an LED on ESP32

Tutorial·107 views

ESP32Cube Development Guide

Tutorial·135 views
View more in this category→
Copyright © 2026 ESP32Cube. All rights reserved.•1.0.1•Terms·Privacy
Source codeTwitterDiscord