Skip to content

Circuit-Digest/ESP32-Based-Internet-Radio-using-MAX98357A-I2S-Amplifier-Board

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

ESP32 Based Internet Radio using MAX98357A I2S Amplifier Board

Project Overview

This project demonstrates how to build an ESP32-based Internet Radio that streams audio directly from the internet using Wi-Fi connectivity. The system uses a MAX98357A I2S amplifier board to deliver high-quality digital audio output through speakers, creating a standalone internet radio device.

ESP32 Internet Radio

Features

  • Wi-Fi Connectivity: Streams audio directly from internet radio stations
  • High-Quality Audio: Uses I2S digital audio interface for crystal clear sound
  • Digital Class D Amplifier: MAX98357A provides 92% efficiency and up to 3.2W output power
  • Simple Setup: Minimal components required
  • Expandable: Can be enhanced with display, volume control, and station switching
  • Low Power: ESP32's efficient power management
  • Plug & Play: Automatic connection and streaming

ESP32 Internet Radio Circuit Diagram

Table of Contents

Components Required

Component Quantity Description
ESP32 Development Board 1 Main microcontroller with Wi-Fi
MAX98357A I2S Amplifier 1 Digital Class D amplifier module
8Ω Speaker (0.5W-1W) 1 Audio output device
USB Cable 1 For programming and power
5V 1A Power Adapter 1 External power supply
Jumper Wires Several For connections
Breadboard (Optional) 1 For prototyping

Hardware Setup

MAX98357A I2S Amplifier Specifications

  • Efficiency: 92%
  • Output Power: Up to 3.2W into 4Ω load at 5V
  • Operating Voltage: 2.5V to 5.5V
  • Features: Click/pop noise reduction, short circuit protection, thermal protection
  • Audio Modes: Left, Right, or (Left/2 + Right/2) output

Circuit Diagram

Pin Connections

MAX98357A Pin ESP32 Pin Description
LRC GPIO 26 Left/Right Clock (Word Select)
BCLK GPIO 27 Bit Clock Input
DIN GPIO 25 Digital Data Input
GAIN GND Gain Control (GND = 12dB, VDD = 6dB)
SD - Shutdown (Leave floating for normal operation)
GND GND Ground
VIN 5V Power Supply

Wiring Diagram

ESP32          MAX98357A         Speaker
-----          ---------         -------
GPIO25   ----> DIN
GPIO26   ----> LRC
GPIO27   ----> BCLK
5V       ----> VIN
GND      ----> GND
GND      ----> GAIN
                 +     ---------> Speaker +
                 -     ---------> Speaker -

Software Installation

1. Install Arduino IDE

Download and install the latest version of Arduino IDE from arduino.cc

2. Install ESP32 Board Package

  1. Open Arduino IDE
  2. Go to File > Preferences
  3. Add this URL to "Additional Board Manager URLs":
    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
    
  4. Go to Tools > Board > Board Manager
  5. Search for "ESP32" and install "esp32 by Espressif Systems"

3. Install Required Library

  1. Download the ESP32-audioI2S library from GitHub:
    https://github.com/schreibfaul1/ESP32-audioI2S
    
  2. In Arduino IDE, go to Sketch > Include Library > Add .ZIP Library
  3. Select the downloaded library ZIP file

Code Explanation

Main Libraries Used

#include "Arduino.h"  // Core Arduino functions
#include "WiFi.h"     // Wi-Fi connectivity
#include "Audio.h"    // ESP32-audioI2S library

Pin Definitions

#define I2S_DOUT 25   // Data out pin
#define I2S_BCLK 27   // Bit clock pin  
#define I2S_LRC 26    // Left/Right clock pin

Key Functions

  • WiFi.begin(): Connects ESP32 to Wi-Fi network
  • audio.setPinout(): Configures I2S pins
  • audio.setVolume(): Sets playback volume (0-100)
  • audio.connecttohost(): Connects to streaming URL
  • audio.loop(): Maintains audio streaming in main loop

Configuration

1. Wi-Fi Setup

Replace the following lines in the code with your network credentials:

String ssid = "Your_WiFi_SSID";
String password = "Your_WiFi_Password";

2. Radio Station Setup

Change the streaming URL to your preferred station:

audio.connecttohost("http://your-radio-station-url.com/stream");

Popular Radio Station URLs (Examples):

  • BBC Radio 1: http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p
  • Capital FM: http://vis.media-ice.musicradio.com/CapitalMP3
  • SmoothRadio: http://vis.media-ice.musicradio.com/SmoothUKMP3

3. Volume Control

Adjust the volume level (0-100):

audio.setVolume(75); // Set to 75% volume

Testing

Upload Process

  1. Connect ESP32 to computer via USB
  2. Select correct board: Tools > Board > ESP32 Dev Module
  3. Select correct port: Tools > Port > [Your ESP32 Port]
  4. Click Upload button
  5. Open Serial Monitor (9600 baud) to view connection status

Expected Behavior

  1. ESP32 connects to Wi-Fi (LED indicator may blink)
  2. Serial monitor shows connection status
  3. Audio streaming begins automatically
  4. Clear audio output through speaker

Audio Quality Check

  • Audio should be clear without distortion
  • No clicking or popping sounds during startup
  • Consistent streaming without interruptions

Troubleshooting

Common Issues

Problem Possible Cause Solution
No audio output Wrong pin connections Check I2S pin wiring
Compilation error Missing library Install ESP32-audioI2S library
Wi-Fi connection fails Wrong credentials Verify SSID and password
Audio distortion Power supply issue Use adequate 5V power supply
Streaming stops Internet connectivity Check network stability

Debug Steps

  1. Check Serial Monitor: Look for error messages
  2. Verify Connections: Use multimeter to check continuity
  3. Test Speaker: Connect speaker to another audio source
  4. Power Supply: Ensure stable 5V supply
  5. Library Version: Use latest ESP32-audioI2S library

Future Enhancements

Suggested Improvements

  • OLED Display: Show current station and song info
  • Rotary Encoder: Volume control and station selection
  • Web Interface: Configure stations via browser
  • Multiple Stations: Store and switch between favorites
  • Bluetooth Support: Add Bluetooth audio capability
  • SD Card Support: Play local audio files
  • Touch Interface: Capacitive touch controls
  • Voice Control: Integration with voice assistants

Advanced Features

  • Equalizer: Software-based audio processing
  • Sleep Timer: Auto-shutdown functionality
  • Alarm Clock: Wake up with internet radio
  • Recording: Save streams to SD card
  • Streaming Server: Broadcast your own content

Circuit PCB Design (Optional)

For permanent installation, consider designing a custom PCB with:

  • ESP32 module
  • MAX98357A integration
  • Power regulation circuit
  • Control interfaces
  • Speaker terminal blocks

Power Consumption

  • ESP32: ~240mA (during Wi-Fi streaming)
  • MAX98357A: ~10-500mA (depending on volume)
  • Total System: ~250-750mA at 5V
  • Recommended PSU: 5V 1A minimum

References

License

This project is based on open-source resources and is intended for educational and hobbyist use.

Contributing

Feel free to contribute improvements, bug fixes, or additional features. Create pull requests or open issues for discussion.


Project Status: ✅ Tested and Working
Difficulty Level: Beginner to Intermediate
Estimated Build Time: 2-3 hours
Last Updated: August 2025

Complete Arduino Code

#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"

#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26

Audio audio;

String ssid = "Your_WiFi_SSID";
String password = "Your_WiFi_Password";

void setup() {
    Serial.begin(115200);
    
    WiFi.disconnect();
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid.c_str(), password.c_str());
    
    while (WiFi.status() != WL_CONNECTED) {
        delay(1500);
        Serial.print(".");
    }
    
    Serial.println("WiFi connected");
    
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
    audio.setVolume(100); // 0...100
    audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3");
}

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

Happy Making! 🎵🔊

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages