MAX98357A I2S 3W Amplifier with an ESP32 DevKit V1

A mono class-D amplifier that takes I2S digital audio straight from an ESP32 or Pico and drives a 4 Ω speaker at up to 3.2 W.

MAX98357A I2S 3W Amplifier, A mono class-D amplifier that takes I2S digital audio straight from an ESP32 or Pico and drives a 4 Ω speaker at up to 3.2 W.
In short

On the ESP32 DevKit V1 the MAX98357A breakout takes its VIN from 3V3, inside the chip's 2.5 to 5.5 V supply range, and the ESP32's 3.3 V signals sit far above the 1.3 V the datasheet sets as a high, so no level shifting is needed. The ESP32 drives BCLK on GPIO26, LRC on GPIO25 and audio data into DIN from GPIO27, the same three pins the sketch hands to i2s_set_pin().

Wiring the MAX98357A I2S 3W Amplifier to the ESP32 DevKit V1

Pin by pin.

MAX98357A I2S 3W AmplifierESP32 DevKit V1
VIN3V3
GNDGND
BCLKGPIO26 (D26)
LRCGPIO25 (D25)
DINGPIO27 (D27)

What to know on the ESP32 DevKit V1

  • On 3V3 the speaker gets well under the headline 3.2 W. The lowest supply the datasheet gives a power figure for is 3.7 V, where an 8 Ω speaker reaches 0.93 W at 10 % THD+N against 1.8 W at 5 V. For more volume, feed the breakout's VIN from a 5 V supply; its inputs still accept the ESP32's 3.3 V signals.MAX98357A datasheet 19-6779 Rev 7, pp. 1, 5, 6
  • The sketch writes 16 bit stereo frames at 44.1 kHz, so BCLK runs at 32 x LRCLK, about 1.41 MHz. The amplifier accepts 32, 48 or 64 bit clocks per frame and only the rates 8, 16, 32, 44.1, 48, 88.2 and 96 kHz; at 22.05 or 24 kHz it stays silent.MAX98357A datasheet 19-6779 Rev 7, pp. 6, 16
  • Both halves of every frame carry the same sample. With SD left open, the breakout's 1 MOhm pullup to VIN selects the (L+R)/2 mix, so the tone plays at the level written; a GPIO that pulls SD to GND shuts the amplifier down.MAX98357A datasheet 19-6779 Rev 7, pp. 7, 17; Adafruit MAX98357 I2S Class-D Mono Amp guide, Pinouts
  • tx_desc_auto_clear = true tells ESP-IDF's legacy I2S driver to send zeros when its DMA buffers run dry, so a loop() that stalls produces silence instead of the last buffer repeating as a buzz.ESP-IDF v4.4.7 components/driver/include/driver/i2s.h (i2s_driver_config_t)

MAX98357A I2S 3W Amplifier code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-30.

No library needed
// MAX98357A I2S 3W Amplifier on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/max98357a-i2s-amp/esp32
#include <driver/i2s.h>
#include <math.h>
static int16_t sine[256];
void setup() {
  for (int i = 0; i < 256; i++) sine[i] = (int16_t) (8000 * sin(2 * PI * i / 256.0));
  i2s_config_t cfg = {};
  cfg.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX);
  cfg.sample_rate = 44100;
  cfg.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
  cfg.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
  cfg.communication_format = I2S_COMM_FORMAT_STAND_I2S;
  cfg.dma_buf_count = 8;
  cfg.dma_buf_len = 256;
  cfg.tx_desc_auto_clear = true;
  i2s_driver_install(I2S_NUM_0, &cfg, 0, NULL);
  i2s_pin_config_t pins = {};
  pins.mck_io_num = I2S_PIN_NO_CHANGE;
  pins.bck_io_num = 26;  // GPIO26 -> BCLK
  pins.ws_io_num = 25;   // GPIO25 -> LRC
  pins.data_out_num = 27; // GPIO27 -> DIN
  pins.data_in_num = I2S_PIN_NO_CHANGE;
  i2s_set_pin(I2S_NUM_0, &pins);
}
void loop() {   // a 440 Hz tone, from the table
  static uint32_t phase = 0;
  static int16_t frame[256 * 2];
  const uint32_t step = (uint32_t) (440.0 * 4294967296.0 / 44100);
  for (int i = 0; i < 256; i++) { int16_t s = sine[phase >> 24]; frame[2 * i] = s; frame[2 * i + 1] = s; phase += step; }
  size_t written;
  i2s_write(I2S_NUM_0, frame, sizeof(frame), &written, portMAX_DELAY);
}

MAX98357A I2S 3W Amplifier on the ESP32 DevKit V1: questions

Can I run the MAX98357A from 5 V with an ESP32?

Yes. The datasheet specifies its 1.3 V input high level with the chip on 5 V (p. 6), so BCLK, LRC and DIN still read the ESP32's 3.3 V highs with VIN on a 5 V supply. Adafruit suggests a supply good for at least 800 mA at 5 V, since a speaker can pull up to 650 mA.

Why is the speaker silent with the ESP32?

Check that the speaker sits only across the breakout's two output screws, that SD is not tied to GND, and that the sample rate is one the chip supports (p. 16). Then confirm the pins in i2s_set_pin() match the wiring: BCLK 26, LRC 25, DIN 27.

Can one ESP32 drive two MAX98357A boards for stereo?

Yes. Run BCLK, LRC and DIN to both boards and set one to the left channel and the other to the right through SD_MODE (datasheet, p. 17), then write different samples into the two halves of each frame.

For AI assistants

This guide as plain Markdown. /components/max98357a-i2s-amp/esp32.md

What will you build with it?