Documentation

PAM8406 Stereo Class-D Audio Amplifier Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual
Documentation / PAM8406 Stereo Class-D Audio Amplifier Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual

PAM8406 Stereo Class-D Audio Amplifier Module for Arduino, Raspberry Pi & ESP32 | ShillehTek Product Manual

shillehtek

Overview

The PAM8406 is a tiny stereo Class-D audio amplifier that turns a 5V rail and a line-level signal into real speaker volume: 5W + 5W into 4-ohm speakers, or about 3W + 3W into 8-ohm. Class-D means the output transistors switch rather than dissipate — efficiency runs around 90%, so there's no heatsink, almost no heat, and it runs happily from USB power banks and single-cell boost circuits.

This CJMCU-style breakout brings out everything on clearly labeled pads: stereo inputs (INL/INR with GND between), stereo bridged outputs (+L/-L and +R/-R), and 5V power — with a hefty 1000uF reservoir capacitor onboard to steady the supply during bass hits. Feed it from a phone's headphone jack, an ESP32 DAC pin, a Pi's audio output, or a filtered PWM pin on any microcontroller.

It's the go-to amp for project speakers, talking gadgets, arcade cabinets, intercoms, and audio-reactive builds. One rule matters above all: the outputs are bridge-tied (BTL) — each speaker terminal is actively driven — so speaker minus pins must never touch ground or each other. Wire each speaker only across its own +/- pair and the amp will run cool for years.

At a Glance

Amplifier
PAM8406, Class-D stereo
Output Power
5W + 5W @ 4 ohm / 5V
Supply Voltage
2.5V - 5.5V
Efficiency
~90% (no heatsink)
Outputs
Bridged (BTL) — no ground!
Speakers
4 - 8 ohm

Specifications

Parameter Value
Amplifier IC PAM8406 filterless Class-D stereo
Supply Voltage 2.5V - 5.5V DC (5V nominal)
Output Power 5W/ch @ 4 ohm, 3W/ch @ 8 ohm (5V, 10% THD)
Output Topology Bridge-tied load (BTL) — outputs must float
Efficiency Up to ~90%
THD+N ~0.1% at 1W typical
Input Stereo line level (INL / INR), ~10k input impedance
Quiescent Current ~10-20 mA (no signal)
Peak Current Up to ~2 A on loud bass — size the supply accordingly
Onboard Reservoir 1000 uF / 16V electrolytic
Pads +R -R -L +L | INR GND INL | GND VCC

Pinout Diagram

Left edge: the four speaker pads — +R/-R for the right speaker, -L/+L for the left. Right edge, top group: the audio input — INR, GND, INL — which maps directly onto a 3.5mm stereo plug (tip = left, ring = right, sleeve = GND). Right edge, bottom group: GND and VCC for the 5V supply. The big can capacitor between them is the onboard reservoir.

PAM8406 stereo class-D amplifier module pinout diagram showing speaker outputs, audio inputs and 5V power connections

Wiring Guide

Arduino Wiring (filtered PWM tones)

The Uno has no DAC, so tone() output is tamed with a simple RC filter before the amp input.

Connection Details
D9 → 1k resistor → INL PWM/tone output into left input
INL → 100nF cap → GND RC low-pass (~1.6 kHz corner)
Input GND → Arduino GND Shared signal ground
VCC / GND 5V / GND (USB is fine for beeps)
Left speaker → +L and -L 4-8 ohm, across the pair only
Warning: Never connect -L or -R to GND — the outputs are bridged and grounding one destroys the amp. Each speaker touches exactly two pads: its own + and -.

ESP32 Wiring (true DAC output)

The classic ESP32 has two real 8-bit DACs — GPIO 25 and 26 — which drive the PAM8406 directly with no filter needed.

Module Pad ESP32 Pin Details
INL GPIO 25 (DAC1) Left channel
INR GPIO 26 (DAC2) Right channel (optional)
Input GND GND
VCC / GND VIN (5V) / GND Amp power
Speakers +L/-L and +R/-R Across each pair

Raspberry Pi Wiring (line-out or USB audio)

Feed the amp from the Pi's 3.5mm jack (models that have one) or a USB sound dongle — the highest-quality route — and keep the Pi and amp grounds common.

Connection Details
3.5mm tip → INL Left audio
3.5mm ring → INR Right audio
3.5mm sleeve → input GND Audio ground
VCC / GND Pin 2 (5V) / Pin 6 (GND)
Speakers +L/-L and +R/-R pairs
Tip: If you hear a hum, power the amp from a separate 5V supply (grounds still joined) — the Pi's rail carries switching noise that bridged amps happily reproduce.

Raspberry Pi Pico Wiring (filtered PWM)

Connection Details
GP15 → 1k resistor → INL PWM audio out
INL → 100nF cap → GND Low-pass filter
Input GND → Pico GND
VCC VBUS (pin 40, 5V)
GND GND (pin 38)
Left speaker +L and -L

Code Examples

The Arduino and Pico examples play melodies over filtered PWM; the ESP32 example synthesizes a sine sweep on its true DAC; the Pi example plays any audio file through the amp with one command plus a Python volume-sweep script.

Arduino

pam8406_arduino.ino
// PAM8406 Amplifier - Arduino Example (tone melody)
// D9 -> 1k -> INL, INL -> 100nF -> GND, speaker across +L/-L

const int audioPin = 9;

// Simple startup jingle: note frequency (Hz) and duration (ms)
const int melody[][2] = {
  {262, 200}, {330, 200}, {392, 200}, {523, 400},
  {392, 200}, {523, 600},
};

void setup() {
  Serial.begin(9600);
  Serial.println("Playing jingle on PAM8406...");
}

void loop() {
  for (unsigned int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
    tone(audioPin, melody[i][0]);
    delay(melody[i][1]);
    noTone(audioPin);
    delay(30);
  }
  delay(2000);
}

ESP32 (Arduino IDE, DAC sine)

pam8406_esp32.ino
// PAM8406 Amplifier - ESP32 Example (DAC sine sweep)
// INL -> GPIO 25 (DAC1), input GND -> GND, VCC -> VIN(5V)

#include <math.h>

const int SAMPLES = 64;
uint8_t sine[SAMPLES];

void setup() {
  Serial.begin(115200);
  for (int i = 0; i < SAMPLES; i++) {
    sine[i] = 128 + 100 * sinf(2 * PI * i / SAMPLES);  // 8-bit sine
  }
  Serial.println("Sweeping 200 Hz - 2 kHz on DAC1...");
}

void playTone(float freq, int ms) {
  // per-sample delay in microseconds for the target frequency
  int us = (int)(1000000.0f / (freq * SAMPLES));
  long end = millis() + ms;
  int i = 0;
  while (millis() < end) {
    dacWrite(25, sine[i]);
    i = (i + 1) % SAMPLES;
    delayMicroseconds(us);
  }
}

void loop() {
  for (float f = 200; f <= 2000; f *= 1.12f) {
    playTone(f, 120);
  }
  dacWrite(25, 128);          // rest at midpoint = silence
  delay(1500);
}

Raspberry Pi (Python)

pam8406_rpi.py
#!/usr/bin/env python3
# PAM8406 Amplifier - Raspberry Pi Example
# Audio out (3.5mm or USB dongle) -> INL/INR/GND, VCC -> 5V
# Plays a test file and sweeps the system volume.
# Install: sudo apt install alsa-utils; put test.wav in the same folder

import subprocess
import time

def set_volume(percent):
    subprocess.run(
        ["amixer", "sset", "Master", "{}%".format(percent)],
        stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

print("Sweeping volume up while playing test.wav...")
player = subprocess.Popen(["aplay", "test.wav"])

try:
    vol = 20
    while player.poll() is None:
        set_volume(vol)
        print("Volume: {}%".format(vol))
        vol = min(90, vol + 10)
        time.sleep(1)
    print("Done.")
except KeyboardInterrupt:
    player.terminate()
    print("Stopped by user")

Raspberry Pi Pico (MicroPython)

pam8406_pico.py
# PAM8406 Amplifier - Pico MicroPython Example (PWM melody)
# GP15 -> 1k -> INL, INL -> 100nF -> GND, speaker across +L/-L

from machine import Pin, PWM
import time

spk = PWM(Pin(15))

MELODY = [
    (262, 200), (330, 200), (392, 200), (523, 400),
    (392, 200), (523, 600),
]

def play(freq, ms):
    spk.freq(freq)
    spk.duty_u16(32768)       # 50% duty = loudest square tone
    time.sleep_ms(ms)
    spk.duty_u16(0)           # silence between notes
    time.sleep_ms(30)

print("Playing jingle on PAM8406...")
while True:
    for freq, ms in MELODY:
        play(freq, ms)
    time.sleep(2)

Frequently Asked Questions

Can I connect one speaker wire to ground to share a common return?
No — this is the one fatal mistake with this amp. The outputs are bridge-tied: both the + and - pads swing actively, which is how it makes 5W from 5V. Grounding a - pad short-circuits an output stage. Every speaker connects across exactly its own +/- pair, and the two channels never share a wire.
How loud is 5W really?
With an efficient full-range driver (85-90 dB/W), 3-5W fills a room comfortably — think portable Bluetooth-speaker loud, not party loud. The rating is at 10% distortion; clean listening power is closer to 2-3W per channel. Speaker choice matters more than watts: a decent 2-3 inch driver in a small sealed box transforms the sound.
It hisses or buzzes when the microcontroller is running. How do I quiet it?
Class-D amps reproduce whatever garbage rides on their input. Keep input wires short and away from switching wiring; join grounds at a single point; add the RC filter shown for PWM sources; and if the noise tracks CPU activity, power the amp from a separate clean 5V (grounds common). A 100-470 ohm resistor in series with each input plus the amp's input impedance also tames hot sources.
What power supply do I need?
For beeps and voice at modest volume, USB 500 mA works. For full stereo volume into 4-ohm speakers, budget 2 A at 5V — bass transients pull hard, and a sagging supply sounds like crackling at volume peaks. The onboard 1000uF helps, but it can't rescue an undersized adapter. Battery builds run great from a 1S lithium cell through a 5V boost rated 2 A+.
Can I drive it straight from a headphone jack or DAC?
Yes — that's its natural diet. Phone/laptop headphone out and line out both work; start at low source volume because headphone outputs can overdrive the input. The 3.5mm mapping is tip → INL, ring → INR, sleeve → input GND. ESP32 DAC pins connect directly; PWM sources should go through the RC filter shown in the wiring tabs.
4 ohm or 8 ohm speakers — which should I buy?
Either is safe. 4-ohm extracts the full 5W per channel; 8-ohm tops out near 3W but draws less current and stresses the supply less. Don't go below 4 ohm (no 2-ohm or paralleled 4-ohm loads) — the output stage overcurrents. If you have a drawer full of speakers, the 4-ohm ones get you the most volume here.
Do I need an output LC filter like bigger Class-D boards have?
No — the PAM8406 is a "filterless" design meant for short speaker leads, where the speaker's own inductance averages the switching waveform. Keep speaker wires under ~25 cm and twist each pair. Only if you must run long leads (or pass EMC testing) add a small ferrite bead + capacitor on each output line.

Related Tutorials