Skip to content
esp-labsESP32-S3 bench guide
ESP32-S3 DevKitC pinoutThis lesson uses: VCC on 3V3, MICS + on 3V3, AO on 6, BLK on 7, RES on 8, DC on 9, CS on 10, SDA on 11, SCL on 12, AMP VIN on 5V, GND on GND, BTN on 5, MICS G on GND, SD on 42, WS on 41, SCK on 40, BCLK on 39, LRC on 38, BOOT on 0, DIN on 47, DO on 21, AMP G on GND.ESP32-S3WROOM-1 N16R8BOOTRSTRGBUSBCOM3V3VCC3V3MICS +RST45BTN6AO7BLK151617188RES3469DC10CS11SDA12SCL13145VAMP VINGNDGNDGNDMICS GTX 43RX 441242SD41WS40SCK39BCLK38LRC3736350BOOT454847DIN21DO2019GNDAMP GGND
  • used in this lesson
  • safe GPIO
  • avoid
  • power
  • ground
  • button input
  • RC522
Between lessons
  1. Ctrl+C closes the monitor on the Mac only. The board keeps running.
  2. Unplug USB: this is what stops the program and the screen
  3. Rewire while off
  4. Check VCC is on 3V3, no loose ends
  5. Plug in, flash the next lesson

Never unplug during Writing at 0x…. Pin changing from output to input? Flash first, then wire.

Lesson S1

Sound · lesson 1 of 8

Hear what the microphones really send

built, not flashed

KY-037 or INMP441Two microphones, two ways in. The INMP441 is digital: its own amplifier and 24-bit converter, numbers over I2S. The KY-037 has two outputs. AO is the microphone's own voltage: a tiny wave riding on a steady bias. DO is a yes/no from the LM393 comparator, set by the blue trim pot. S1 samples AO 16 000 times a second with the ADC's DMA (no analogRead() in a loop), draws it as an oscilloscope, shows where it sits in the ADC's range, and lets you tune the pot. The mics view puts both side by side. Every other sound lab stands on this: the sampler, the 4-second ring and the level meter live in kit/lib/sound-kit.

Goal

See your voice and a clap as a wave, compare the two microphones, read the bias (or the bits), and tune the comparator so it fires only with loud sounds.

You're done when

  • The scope shows a flat line while you're quiet and a wave when you talk; a whistle stands still (trigger on).
  • The bias view shows your module's bias in mV and no CLIPPING when you clap close to it; you tried atten 6 and saw the step size halve.
  • On the comparator view, DO lights with claps and stays dark while you talk normally: “tuned”.
  • status says 16000 Hz measured and DMA overruns 0.
  • With both mics wired, the mics view says how many dB more clearly the INMP441 hears a word.

You will learn

  • analog vs digital mic
  • I2S
  • bias voltage
  • ADC attenuation
  • continuous ADC + DMA
  • ring buffer
  • 6 dB per bit, headroom
  • comparator & hysteresis
  • dBFS
uv run pio run -d labs/sound-lab-s1 -e sound-lab-s1 -t upload
Open this lab's code on GitHubesp-labs / labs / sound-lab-s1 (opens in a new tab)

Parts required

Parts library
  • ESP32-S3-DevKitC-1 + USB-C data cable
  • 1.9″ ST7789 screen
  • KY-037 analog microphone
  • INMP441 I²S microphone

The sound track, lab by lab

Six labs, each its own firmware, all reading the same microphone. Pick one to see what it turns sound into.

Overview of the 8 ESP32-S3 audio labs from analog ADC1 & digital I2S microphones to FFT spectrums and synthesis. Six labs, each its own firmware, all reading the same microphone. Pick one to see what it turns sound into.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

From air to numbers

Eight stages between your voice and a number the code can use. Step through them (or let it play); the buttons at the right make sounds, and every value below the picture is live.

Signal chain comparing acoustic pressure -> MEMS/electret mic -> ADC1 or I2S -> GDMA ring buffer -> DSP. Eight stages between your voice and a number the code can use. Step through them (or let it play); the buttons at the right make sounds, and every value below the picture is live.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

Analog mic, digital mic: how I2S carries a sample

The KY-037 hands the ESP32 a voltage to measure; the INMP441 measures it itself and sends the number. Below: one I2S frame on its three wires. Step it tick by tick and watch a 24-bit sample arrive, then become the 16-bit number every lab uses.

Side-by-side comparison of the analog KY-037 module (ADC1) vs 24-bit digital INMP441 I2S MEMS microphone. The KY-037 hands the ESP32 a voltage to measure; the INMP441 measures it itself and sends the number. Below: one I2S frame on its three wires. Step it tick by tick and watch a 24-bit sample arrive, then become the 16-bit number every lab uses.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

Where the wave sits in the ADC's range (KY-037)

Move the bias and the loudness, change the attenuation. The ADC can only measure inside the shaded range: outside it the wave is cut flat (clipping). A smaller range gives finer steps, as long as the wave still fits.

Waveform diagram explaining DC midpoint bias on the KY-037 analog output vs signed 24-bit I2S PCM samples. Move the bias and the loudness, change the attenuation. The ADC can only measure inside the shaded range: outside it the wave is cut flat (clipping). A smaller range gives finer steps, as long as the wave still fits.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

The comparator and its pot

The LM393 compares AO with the voltage the pot sets. Above the line, DO is high (and LED2 on the module lights). Drag the dashed line (or the slider) and watch DO: too low and it chatters all the time, too high and even a clap is missed.

Comparator hysteresis circuit showing how the KY-037 potentiometer threshold triggers digital clap interrupts. The LM393 compares AO with the voltage the pot sets. Above the line, DO is high (and LED2 on the module lights). Drag the dashed line (or the slider) and watch DO: too low and it chatters all the time, too high and even a clap is missed.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

What the screen shows

Five views. Click = next view, double-click = the action at the bottom left, long press = freeze. Top right: the level bar, the DO lamp (or D with the INMP441), waves while the speaker plays, and a red dot whenever anything records (S4, S8).

Gallery of ST7789 audio visualizers rendered across the Sound track. Five views. Click = next view, double-click = the action at the bottom left, long press = freeze. Top right: the level bar, the DO lamp (or D with the INMP441), waves while the speaker plays, and a red dot whenever anything records (S4, S8).

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

Wiring: the microphones and the speaker (wire what the lab needs; the screen stays as in lesson 03)

Module pinESP32-S3Notes
KY-037 + · G3V3The analog mic. + on the second 3V3 pin (the screen has the first), G on GND. Never 5 V: AO and DO swing up to the module's supply, and the ESP32-S3's pins take 3.3 V at most.
KY-037 AOGPIO 6Analog out: the microphone's voltage. GPIO 6 is ADC1 channel 5: ADC1 keeps working while Wi-Fi is on, ADC2 doesn't.
KY-037 DOGPIO 21Digital out: the LM393 comparator says high when the sound is louder than the blue trim pot's setting.
INMP441 VDD · GND3V3The digital mic (I2S). VDD on 3V3 (share the breadboard rail with the KY-037), GND on GND. 3.3 V only.
INMP441 L/RGNDLow = it talks in the left slot, the one the board reads.
INMP441 SCKGPIO 40The bit clock. The ESP32 drives it: 16 000 × 64 = 1.024 MHz.
INMP441 WSGPIO 41Word select: left slot / right slot, flips every 32 clock ticks.
INMP441 SDGPIO 42The data, most significant bit first. Pulled down, so a missing mic reads as zeros.
MAX98357A VIN · GND5VThe speaker amplifier. 5V gives the most (about 3 W into 4 Ω); 3V3 works, quieter.
MAX98357A BCLKGPIO 39Bit clock of the second I2S port (I2S1; the mic uses I2S0, so both run at once).
MAX98357A LRCGPIO 38Word select (left/right).
MAX98357A DINGPIO 47The samples, 16-bit.
MAX98357A GAIN · SDnothingLeave both unconnected: 9 dB gain, and it plays (left + right) / 2.
speaker (4 Ω, 3 W)amp + / −On the amplifier's screw terminal: the JST-PH2.0 lead's two wires, red to +.
screen (8 wires)as lesson 03Unchanged. The push button on GPIO 5 is optional: it does what BOOT does.

Commands, in order

Type these in the serial monitor (uv run pio device monitor) unless the grey tag says otherwise. The coloured tag says what should be near the board while it runs.

  1. uv run pio run -d labs/sound-lab-s1 -e sound-lab-s1 -t uploadMac terminalroom quiet
    Does
    Builds lab S1 and writes it to the board, then open the monitor with uv run pio device monitor.
    You should see
    Listening for an INMP441 on the I2S pins..., Microphone: INMP441 (I2S, digital) (mic setting: auto) (or KY-037), then Sound lab S1 …, the command list and a three-note hello from the speaker. Stay quiet for half a second: - learning the quiet...
    If not
    Wrong mic picked: mic inmp441 or mic ky037 (saved, restarts). No hello: the speaker is optional; check VIN and DIN. “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
  2. mic inmp441 (or mic ky037, mic auto)serial monitorsound: doesn't matter
    Does
    Which microphone the shell uses. auto (the default) listens for an INMP441 for 0.3 s at start-up. Saved in NVS (namespace sound); the board restarts.
    You should see
    Microphone: INMP441 (I2S, digital) (mic setting: inmp441); top right of the screen a small D instead of the DO lamp.
    If not
    Stays on the KY-037: check SCK 40, WS 41, SD 42, L/R to GND.
  3. (click to the mics view, then talk)push button / BOOTmake some noise
    Does
    Opens the other microphone too and shows both lanes, INMP441 on top: each one's quiet in dBFS and how far above it you are.
    You should see
    INMP441 hears it 12 dB more clearly (the number depends on your room); the KY-037's lane is grainier.
    If not
    Only one lane: the other mic isn't wired. Wire it, then press RST: S1 looks for it at start-up.
  4. thresh 20serial monitormake some noise
    Does
    With the INMP441 there is no DO pin: the board compares in software. thresh is the line in dB above the quiet (default 15), with 3 dB of hysteresis.
    You should see
    - software comparator at 20 dB; on the comparator view only claps cross it.
  5. (talk, then clap, near the mic)with your handsmake some noise
    Does
    The scope view draws the last 20 ms. Talking makes a small wobbly wave, a clap fills the box.
    You should see
    A wave in pink; the scale on the left grows to ±1-5 mV for a voice, ±100 mV and more for a clap.
    If not
    Flat line whatever you do: AO isn't on GPIO 6, or + isn't on 3V3 (the module's power LED must be on).
  6. statusserial monitorsound: doesn't matter
    Does
    The sampler, the ADC and the level in numbers.
    You should see
    sampler: 16000 Hz asked, 16000 Hz measured · frames dropped 0 · DMA overruns 0, then ADC: attenuation 12 dB (0-3.1 V) · bias … mV.
    If not
    Overruns climbing: something blocks core 0 for long; tell Claude what else runs.
  7. (click to the bias view)push button / BOOTroom quiet
    Does
    The 0-3.3 V ruler, your bias, and the swing of the last 0.1 s.
    You should see
    A bias line somewhere around 1-2 V and a hint such as fits in 0-1.75 V: try atten 6 (2x finer).
    If not
    Bias near 0 or 3.3 V: the module is on 5 V or a wire is loose. Use 3V3.
  8. atten 6serial monitorsound: doesn't matter
    Does
    Narrows the ADC's range to 0-1.75 V: each step becomes 0.43 mV instead of 0.76. (Double-click on bias steps through 12 → 6 → 2.5 → 0.)
    You should see
    - attenuation 6 dB (0-1.75 V); on the ruler the shaded range shrinks, the wave looks taller on the scope.
    If not
    CLIPPING: the bias or the wave no longer fits. Go back with atten 12.
  9. potserial monitorroom quiet
    Does
    Prints how to tune the comparator and jumps to the comparator view.
    You should see
    Three steps: quiet → turn until LED2 just goes off; clap → it flashes; adjust.
  10. (turn the blue pot with a small screwdriver)with your handsmake some noise
    Does
    Moves the comparator's threshold. Watch the DO lamp (top right) and the strip: loudness on top, DO below.
    You should see
    Tuned: DO follows the loud moments: tuned, LED2 flashes with claps, dark while you talk.
    If not
    DO always on: turn the other way. Which way is more sensitive differs between makers.
  11. plotserial monitormake some noise
    Does
    Prints the level as a text bar every 50 ms (any sound lab has it). plot off stops it.
    You should see
    23.4 dB |######### | | DO 0 lines scrolling.
  12. dump 64serial monitormake some noise
    Does
    Prints the newest 64 samples as numbers (int16 after removing the bias; one ADC step = 16).
    You should see
    Four lines of 16 comma-separated numbers, e.g. -32,16,48,…. Paste into a spreadsheet and draw a line chart.
  13. freeze, span 5serial monitormake some noise
    Does
    Freeze holds the picture (double-click on scope, or long press); span sets the time across the screen.
    You should see
    scope frozen (freeze again to go on); with span 5 single waves of a whistle become clear.

Steps

0 of 6 ticked. Ticks are saved in this browser.

With the INMP441 the scope's scale is in % of full scale, the bias view becomes a ladder of its 24 bits (each bit = 6 dB; how many the sound uses, the headroom left), the comparator is software, and numbers adds dB SPL. Honest expectations for the KY-037: it has no amplifier. Its AO is the capsule's raw voltage, a few millivolts for a voice, so speech uses only a handful of the ADC's 4096 steps. That makes it a good loudness sensor (claps, knocks, noise, beats) and only a rough microphone. DO is a single comparator: a clap makes dozens of edges on it as the wave crosses the line, so the labs listen to AO and use DO for the hardware lamp and as a second opinion. The ADC samples through ADC1, which keeps working while Wi-Fi is on (ADC2 doesn't).

Preview: what you should see

Interactive audio lab simulator displaying live waveforms, dBFS loudness, FFT bins, and synthesized tones.

  • Key concepts: analog vs digital mic, I2S, bias voltage, ADC attenuation, continuous ADC + DMA, ring buffer, 6 dB per bit, headroom, comparator & hysteresis, dBFS.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

ESP32-S3 peripherals used in this lab

Open interactive GPIO pinout

Explore the hardware blocks, pin rules, and registers behind this experiment.

  • GPIO and IO MUX

    45 pins, and a matrix that routes almost any signal to almost any pin

  • I2S

    Digital audio in and out: microphones, amplifiers, codecs

  • SPI

    Fast four-wire bus for screens, card readers and flash

  • SAR ADC

    Two 12-bit converters that turn a voltage into a number

  • GDMA

    Moves data between memory and peripherals without the CPU

  • UART

    Three serial ports, the one you see in the serial monitor

Troubleshooting & hardware gotchas

See all 17 ESP32-S3 hardware gotchas
What if it does not work or behaves unexpectedly?
With the INMP441 the scope's scale is in % of full scale, the bias view becomes a ladder of its 24 bits (each bit = 6 dB; how many the sound uses, the headroom left), the comparator is software, and numbers adds dB SPL. Honest expectations for the KY-037: it has no amplifier. Its AO is the capsule's raw voltage, a few millivolts for a voice, so speech uses only a handful of the ADC's 4096 steps. That makes it a good loudness sensor (claps, knocks, noise, beats) and only a rough microphone. DO is a single comparator: a clap makes dozens of edges on it as the wave crosses the line, so the labs listen to AO and use DO for the hardware lamp and as a second opinion. The ADC samples through ADC1, which keeps working while Wi-Fi is on (ADC2 doesn't).
If “uv run pio run -d labs/sound-lab-s1 -e sound-lab-s1 -t upload” does not work
Wrong mic picked: mic inmp441 or mic ky037 (saved, restarts). No hello: the speaker is optional; check VIN and DIN. “Failed to connect”: hold BOOT, tap RST, release BOOT, run it again.
If “mic inmp441 (or mic ky037, mic auto)” does not work
Stays on the KY-037: check SCK 40, WS 41, SD 42, L/R to GND.
If “(click to the mics view, then talk)” does not work
Only one lane: the other mic isn't wired. Wire it, then press RST: S1 looks for it at start-up.
If “(talk, then clap, near the mic)” does not work
Flat line whatever you do: AO isn't on GPIO 6, or + isn't on 3V3 (the module's power LED must be on).
If “status” does not work
Overruns climbing: something blocks core 0 for long; tell Claude what else runs.
If “(click to the bias view)” does not work
Bias near 0 or 3.3 V: the module is on 5 V or a wire is loose. Use 3V3.
If “atten 6” does not work
CLIPPING: the bias or the wave no longer fits. Go back with atten 12.
If “(turn the blue pot with a small screwdriver)” does not work
DO always on: turn the other way. Which way is more sensitive differs between makers.
Four pins are read at reset
GPIO0, GPIO3, GPIO45 and GPIO46 are sampled the moment the chip comes out of reset: they pick the boot mode, the flash voltage, the ROM log and the JTAG source. Anything wired to them must not pull them the wrong way at power-up. After reset they are normal pins again.
GPIO3 has no pull resistor at reset
GPIO0 has a weak pull-up and GPIO45/46 weak pull-downs, but GPIO3 floats. When the eFuses make it choose the JTAG source, an outside circuit has to hold it at a clear level.
ADC2 stops working while Wi-Fi is on
The ADC2 channels (GPIO11-20) cannot be used at the same time as Wi-Fi: the radio shares ADC2 through an arbiter. Put analog sensors on ADC1 (GPIO1-10), as the sound labs do with GPIO6.
GPIO47 and 48 run at 1.8 V on R16V modules
Modules with the ESP32-S3R16V chip set the flash voltage to 1.8 V, and GPIO47/48 share that supply. A 3.3 V part on those pins sees the wrong levels.