Table of contents
Introduction Understanding Digital Audio Amplification What Is I²S and Why It Matters Features of the MAX98357 Digital Audio Amplifier Wiring the MAX98357 to an ESP32 Selecting Speakers and Audio Formats Featured Project: Ultrasonic Audio Warning Sensor System Components How the Detection Logic Works Troubleshooting and Practical Tips Advanced Applications: IoT Audio DevicesTable of contents
Introduction
Digital sound has quietly become the voice of modern embedded electronics. Smart sensors speak, wearables play alerts, toys respond with personality, and IoT devices deliver surprisingly rich audio from very small hardware. This shift is possible because of a new generation of compact digital amplifiers that make high-quality sound simple to integrate. The MAX98357 is a prime example, accepting an I²S audio stream directly from a microcontroller and producing clean, amplified output with only a handful of supporting components.
Understanding Digital Audio Amplification
Digital audio amplification keeps the signal in digital form until the final conversion stage. The MAX98357 converts and amplifies the audio internally, reducing noise and eliminating the need for external DACs or complex analog circuitry.
Advantages include:
- fewer components
- reduced noise and distortion
- no external DAC required
- consistent output quality
- simple wiring and software control

What Is I²S and Why It Matters
I²S is a dedicated digital audio interface used in smartphones, Bluetooth speakers, and embedded devices. It transports synchronized left and right audio data using three lines:
- BCLK (bit clock)
- LRCLK (left/right clock)
- DIN (audio data)
Microcontrollers such as the ESP32 can stream audio samples directly to the MAX98357, which converts them into an amplified stereo signal.
Features of the MAX98357 Digital Audio Amplifier
The MAX98357A combines a digital-to-analog converter with a high-efficiency Class-D amplifier, allowing a microcontroller to drive a speaker directly from an I²S audio stream. It can deliver about 3 W of output power depending on the supply voltage and speaker load, and it maintains low noise, low distortion, and simple wiring that suits compact embedded audio designs.
Key features:
- Integrated DAC and Class-D amplifier
- One audio channel per chip
- 3.3 V supply operation
- Up to roughly 3.2 W output into 4 Ω at 5 V
- Low quiescent current
- High efficiency
- Low output noise and THD+N
- Supports sample rates from 8 kHz to 96 kHz
- Breadboard-friendly modules with documentation and library support
Wiring the MAX98357 to an ESP32
Only power, ground and three I²S lines are required.
I²S connections:
- ESP32 pin 26 → BCLK
- ESP32 pin 25 → LRCLK
- ESP32 pin 27 → DIN
Power:
- VCC → 5 V or 3.3 V
- GND shared between ESP32 and amplifier
Speakers:
- L+ and L−
- R+ and R−
Selecting Speakers and Audio Formats
Small 0.5 W to 3 W speakers with 4 or 8 ohms impedance are ideal. WAV files should be 16-bit PCM at 44.1 kHz for maximum compatibility with ESP32 audio libraries.
Featured Project: Ultrasonic Audio Warning Sensor

This project demonstrates how to combine a Dasduino CONNECTPLUS, an ultrasonic sensor and a MAX98357 amplifier to create a distance-triggered alert device. The system monitors an object’s position. If it stays within a defined window (40 cm ± 3 cm) for five seconds, the Dasduino CONNECTPLUS plays a WAV file through the amplifier. This method prevents false triggers and ensures alerts activate only when readings are stable.
The complete project source code, including all example files and configuration details, is available on GitHub.
System Components
- Dasduino CONNECTPLUS (ESP32-based)
- MAX98357 stereo I²S amplifier
- 8-ohm speakers
- Ultrasonic distance sensor (easyC / I²C)
- microSD card module with WAV file
How the Detection Logic Works
The sensor provides distance readings every 50 ms. If the reading stays within range continuously for the set duration, playback is triggered.
Logic excerpt:
if (distanceInRange(d, TARGET_DISTANCE, TOLERANCE)) {
if (!gInRangeTiming) {
gRangeStartMs = millis();
gInRangeTiming = true;
} else if (millis() - gRangeStartMs >= HOLD_TIME_MS) {
playOnce();
gInRangeTiming = false;
}
} else {
gInRangeTiming = false;
}
Serial Control and Manual Operation
The firmware includes a serial control interface at 115200 baud:
- p = play once
- l = start loop playback
- s = stop loop
- u = enable detection mode
- z = disable detection
- 0–21 = set volume level
Troubleshooting and Practical Tips
- No audio: verify shared ground, check WAV format, confirm microSD wiring
- Distortion: lower volume, use correct speaker impedance
- Unstable behavior: use a solid 5 V supply
- Detection issues: adjust hold time or tolerance
Advanced Applications: IoT Audio Devices
Once you understand the basics of I2S and can play sounds reliably, the MAX98357 amplifier becomes a gateway to a whole range of advanced IoT projects. With only a few core components such as an ESP32, Wi-Fi connectivity and I2S audio, you can build devices that talk, react, notify or stream live content.
Here are some inspiring ideas:
Smart Home Voice Alerts
Use MQTT messages from your smart home hub and play short speech samples like “Window open”, “Motion detected” or “Temperature too high”.
Wi-Fi Connected Doorbell
Create a doorbell with multiple sounds depending on the time of day, visitor detection or notifications sent to your phone.
IoT Status Speaker
Let your device announce sensor readings, Wi-Fi events, task completion or system warnings using simple audio prompts.
Mini Internet Radio
Make a small streaming radio player where the ESP32 fetches an online audio stream and the MAX98357 outputs clear stereo sound.
Talking Gadgets and Toys
Add sound effects or speech to 3D-printed robots, interactive installations, museum exhibits or educational kits.
The Stereo I2S Audio Amplifier makes all these projects surprisingly simple. There is no complex analog circuitry to worry about. With clean digital audio, straightforward wiring and software-driven control, your IoT devices can easily gain a voice of their own.