Overview
The MAX98357A is a digital audio amplifier. It takes I2S audio, the digital audio bus found on many microcontrollers and single-board computers, converts it to analog and drives a speaker directly, all in one chip. There is no separate DAC, no analog wiring and no hum-prone signal path: three signal wires go in and a speaker comes out. It is a mono Class D amplifier that delivers up to about 3 W into a 4 ohm speaker from a 5 V supply.
This pre-soldered module has a 7-pin header (LRC, BCLK, DIN, GAIN, SD, GND and VIN) and a screw terminal for the speaker. It runs from 2.5 to 5.5 V and accepts 3.3 V or 5 V logic. The gain is 9 dB by default and can be changed with the GAIN pin. The SD pin shuts the amplifier down or selects the channel, and by default the board plays a mix of the left and right channels.
It works with any board that has an I2S output: the ESP32, Raspberry Pi, Raspberry Pi Pico and I2S-capable Arduinos such as the Nano 33 IoT and MKR boards. The Arduino Uno and classic Nano have no I2S port and cannot drive it. This manual covers the pinout, wiring, test-tone code for each platform, and answers on gain, channel selection, speakers and noise.
At a Glance
Specifications
| Parameter | Value |
| Amplifier IC | MAX98357A, mono Class D with built-in DAC |
| Audio input | I2S: LRC (word clock), BCLK (bit clock), DIN (data). No MCLK needed. |
| Sample rates | 8 to 96 kHz |
| Output power | About 3 W into 4 ohm or 1.8 W into 8 ohm at 5 V (10% THD) |
| Supply voltage | 2.5 – 5.5 V |
| Logic level | 3.3 V or 5 V |
| Gain | 9 dB default · 3, 6, 12 or 15 dB with the GAIN pin |
| Channel | (L+R)/2 mix by default · left or right with the SD pin |
| Shutdown | SD pin to GND |
| Speaker | 4 to 8 ohm on the screw terminal (bridge-tied output) |
| Board size | About 19 × 18 mm |
Pinout Diagram
With the screw terminal at the top and the header at the bottom, the pins read left to right: LRC, BCLK, DIN, GAIN, SD, GND and VIN. LRC, BCLK and DIN are the three I2S signals. GAIN and SD are optional setting pins and can stay unconnected. VIN takes 2.5 to 5.5 V. The speaker goes on the screw terminal, which is marked - and +. The amplifier drives both speaker wires, so never connect either of them to ground.
Wiring Guide
The amplifier needs power, ground and the three I2S signals. Screw the speaker into the terminal first. Power VIN from 5 V where you can: the amplifier is louder there, and its current does not load your board's 3.3 V regulator.
Arduino Wiring (Nano 33 IoT, MKR, Zero)
The Arduino Uno and classic Nano have no I2S port, so they cannot drive this amplifier. The SAMD21 boards below can, using the I2S library that comes with their board package.
| Amp Pin | Nano 33 IoT | MKR | Zero |
|---|---|---|---|
| VIN | 3.3V | 5V | 5V |
| GND | GND | GND | GND |
| LRC | A2 | 3 | 0 |
| BCLK | A3 | 2 | 1 |
| DIN | 4 | A6 | 9 |
ESP32 Wiring
| Amp Pin | ESP32 Pin | Notes |
|---|---|---|
| VIN | 5V or VIN | Power |
| GND | GND | Ground |
| BCLK | GPIO 26 | Bit clock |
| LRC | GPIO 25 | Word clock |
| DIN | GPIO 22 | Audio data |
Raspberry Pi Wiring
| Amp Pin | Raspberry Pi Pin | Notes |
|---|---|---|
| VIN | 5V (Pin 2) | Power |
| GND | GND (Pin 6) | Ground |
| BCLK | GPIO 18 (Pin 12) | Bit clock |
| LRC | GPIO 19 (Pin 35) | Word clock |
| DIN | GPIO 21 (Pin 40) | Audio data |
Raspberry Pi Pico Wiring
| Amp Pin | Pico Pin | Notes |
|---|---|---|
| VIN | VBUS (Pin 40) | USB 5 V |
| GND | GND (Pin 38) | Ground |
| BCLK | GP16 (Pin 21) | Bit clock |
| LRC | GP17 (Pin 22) | Word clock |
| DIN | GP18 (Pin 24) | Audio data |
Code Examples
View or download this product's example code on GitHub.
Each example plays a steady test tone of about 440 Hz, enough to confirm the wiring before you move on to real audio. The volume values are deliberately low. Raise them once you hear the tone.
Arduino Nano 33 IoT, MKR and Zero — Test Tone
// MAX98357 I2S amplifier - 440 Hz test tone from an I2S-capable Arduino
// For SAMD21 boards (Nano 33 IoT, MKR family, Zero). The Uno and classic Nano have no I2S.
// Wiring: LRC = A2 (Nano 33 IoT), 3 (MKR) or 0 (Zero)
// BCLK = A3 (Nano 33 IoT), 2 (MKR) or 1 (Zero)
// DIN = 4 (Nano 33 IoT), A6 (MKR) or 9 (Zero)
// VIN = 3.3V or 5V, GND = GND
#include <I2S.h>
const int sampleRate = 8000; // samples per second
const int frequency = 440; // tone pitch in Hz
const int amplitude = 2000; // volume, up to 32767
const int halfWave = sampleRate / frequency / 2; // samples per half wave
short sample = amplitude;
int count = 0;
void setup() {
Serial.begin(115200);
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) {
Serial.println("Failed to start I2S");
while (true) { delay(1000); }
}
}
void loop() {
if (count % halfWave == 0) {
sample = -sample; // flip the square wave
}
I2S.write(sample); // left channel
I2S.write(sample); // right channel
count++;
}
ESP32 — Sine Test Tone
// MAX98357 I2S amplifier - 440 Hz sine test tone from an ESP32
// Needs the ESP32 board package 3.0 or newer, which provides ESP_I2S.h
// Wiring: VIN = 5V, GND = GND, BCLK = GPIO 26, LRC = GPIO 25, DIN = GPIO 22
#include <ESP_I2S.h>
const int PIN_BCLK = 26;
const int PIN_LRC = 25;
const int PIN_DIN = 22;
const int sampleRate = 44100; // samples per second
const float frequency = 440.0; // tone pitch in Hz
const int amplitude = 4000; // volume, up to 32767
I2SClass i2s;
int16_t samples[512]; // 256 stereo frames: left, right, left, right ...
float phase = 0.0;
void setup() {
Serial.begin(115200);
i2s.setPins(PIN_BCLK, PIN_LRC, PIN_DIN);
if (!i2s.begin(I2S_MODE_STD, sampleRate, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO)) {
Serial.println("Failed to start I2S");
while (true) { delay(1000); }
}
}
void loop() {
const float step = 2.0 * PI * frequency / sampleRate;
for (int i = 0; i < 256; i++) {
int16_t value = (int16_t)(amplitude * sin(phase));
samples[2 * i] = value; // left channel
samples[2 * i + 1] = value; // right channel
phase += step;
if (phase >= 2.0 * PI) phase -= 2.0 * PI;
}
i2s.write((uint8_t *)samples, sizeof(samples)); // waits until the samples are queued
}
Raspberry Pi — Python Test Tone
#!/usr/bin/env python3
# MAX98357 I2S amplifier on Raspberry Pi - create a test tone and play it
# One-time setup in /boot/firmware/config.txt: put a # in front of dtparam=audio=on,
# add the line dtoverlay=max98357a, then reboot.
# Wiring: VIN = 5V (pin 2), GND = pin 6, BCLK = GPIO 18 (pin 12),
# LRC = GPIO 19 (pin 35), DIN = GPIO 21 (pin 40)
import math
import struct
import subprocess
import wave
RATE = 44100 # samples per second
FREQ = 440.0 # tone pitch in Hz
SECONDS = 2
VOLUME = 0.2 # 0.0 to 1.0
frames = bytearray()
for n in range(RATE * SECONDS):
value = int(32767 * VOLUME * math.sin(2 * math.pi * FREQ * n / RATE))
frames += struct.pack("<hh", value, value) # left and right sample
with wave.open("tone.wav", "wb") as wav:
wav.setnchannels(2) # the Pi's I2S output expects stereo
wav.setsampwidth(2) # 16-bit samples
wav.setframerate(RATE)
wav.writeframes(bytes(frames))
subprocess.run(["aplay", "tone.wav"], check=True)
Raspberry Pi Pico — MicroPython Test Tone
# MAX98357 I2S amplifier on Raspberry Pi Pico (MicroPython) - 441 Hz sine test tone
# Wiring: VIN = VBUS (5 V), GND = GND, BCLK = GP16, LRC = GP17, DIN = GP18
from machine import I2S, Pin
import math
import struct
RATE = 22050 # samples per second
FREQ = 441 # tone pitch in Hz (exactly 50 samples per wave at this rate)
VOLUME = 0.2 # 0.0 to 1.0
# On the Pico the LRC (ws) pin must be the GPIO right after the BCLK (sck) pin
audio = I2S(0, sck=Pin(16), ws=Pin(17), sd=Pin(18),
mode=I2S.TX, bits=16, format=I2S.MONO, rate=RATE, ibuf=4000)
samples_per_wave = RATE // FREQ
wave = bytearray(samples_per_wave * 2)
for n in range(samples_per_wave):
value = int(32767 * VOLUME * math.sin(2 * math.pi * n / samples_per_wave))
struct.pack_into("<h", wave, n * 2, value)
try:
while True:
audio.write(wave) # waits until the samples are queued
except KeyboardInterrupt:
audio.deinit()