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 S2

Sound · lesson 2 of 8

A sound level meter for your room

built, not flashed

KY-037 or INMP441MAX98357A + speaker (optional)How loud is it? With the INMP441 S2 shows real dB SPL (its datasheet says −26 dBFS at 94 dB SPL, so RMS dBFS + 111): 30 whisper, 60 talk, 85 the hearing-risk line. With the KY-037 it shows dB above your room's quiet. S2 turns the samples into decibels the way a sound level meter does: fast (125 ms) or slow (1 s) smoothing, a peak hold, and a noise floor that learns your room. Then it keeps a minute of graph, a ten-minute noise diary, and an alarm that lights lesson 02's LED on GPIO 4 when it stays too loud.

Goal

Read your room's level (in dB SPL with the INMP441), see the difference between fast and slow, keep a diary, and set off (and silence) the alarm.

You're done when

  • The meter reads about 0 when quiet, 15-25 when you talk, 40+ for a clap, and says what that roughly is.
  • With speed slow the number calms down; the peak tick still catches a clap.
  • After a few minutes, diary prints rows with low / avg / high.
  • Loud music for a second turns the alarm view red, lights the LED, and a button press silences it.

You will learn

  • decibels (+6 = ×2)
  • RMS
  • dB SPL needs a known sensitivity
  • unweighted vs dBA
  • 85 dB risk line
  • fast / slow smoothing
  • noise floor
  • echo guard
uv run pio run -d labs/sound-lab-s2 -e sound-lab-s2 -t upload
Open this lab's code on GitHubesp-labs / labs / sound-lab-s2 (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
  • Optional: MAX98357A amp + speaker
  • Optional: LED + 220–330 Ω resistor

What a decibel is

Our ears hear ratios, not differences, so loudness is measured in decibels: 20 × log10(this ÷ the quiet). Slide the loudness and watch the wave: every +6 dB doubles its height, +20 dB is ten times.

Logarithmic dBFS meter scale translating 16/24-bit PCM RMS amplitude into decibels below full scale. Our ears hear ratios, not differences, so loudness is measured in decibels: 20 × log10(this ÷ the quiet). Slide the loudness and watch the wave: every +6 dB doubles its height, +20 dB is ten times.

  • Key concepts: decibels (+6 = ×2), RMS, dB SPL needs a known sensitivity, unweighted vs dBA, 85 dB risk line, fast / slow smoothing, noise floor, echo guard.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

Fast, slow and the floor

The same sound through the meter's three lenses, replayed. Pick a scene. The floor follows the quiet: it drops at once and creeps up 0.5 dB a second, so a fan that keeps running becomes the new quiet.

Attack and release ballistics curves smoothing fast audio peaks for readable VU meters. The same sound through the meter's three lenses, replayed. Pick a scene. The floor follows the quiet: it drops at once and creeps up 0.5 dB a second, so a fan that keeps running becomes the new quiet.

  • Key concepts: decibels (+6 = ×2), RMS, dB SPL needs a known sensitivity, unweighted vs dBA, 85 dB risk line, fast / slow smoothing, noise floor, echo guard.
  • Signals & pins: 3V3 (VCC), 3V3 (MICS +), GPIO6 (AO), GPIO7 (BLK), GPIO8 (RES).

Interactive diagram loads after page initialization.

What the screen shows

Four views. Click = next, double-click = the action at the bottom left (speed, quiet, diary, alarm), long press = re-learn the quiet. While the alarm rings, any press silences it.

Gallery of ST7789 audio visualizers rendered across the Sound track. Four views. Click = next, double-click = the action at the bottom left (speed, quiet, diary, alarm), long press = re-learn the quiet. While the alarm rings, any press silences it.

  • Key concepts: decibels (+6 = ×2), RMS, dB SPL needs a known sensitivity, unweighted vs dBA, 85 dB risk line, fast / slow smoothing, noise floor, echo guard.
  • 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-s2 -e sound-lab-s2 -t uploadMac terminalroom quiet
    Does
    Builds lab S2 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 S2 …, 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. (talk, then clap)with your handsmake some noise
    Does
    The meter view: the big number is dB above your room's quiet.
    You should see
    Around 15-25 while you talk (“talking”), 40+ on a clap (“shout, clap, bang”). The white tick is the peak hold.
    If not
    Always 0: the quiet was learnt while you were talking. Type quiet and stay silent for half a second.
  3. speed slowserial monitormake some noise
    Does
    Switches the meter, graphs and alarm to 1 s smoothing (double-click on meter toggles).
    You should see
    - slow: 1 s smoothing; the number moves calmly, a clap barely lifts it.
  4. units quiet (units spl)serial monitorsound: doesn't matter
    Does
    Switches between dB SPL (INMP441 only) and dB above the quiet.
    You should see
    - units: dB above the quiet; units spl on the KY-037: dB SPL needs the INMP441 (its sensitivity is known).
  5. limit 75 spl (or limit 30 quiet)serial monitorsound: doesn't matter
    Does
    The alarm line: 30-120 dB SPL (default 80) or 3-60 dB above the quiet (default 35). Saved in NVS (namespace loud).
    You should see
    - limit 75 dB SPL; the dotted red line moves.
  6. alarm sound offserial monitorsound: doesn't matter
    Does
    The alarm tune plays once per alarm on the speaker (the button stops it too). The echo guard keeps S2 from measuring its own tune.
    You should see
    - alarm sound off.
  7. (play loud music for 2 s)with your handsmusic near the mic
    Does
    Over the limit for hold (1 s) fires the alarm.
    You should see
    x too loud: 38 dB; the alarm view pulses red, the LED on GPIO 4 lights (if wired).
    If not
    No alarm: alarm on, or a lower limit.
  8. (press the button)push button / BOOTsound: doesn't matter
    Does
    While the alarm rings, any press silences it; it re-arms when the room is calm (3 dB under the line).
    You should see
    - alarm silenced, later + calm again.
  9. diaryserial monitorsound: doesn't matter
    Does
    Prints the last ten minutes, one row per 10 s: quietest, average, loudest, and ALARM.
    You should see
    60s 2 11 34 |===== | rows.
    If not
    Empty: the diary fills one row every 10 s. Come back in a few minutes.

Steps

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

dB SPL needs a microphone whose sensitivity is known: the INMP441's is in its datasheet, so S2 can show it (unweighted, about ±2 dB; real meters often show dBA, which weights the frequencies like the ear and reads lower for a deep hum). The KY-037's numbers are dB above your room's quiet, not dB SPL (the number a calibrated meter shows): that would need a reference microphone and the capsule's sensitivity. The floor is learnt in the first half second after boot or quiet, then follows the quiet (down at once, up 0.5 dB/s). Settings (speed, limit, hold, alarm) survive a reset in NVS; the diary doesn't.

Preview: what you should see

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

  • Key concepts: decibels (+6 = ×2), RMS, dB SPL needs a known sensitivity, unweighted vs dBA, 85 dB risk line, fast / slow smoothing, noise floor, echo guard.
  • 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?
dB SPL needs a microphone whose sensitivity is known: the INMP441's is in its datasheet, so S2 can show it (unweighted, about ±2 dB; real meters often show dBA, which weights the frequencies like the ear and reads lower for a deep hum). The KY-037's numbers are dB above your room's quiet, not dB SPL (the number a calibrated meter shows): that would need a reference microphone and the capsule's sensitivity. The floor is learnt in the first half second after boot or quiet, then follows the quiet (down at once, up 0.5 dB/s). Settings (speed, limit, hold, alarm) survive a reset in NVS; the diary doesn't.
If “uv run pio run -d labs/sound-lab-s2 -e sound-lab-s2 -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 “(talk, then clap)” does not work
Always 0: the quiet was learnt while you were talking. Type quiet and stay silent for half a second.
If “(play loud music for 2 s)” does not work
No alarm: alarm on, or a lower limit.
If “diary” does not work
Empty: the diary fills one row every 10 s. Come back in a few minutes.
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.