All wiring guides

Free wiring guides

Wire the MAX98357A I2S amplifier to the ESP32-C3

I2S amplifier MAX98357A with a 4 Ω 3 W speaker. Turns digital sound from the board into a loud speaker.

When buying: The speaker's two wires go to the screw terminal on the amplifier.

Which pin goes where

On the partOn the ESP32-C3
LRCGPIO 6
BCLKGPIO 5
DINGPIO 7
GAINleave unconnected
SDleave unconnected
GNDGND
VIN5V

Wire it with the USB cable unplugged. Follow the names printed on your own part: makers sometimes reorder the pins.

In 3D

Example sketch

// I2S amplifier MAX98357A with a 4 Ω 3 W speaker
// on the ESP32-C3 Super Mini
// https://stem.manusignal.com/en/parts/max98357a-i2s-amplifier-esp32-c3
#include <ESP_I2S.h>

const int PIN_BCLK = 5;
const int PIN_LRC = 6;
const int PIN_DIN = 7;

I2SClass i2s;
const int SAMPLE_RATE = 16000;
int16_t wave[160];

void setup() {
  i2s.setPins(PIN_BCLK, PIN_LRC, PIN_DIN);
  i2s.begin(I2S_MODE_STD, SAMPLE_RATE, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO);
  // One hundredth of a second of a 400 Hz tone, quietly.
  for (int i = 0; i < 160; i++) wave[i] = (int16_t)(sin(2.0 * PI * 400.0 * i / SAMPLE_RATE) * 6000);
}

void loop() {
  for (int i = 0; i < 50; i++) i2s.write((uint8_t*)wave, sizeof(wave));
  delay(500);
}
  • Tools > Board > ESP32C3 Dev Module (USB CDC On Boot: Enabled), then Tools > Port and choose the board's port.

This sketch is compiled for the board before the page is published. It has not been run on real hardware by us.

What you should see

The speaker beeps for half a second, twice a second.

If it does not work

No sound at all.
BCLK and LRC are swapped, or the speaker wires are loose in the terminal.

The same part on the ESP32-S3

More parts on the ESP32-C3