Skip to content

entron/esp32_sound_direction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 Sound Direction Demo

hardware

Dual INMP441 microphones on an ESP32 using ESP-IDF v6. The firmware captures stereo I2S audio, estimates approximate SPL for each mic, and computes a rough arrival angle from inter-mic delay.

Current firmware behavior:

  • 16 kHz stereo capture
  • GPIO 2 LED turns on when either mic exceeds the SPL threshold
  • CSV metrics over UART
  • Optional Wi-Fi UDP forwarding for logs and metrics
  • Optional browser monitor in web_monitor/

Hardware

Both microphones share clocks and the same SD data line.

Mic INMP441 Pin ESP32 Pin
Left mic SD / DOUT GPIO 19
Left mic WS / LRCLK GPIO 32
Left mic SCK / BCLK GPIO 33
Left mic L/R GND
Right mic SD / DOUT GPIO 19
Right mic WS / LRCLK GPIO 32
Right mic SCK / BCLK GPIO 33
Right mic L/R 3V3
Both mics VDD 3V3
Both mics GND GND

One mic must be strapped left and the other right when they share the same SD line.

Build

idf.py build
idf.py flash monitor

Serial Output

The app prints a CSV header followed by one metrics row about every 100 ms.

Current columns:

dBSPL1,dBSPL2,level_diff_db,corr_peak,delay_samples,delay_samples_frac,delay_us,angle_deg,delay_confidence,load_core0,load_core1,min_free_heap

When the input is too quiet for direction estimation, the direction-related fields are emitted as nan.

Browser Monitor

The repository includes a small local monitor in web_monitor/ for the angle_deg stream.

ESP32 Sound Direction Wi-Fi Demo

Run it with:

python3 web_monitor/serve.py

Then open http://127.0.0.1:8765 in Chrome or Edge and choose:

  • Connect Serial to read UART directly with Web Serial
  • Connect Wi-Fi to read UDP-forwarded metrics through the local bridge

By default the bridge listens for metrics on UDP port 30501.

Optional Wi-Fi Forwarding

To forward logs and CSV metrics over Wi-Fi:

  1. Copy main/include/secrets_example.h to main/include/secrets.h.
  2. Fill in WIFI_SSID, WIFI_PASSWORD, and UDP_DEST_IP.
  3. Build with Wi-Fi forwarding enabled:
idf.py -DENABLE_WIFI_LOGGING=1 build

Defaults:

  • Log UDP port: 30500
  • Metrics UDP port: 30501

You can override the ports at build time:

idf.py -DENABLE_WIFI_LOGGING=1 -DUDP_LOG_PORT=30500 -DUDP_METRICS_PORT=30501 build

main/include/secrets.h is gitignored and should not be committed.

License

MIT. See LICENSE.

About

Experiment to use two INMP441and ESP32 to detect the direction of the sound.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors