Sound · lesson 4 of 8
A voice-activated recorder
KY-037 or INMP441Wi-Fi (W1) (optional)MAX98357A + speaker (optional)Armed, the board waits for a sound louder than the trigger, then records into PSRAM, starting half a second before the trigger (the ring buffer still has it), until 1.2 s of quiet. Up to 12 clips, 6 MB, gone on reset. Listen on your phone at http://bench.local (the Wi-Fi network W1 saved, plus the admin token), or pull a WAV over USB with tools/sound_pull.py, or play it on the board's own speaker (play 3 0.7: slower and deeper). The board always shows REC and a red LED while it records, whoever started it.
Record a sentence hands-free, see the pre-roll, play it on your phone, and pull one clip to your Mac as a WAV file.
You're done when
arm, then talk: the recorder view goes ARMED → REC → ARMED andclipslists a voice clip.- A door slam or a single clap starts a recording but is dropped (too short).
- The phone page at
http://bench.localunlocks with the token, draws the clip and plays it. tools/sound_pull.pywrote a .wav that plays on the Mac.play(or a double-click on clips) plays the picked clip on the board's speaker;play 1 2is a chipmunk.
On the board
- 3V3VCC
- 3V3MICS +
- GPIO 6AO
- GPIO 7BLK
- GPIO 8RES
- GPIO 9DC
- GPIO 10CS
- GPIO 11SDA
- GPIO 12SCL
- 5VAMP VIN
- GNDGND
- GPIO 5BTN
- GNDMICS G
- GPIO 42SD
- GPIO 41WS
- GPIO 40SCK
- GPIO 39BCLK
- GPIO 38LRC
- GPIO 0BOOT
- GPIO 47DIN
- GPIO 21DO
- GNDAMP G
You will learn
- pre-roll from a ring
- trigger + hold
- PSRAM clip store
- WAV format
- streaming responses
- base64 + CRC-32
- playback speed = pitch
- tokens & visible recording
uv run pio run -d labs/sound-lab-s4 -e sound-lab-s4 -t uploadParts required
Parts library- ESP32-S3-DevKitC-1 + USB-C data cable
- 1.9″ ST7789 screen
- KY-037 analog microphone
- INMP441 I²S microphone
- Optional: MAX98357A amp + speaker
- Optional: 2.4 GHz Wi-Fi network
Voice-activated recording, step by step
Nine seconds: a door bang, then a sentence with a pause in it. Step through or play, move the trigger and the hold. Amber = the pre-roll taken from the ring, red = recorded, grey = dropped.
Voice-activated recorder timeline showing pre-roll ring buffers, silence timeout, and HTTP streaming. Nine seconds: a door bang, then a sentence with a pause in it. Step through or play, move the trigger and the hold. Amber = the pre-roll taken from the ring, red = recorded, grey = dropped.
- Key concepts: pre-roll from a ring, trigger + hold, PSRAM clip store, WAV format, streaming responses, base64 + CRC-32, playback speed = pitch, tokens & visible recording.
- Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).
Interactive diagram loads after page initialization.
Getting the audio out
Three paths: the phone over Wi-Fi, the Mac over the USB serial port, or the board's own speaker. Below: the 44 bytes every WAV file starts with (for a 3.2 s clip at 16 000 Hz).
Audio-driven breakout and pitch game mechanics mapped to live microphone input. Three paths: the phone over Wi-Fi, the Mac over the USB serial port, or the board's own speaker. Below: the 44 bytes every WAV file starts with (for a 3.2 s clip at 16 000 Hz).
- Key concepts: pre-roll from a ring, trigger + hold, PSRAM clip store, WAV format, streaming responses, base64 + CRC-32, playback speed = pitch, tokens & visible recording.
- Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).
Interactive diagram loads after page initialization.
What the screen shows
Three views. Click = next, double-click = the action at the bottom left (arm, next, wifi), long press = rec / stop.
Gallery of ST7789 audio visualizers rendered across the Sound track. Three views. Click = next, double-click = the action at the bottom left (arm, next, wifi), long press = rec / stop.
- Key concepts: pre-roll from a ring, trigger + hold, PSRAM clip store, WAV format, streaming responses, base64 + CRC-32, playback speed = pitch, tokens & visible recording.
- 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 pin | ESP32-S3 | Notes |
|---|---|---|
| KY-037 + · G | 3V3 | The 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 AO | GPIO 6 | Analog out: the microphone's voltage. GPIO 6 is ADC1 channel 5: ADC1 keeps working while Wi-Fi is on, ADC2 doesn't. |
| KY-037 DO | GPIO 21 | Digital out: the LM393 comparator says high when the sound is louder than the blue trim pot's setting. |
| INMP441 VDD · GND | 3V3 | The digital mic (I2S). VDD on 3V3 (share the breadboard rail with the KY-037), GND on GND. 3.3 V only. |
| INMP441 L/R | GND | Low = it talks in the left slot, the one the board reads. |
| INMP441 SCK | GPIO 40 | The bit clock. The ESP32 drives it: 16 000 × 64 = 1.024 MHz. |
| INMP441 WS | GPIO 41 | Word select: left slot / right slot, flips every 32 clock ticks. |
| INMP441 SD | GPIO 42 | The data, most significant bit first. Pulled down, so a missing mic reads as zeros. |
| MAX98357A VIN · GND | 5V | The speaker amplifier. 5V gives the most (about 3 W into 4 Ω); 3V3 works, quieter. |
| MAX98357A BCLK | GPIO 39 | Bit clock of the second I2S port (I2S1; the mic uses I2S0, so both run at once). |
| MAX98357A LRC | GPIO 38 | Word select (left/right). |
| MAX98357A DIN | GPIO 47 | The samples, 16-bit. |
| MAX98357A GAIN · SD | nothing | Leave 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 03 | Unchanged. 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.
uv run pio run -d labs/sound-lab-s4 -e sound-lab-s4 -t uploadMac terminalroom quiet- Does
- Builds lab S4 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), thenSound lab S4 …, 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 inmp441ormic 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.
armserial monitorroom quiet- Does
- Voice-activated: louder than
trigger(15 dB above the quiet) starts a clip. - You should see
- armed: talk and it records; the recorder view says ARMED (teal ring).
(say a sentence, then wait)with your handsmake some noise- Does
- Records from half a second before your first word until 1.2 s after the last loud moment.
- You should see
x REC clip 1 (voice); REC 2.4 s in red, the header's red dot, the RGB LED red; then+ clip 1: 3.1 s.- If not
- Never starts: speak closer, or
trigger 10.
play 1 0.7serial monitorsound: doesn't matter- Does
- Plays clip 1 on the board's speaker at 0.7× speed (deeper, slower). Without a number: the clip picked on the clips view. Made louder like the download, but at most ×16.
stopstops it;recstops it before recording; it is refused while recording. - You should see
+ playing clip 1 (4.4 s) at x0.70, then- clip 1 played; waves in the header.- If not
recording: stop first (the microphone would hear the speaker).
clipsserial monitorsound: doesn't matter- Does
- Lists the clips: number, length, voice or hand, loudest, how much louder it is sent, when.
- You should see
1 3.1s voice -38.2 dBFS x23.4 2026-10-14 14:02:31
tokenserial monitorsound: doesn't matter- Does
- Prints the admin token the phone page asks for (shared with W2/R7/R8).
- You should see
Admin token: 3f…and where to paste it.- If not
- Keep it out of chats and git;
token newreplaces it.
http://bench.localon your phonesound: doesn't matter- Does
- The board's own page: live level, arm / rec / stop, the clip list with each waveform, play and download, a speed choice and Play on board / Stop on board per clip. The token stays in that tab only.
- You should see
- A clip card with its shape; play moves a playhead.
- If not
- “no Wi-Fi saved”: flash wifi-lab-w1 once and join. Page unreachable: same network? Try the IP from
wifi.
uv run python tools/sound_pull.py /dev/cu.usbserial-A5069RR4 1Mac terminalsound: doesn't matter- Does
- Close the monitor first. Types
send 1, reads the base64 WAV, checks the CRC-32 and the size, writes the file. - You should see
Receiving clip 1: 99244 bytes as …, thenSaved … (3.1 s at 16000 Hz, 99244 bytes, CRC ok).- If not
Could not open … (is the serial monitor still open?): close it.
Steps
0 of 6 ticked. Ticks are saved in this browser.
Privacy is built in, not optional: recording always shows on the board (REC, red dot, red LED) whoever starts it; every audio route on the page needs the admin token; clips live in RAM only and vanish on reset. The sound will be thin and hissy: the clips are normalised (made up to 64 times louder) on the way out, and that lifts the hiss with the voice. This module is a loudness sensor first, a microphone second.
Preview: what you should see
Interactive audio lab simulator displaying live waveforms, dBFS loudness, FFT bins, and synthesized tones.
- Key concepts: pre-roll from a ring, trigger + hold, PSRAM clip store, WAV format, streaming responses, base64 + CRC-32, playback speed = pitch, tokens & visible recording.
- 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 pinoutExplore 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
- RMT
Plays and records exact pulse trains: IR remotes, RGB LEDs
- SAR ADC
Two 12-bit converters that turn a voltage into a number
- Wi-Fi
2.4 GHz 802.11b/g/n, as a station, an access point or both
Troubleshooting & hardware gotchas
See all 17 ESP32-S3 hardware gotchas- What if it does not work or behaves unexpectedly?
- Privacy is built in, not optional: recording always shows on the board (REC, red dot, red LED) whoever starts it; every audio route on the page needs the admin token; clips live in RAM only and vanish on reset. The sound will be thin and hissy: the clips are normalised (made up to 64 times louder) on the way out, and that lifts the hiss with the voice. This module is a loudness sensor first, a microphone second.
- If “uv run pio run -d labs/sound-lab-s4 -e sound-lab-s4 -t upload” does not work
- Wrong mic picked:
mic inmp441ormic 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 “(say a sentence, then wait)” does not work
- Never starts: speak closer, or
trigger 10. - If “play 1 0.7” does not work
recording: stop first (the microphone would hear the speaker).- If “token” does not work
- Keep it out of chats and git;
token newreplaces it. - If “http://bench.local” does not work
- “no Wi-Fi saved”: flash wifi-lab-w1 once and join. Page unreachable: same network? Try the IP from
wifi. - If “uv run python tools/sound_pull.py /dev/cu.usbserial-A5069RR4 1” does not work
Could not open … (is the serial monitor still open?): close it.- 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.