A four-microphone ESP32-S3 sound-direction demo that estimates where a sound came from using TDOA and displays the direction on a TFT screen plus a web dashboard.
Chinese · Quickstart · How It Works · Web Dashboard
This is a compact sound-localization prototype built with an ESP32-S3, four I2S microphone modules, and a TFT screen. It listens for sharp sound events, filters out low-energy noise, estimates the time difference of arrival between microphone pairs, and turns that into a direction angle.
The project is intentionally simple: one Arduino sketch, one physical prototype, and one browser dashboard for calibration.
- Four-microphone I2S sampling using two ESP32 I2S peripherals.
- High-pass filtering, energy thresholding, normalization, and cross-correlation TDOA estimation.
- Direction sector drawn directly on a TFT screen.
- ESP32-hosted web dashboard with live waveforms, radar view, TDOA values, and tuning sliders.
- Runtime tuning for I2S sample offsets, energy threshold, and display sector width.
- Wi-Fi station mode with fallback access point when no local Wi-Fi is configured.
| Part | Role |
|---|---|
| ESP32-S3 | Main controller, I2S sampling, web server, signal processing |
| 4x I2S microphone modules | Sound arrival-time sensing |
| TFT display with TFT_eSPI | Local direction display |
| Breadboard / wiring | Prototype microphone geometry |
| Signal group | ESP32 pin |
|---|---|
| MIC1 + MIC2 shared I2S data | GPIO 4 |
| MIC1 + MIC2 BCLK | GPIO 5 |
| MIC1 + MIC2 WS/LRCLK | GPIO 6 |
| MIC3 + MIC4 shared I2S data | GPIO 39 |
| MIC3 + MIC4 BCLK | GPIO 37 |
| MIC3 + MIC4 WS/LRCLK | GPIO 38 |
For each I2S microphone pair, set the two microphone modules to opposite left/right channel selections so the shared data line carries a stereo pair. Configure the TFT pins in your local TFT_eSPI setup file.
- Install the ESP32 board package in Arduino IDE.
- Install these libraries:
ESPAsyncWebServerAsyncTCPArduinoJsonTFT_eSPI
- Open
src/esp32_sound_radar/esp32_sound_radar.ino. - Select an ESP32-S3 board and upload the sketch.
- Open Serial Monitor at
115200baud. - Connect to the printed dashboard address.
If WIFI_SSID is left as YOUR_WIFI_SSID, the ESP32 starts a fallback access point:
SSID: ESP32-Sound-Radar
Password: soundradar
Dashboard: http://192.168.4.1
The ESP32 serves a dashboard at / and streams waveform data over /ws.
The dashboard shows:
- four microphone waveforms
- TDOA values in microseconds
- estimated direction angle
- radar-style direction fan
- sliders for I2S0/I2S1 offset calibration
- sliders for noise energy threshold and sector width
- Two I2S buses read four microphones as two stereo pairs.
- The sketch applies configurable sample offsets to align the I2S streams.
- A high-pass filter reduces low-frequency drift.
- Low-energy frames are ignored using an adjustable threshold.
- The remaining frame is normalized so correlation is less sensitive to volume.
- Cross-correlation estimates the lag between microphone signals.
- Averaged horizontal/vertical lag estimates are converted into an angle with
atan2. - The direction is drawn on the TFT display and streamed to the browser.
This is an experimental prototype, not a calibrated measurement instrument. Microphone spacing, orientation, room reflections, and module timing differences all affect accuracy.
src/esp32_sound_radar/esp32_sound_radar.ino
Main Arduino sketch with sampling, filtering, TDOA, TFT drawing, and web UI.
.github/assets/sound-radar-build.jpg
Photo of the physical prototype used in the README.
- Do not commit real Wi-Fi credentials. The public sketch uses placeholders and AP fallback.
- For better direction accuracy, keep microphone positions symmetric and mechanically stable.
- The dashboard uses Chart.js from a CDN, so waveform charts need internet access in the browser.
MIT License. Commercial use, modification, distribution, and private use are allowed.
