Overview
This square mini speaker is a simple way to give a project a voice. It is a passive 4 Ω driver with a supplier-listed 3 W rating (the supplier calls it a “2831 type”), mounting tabs on the frame, and a 150 mm red-and-black lead that ends in a two-pin Dupont-style connector — small enough for handheld builds, loud enough for alarms, spoken prompts, MP3 playback, and game sound effects.
“Passive” is the important word: there is no amplifier inside. A 4 Ω load on a 5 V signal would try to draw more than an amp, while a microcontroller pin can supply only a few tens of milliamps — so the speaker always connects to the output of an audio amplifier, never to a GPIO pin. Good matches are small 5 V Class-D boards: an I2S amplifier such as the MAX98357 (up to 3.2 W into 4 Ω at 5 V), an analog-input module such as the PAM8406, or an MP3 player module with its own speaker output.
This manual covers how to connect the speaker to the common amplifier options for Arduino, ESP32, Raspberry Pi, and Pico, what the 4 Ω and 3 W numbers mean for volume and power-supply sizing, which wire is which, and short test programs to confirm everything works.
At a Glance
Specifications
| Parameter | Value |
| Speaker type | Passive dynamic mini speaker, square frame with mounting tabs (supplier “2831 type”) |
| Nominal impedance | 4 Ω (supplier nominal value) |
| Power rating | 3 W, supplier-listed (continuous vs. peak not specified) |
| Voltage at rated power | About 3.5 V RMS across the speaker (√(3 W × 4 Ω)) |
| Current at rated power | About 0.87 A RMS |
| Lead | 150 mm, red and black wires |
| Connector | Two-pin Dupont-style, 2.54 mm pitch |
| Polarity | Not marked in the supplier data — red is + by convention |
| Amplifier | Required (no amplifier inside the speaker) |
| Not specified | Frequency response, sensitivity, frame dimensions |
| In the box | 1 speaker with attached lead |
Wiring Guide
Three rules cover every setup: the speaker goes across an amplifier’s two speaker terminals and nowhere else; neither speaker wire ever connects to ground, because small Class-D outputs are bridge-tied; and the amplifier needs a supply that can deliver about 1 A at full volume. If your amplifier has no matching header pins, bridge the Dupont connector with two jumper wires, or trim it off and strip the two leads for screw terminals.
Arduino + Analog-Input Amplifier (PAM8406-class)
An Uno or Nano has no DAC, so the tone() output passes through a small RC filter into the amplifier’s input. The amplifier — not the Arduino — drives the speaker.
| Connection | Goes To | Details |
|---|---|---|
| Arduino D9 | 1 kΩ resistor → amplifier input (INL) | Signal only — almost no current |
| Amplifier input (INL) | 100 nF capacitor → GND | RC low-pass that softens the square wave |
| Amplifier VCC / GND | Arduino 5V / GND | Shared ground; USB 5 V is fine for test beeps |
| Amplifier +L / −L | Speaker red / black | Across the output pair only |
ESP32 + MAX98357 I2S Amplifier
I2S keeps the audio digital all the way to the amplifier, so there is no PWM filtering to get right. Any free GPIOs work; these match the code below.
| Amplifier Pin | ESP32 Pin | Details |
|---|---|---|
| VIN | 5V (VIN) | 2.5–5.5 V supply; 5 V gives full power |
| GND | GND | Common ground |
| BCLK | GPIO 26 | Bit clock |
| LRC | GPIO 25 | Left/right (word) clock |
| DIN | GPIO 22 | Audio data |
| Speaker + / − | Speaker red / black | The amplifier’s speaker terminal or pads |
Raspberry Pi + MAX98357 I2S Amplifier
The Pi sends audio over its PCM/I2S pins on the 40-pin header. No sound card or 3.5 mm jack is needed.
| Amplifier Pin | Pi Pin | Details |
|---|---|---|
| VIN | Pin 2 (5V) | Amplifier supply |
| GND | Pin 6 (GND) | Common ground |
| BCLK | Pin 12 (GPIO 18) | PCM clock |
| LRC | Pin 35 (GPIO 19) | PCM frame sync |
| DIN | Pin 40 (GPIO 21) | PCM data out |
| Speaker + / − | Speaker red / black | Across the output pair only |
Raspberry Pi Pico + MAX98357 I2S Amplifier
MicroPython’s I2S driver on the Pico needs the word-clock pin to be the GPIO directly after the bit-clock pin, which is why GP16 and GP17 are used together.
| Amplifier Pin | Pico Pin | Details |
|---|---|---|
| VIN | VBUS (pin 40) | 5 V from USB |
| GND | GND (pin 38) | Common ground |
| BCLK | GP16 (pin 21) | Bit clock |
| LRC | GP17 (pin 22) | Must be the pin right after BCLK |
| DIN | GP18 (pin 24) | Audio data |
| Speaker + / − | Speaker red / black | Across the output pair only |
Code Examples
Each example plays a short test sound so you can confirm the wiring before building anything bigger. Start at low volume.
Arduino (tone test through an amplifier)
// Speaker tone test - Arduino Uno / Nano
// D9 -> 1k resistor -> amplifier INPUT (never straight to the speaker)
// Amplifier output + / - -> speaker red / black
const int AUDIO_PIN = 9;
const int NOTES[] = {262, 294, 330, 349, 392, 440, 494, 523}; // C4 to C5
void setup() {
Serial.begin(9600);
Serial.println("Playing test scale...");
}
void loop() {
for (int i = 0; i < 8; i++) {
tone(AUDIO_PIN, NOTES[i], 250); // 250 ms per note
delay(300);
}
noTone(AUDIO_PIN);
delay(2000); // pause, then repeat
}
ESP32 and Pico (MicroPython, I2S test tone)
# I2S test tone - MicroPython with a MAX98357 amplifier
# ESP32 pins: BCLK = 26, LRC = 25, DIN = 22
# Pico pins: BCLK = 16, LRC = 17, DIN = 18 (LRC must be BCLK + 1)
from machine import I2S, Pin
import math
import struct
BCLK, LRC, DIN = 26, 25, 22 # change to 16, 17, 18 on a Pico
RATE = 22050 # samples per second
FREQ = 441 # Hz - exactly 50 samples per cycle at 22050
VOLUME = 0.25 # 0.0 to 1.0, start low
audio = I2S(0, sck=Pin(BCLK), ws=Pin(LRC), sd=Pin(DIN),
mode=I2S.TX, bits=16, format=I2S.MONO,
rate=RATE, ibuf=4000)
# Build one cycle of a sine wave as 16-bit samples
n = RATE // FREQ
cycle = bytearray(n * 2)
for i in range(n):
sample = int(32767 * VOLUME * math.sin(2 * math.pi * i / n))
struct.pack_into("<h", cycle, i * 2, sample)
try:
for _ in range(FREQ * 2): # about 2 seconds of tone
audio.write(cycle)
finally:
audio.deinit()
Raspberry Pi (enable the MAX98357 and test)
# Raspberry Pi OS Bookworm and later: /boot/firmware/config.txt
# Older releases: /boot/config.txt
sudo nano /boot/firmware/config.txt
# 1) Put a # in front of this line: dtparam=audio=on
# 2) Add this line: dtoverlay=max98357a
sudo reboot
# After the reboot:
aplay -l # the MAX98357 card should be listed
speaker-test -c2 -t wav -l 1 # plays a spoken channel test once