Kode Dot

Microphone

Sound into a Kode Dot: a MEMS microphone on the codec's analogue input, read as samples over I2S, and the code to watch its level.

What it is

The microphone is a ZTS6211E, a small analogue MEMS capsule on the front of the board. It does not speak any bus of its own: its output goes straight into the codec's microphone input, and the codec's ADC turns it into samples the P4 reads over I2S. So a bus scan will never show a microphone, and the codec's gain setting is the microphone's volume.

What you get is a mono stream of 16-bit samples at the codec's sample rate. From there it is a level meter, a waveform on the screen, a recording to the microSD card, or the input side of the USB sound card the Kode Dot can present to a computer.

How it is connected

flowchart LR
mic["ZTS6211E"] -- "MIC1P / MIC1N" --> codec["ES8311 ADC"]
codec -- "I2S, GPIO36" --> p4["ESP32-P4"]
Analogue into the codec, samples out of it over I2S

The capsule is powered from the 3.3 V rail with no gate of its own, and wired to the codec's MIC1P and MIC1N pins. The codec sends samples to the P4 on GPIO36, clocked by the same GPIO33, GPIO34 and GPIO37 the speaker uses, and takes its gain over I2C at 0x18.

Specifications

ThingValue
MicrophoneZTS6211E, analogue MEMS, always powered
PathCodec's mic input → ADC → I2S to the P4 on GPIO36. Mono, 16-bit
GainSet in the codec over I2C. Kode's validation echo runs at 18 dB
Sample rate48 kHz, the same clock as the speaker; the two directions share one I2S channel
Kode driverkode_audio_envelope: one 50 ms window reduced to 32 peak values, 0–1000. Enough to draw a waveform, not enough to reconstruct the sound, on purpose
USB sound cardThe P4 can present itself to a computer as a USB audio device, mono in and out, 96 kHz. It takes the USB-C port, so the serial console goes away while it runs
ValidatedKode-Dot-Val/05-AUDIO: echo on the board and recording through the USB sound card from a Mac

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

Read the microphone's level ten times a second and log it. Silence logs a small number; tap the front of the Kode Dot and it jumps.

/*
 * mic_level.c - 2026-09-18 - from Kode with love
 *
 * Watches the Kode Dot's microphone. Brings the board and the codec up, then
 * reads one 50 ms window of audio at a time as a 32-bin envelope and logs
 * the loudest bin, 0 to 1000. Silence logs a few tens; a tap on the case or
 * a word spoken at it jumps into the hundreds.
 */
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "kode.h"
 
/* Board, codec, then one envelope per loop. */
void app_main(void)
{
    ESP_ERROR_CHECK(kode_bsp_init());
    ESP_ERROR_CHECK(kode_audio_init());
 
    while (1) {
        uint16_t bins[KODE_AUDIO_ENVELOPE_BINS];
        ESP_ERROR_CHECK(kode_audio_envelope(bins, KODE_AUDIO_ENVELOPE_BINS));   /* blocks ~50 ms */
 
        uint16_t peak = 0;
        for (int i = 0; i < KODE_AUDIO_ENVELOPE_BINS; i++) {
            if (bins[i] > peak) peak = bins[i];
        }
        ESP_LOGI("mic", "level %4u / 1000", peak);
        vTaskDelay(pdMS_TO_TICKS(50));
    }
}

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

In the SDK