Kode Dot

Speaker

Sound out of a Kode Dot: the codec's DAC, the amplifier the C5 switches on, the sample rate that keeps it clean, and the code to play a tone.

What it is

The speaker is a small 8 Ω, 1 W driver behind the front of the case. It plays whatever the codec's DAC is fed over I2S: a tone, a notification, a file. Between the codec and the speaker sits an NS4150B, a class-D amplifier, because the codec's own output is line level and would barely move the cone.

Two things about this path are decided by hardware and worth knowing before the first beep. The amplifier is enabled from the C5, not the P4. And the codec sounds right only at 48 kHz: at the 16 kHz that codec examples default to, it is a voice codec with audible reconstruction images; at 48 kHz it is flat and clean, and also five times louder, which is why the volume is capped.

How it is connected

flowchart LR
p4["ESP32-P4"] -- "I2S, GPIO38" --> codec["ES8311 DAC"]
codec -- "line out" --> amp["NS4150B"] --> spk["Speaker, 8 Ω 1 W"]
c5["ESP32-C5"] -. "PA_CTRL, IO4" .-> amp
Samples over I2S, line level out of the codec, the C5 switches the amplifier on

The P4 writes samples to the codec on GPIO38, clocked by GPIO33, GPIO34 and GPIO37, and configures volume and rate over I2C at 0x18. The amplifier's enable, PA_CTRL, is IO4 on the ESP32-C5. Kode's C5 firmware raises it at boot; a C5 running anything else leaves the speaker off no matter what the P4 does.

Specifications

ThingValue
CodecES8311, mono, at 0x18 on the shared I2C bus. Driver: Espressif's esp_codec_dev
AmplifierNS4150B class-D, enable PA_CTRL on C5 IO4. A codec driver that expects to own that pin is given -1
Speaker8 Ω, 1 W nominal, resonance about 1.3 kHz
Sample rate48 kHz, always. Resample material that comes at less. At 16 kHz the codec's filter leaves a 15 kHz image at −3.8 dBc
VolumeCap at about −7 dBFS. Full scale at 48 kHz is 1.9 Vrms out of the codec and the amplifier clips; the cap keeps it clean and keeps the speaker under 0.5 W
Kode driverkode_audio_init then kode_audio_tone(hz, ms) in the kode component: one sine, blocking, 100–8000 Hz
ValidatedKode-Dot-Val/05-AUDIO: playback and the USB sound-card path on a board, and the gain measured on the bench, August 2026

Gotchas

Apps that use it

On the marketplace, apps that put this part to work. Install one from start/first-app and see it before you write a line.

Example code

Play one note. You hear a short A above middle C, and the call returns when the speaker is idle again.

/*
 * speaker_tone.c - 2026-09-18 - from Kode with love
 *
 * Plays a 440 Hz tone for 300 ms out of the Kode Dot's speaker, then stops.
 * Brings the board up, opens the codec, and hands the tone to the Kode
 * driver, which fills the I2S stream and returns when it is done. You hear
 * one short beep, provided the C5 has switched the amplifier on.
 */
#include "kode.h"
 
/* Board, codec, one tone. */
void app_main(void)
{
    ESP_ERROR_CHECK(kode_bsp_init());
    ESP_ERROR_CHECK(kode_audio_init());
    ESP_ERROR_CHECK(kode_audio_tone(440, 300));
}

TBD: compiled against the kode component; a run on a V1 board.

In the SDK