Voice Control Automation using INMP441 I2S Module and ESP32
This project allows you to control hardware—like motors and LEDs—using sound! By pairing an ESP32 Development Board with an INMP441 I2S Digital Microphone Module, the system listens to its environment and reacts to specific audio signal.
While we use a simple "clap" to trigger the LED and DC motor in this project, this setup is fully capable of complex voice control. Because we are using an I2S digital microphone, the ESP32 receives raw digital audio data, making it the perfect foundation for advanced speech recognition and keyword spotting.

Components Required
- ESP32 Development Board
- INMP441 I2S Digital Microphone Module
- L293D Motor Driver
- DC Motor
- LED
- 220Ω Resistor
- Breadboard
- Connecting Wires
- Li-Po Battery (for power)
About the Components
ESP32 Development Board

The brain of the project. It reads the digital audio data from the microphone, processes the sound levels, and controls the output devices.
- Microcontroller: Dual-core Tensilica LX6 microprocessor.
- Operating Voltage: 3.3V.
- Input Voltage: 7V - 12V (via VIN pin).
- Clock Frequency: Up to 240 MHz.
- Flash Memory: 4MB.
- Connectivity: Integrated Wi-Fi (802.11 b/g/n) and Dual-mode Bluetooth (Classic & BLE).
- I/O Pins: 30 pins with support for PWM, ADC, DAC, SPI, I2C, and I2S.
INMP441 I2S Digital Mic

A high-performance, low-power digital microphone.
- Interface: Digital I2S (Inter-IC Sound) with high precision.
- Directionality: Omnidirectional (har direction se sound capture karta hai).
- SNR (Signal-to-Noise Ratio): 61 dBA.
- Sensitivity: -26 dBFS.
- Frequency Response: 60 Hz to 15 kHz.
- Current Consumption: Very low (600 µA).
- Digital Output: 24-bit data for high-quality audio processing.
Why not a basic analog sound sensor? Analog sensors only detect loud noises and act like a simple on/off switch. The INMP441 captures clear, actual audio waveforms. If you want to build true voice control, a digital I2S mic is mandatory!
L293D Motor Driver

A compact dual DC motor driver. Microcontrollers like the ESP32 cannot provide enough current to spin a motor directly. The L293D acts as a bridge, taking small control signals from the ESP32 to deliver higher current from the battery to the motor.
- Driver Type: Dual H-Bridge motor driver.
- Supply Voltage (Vcc1 - Logic): 5V.
- Output Current: 600mA per channel (1.2A Peak current).
- Motor Voltage (Vcc2): 4.5V to 36V.
- Protection: Internal ESD protection and thermal shutdown.
- Capability: Can drive 2 DC motors or 1 Stepper motor simultaneously.
System Architecture
- Listen: The INMP441 continuously monitors the room for sound.
- Transmit: It sends high-quality, digital I2S audio data directly to the ESP32.
- Process: The ESP32 code analyzes the audio samples in real-time. For this project, it looks for the specific amplitude spike of a clap.
- Actuate: Once detected, the ESP32 signals the MX1508 motor driver and toggles the LED.
- Result: The motor spins and the LED turns on or off instantly.
Circuit Connection

Fig. Circuit Diagram

Fig. Schemetic Diagram
INMP441 to ESP32:
- VDD → 3.3V
- GND → GND
- L/R → GND (Sets channel to Left)
- WS → GPIO 25 (or your chosen pin)
- SCK → GPIO 33 (or your chosen pin)
- SD → GPIO 32 (or your chosen pin)
Outputs to ESP32 & Power:
- Motor Driver IN1 / IN2 → ESP32 Motor Control GPIOs
- Motor → Driver Motor Outputs (A+ / A-)
- LED → ESP32 GPIO (with a resistor)
- Power → Li-ion battery connects directly to the Motor Driver power input to handle the motor load safely.
Code Explanation
Libraries Used
Purpose of Library
#include <driver/i2s.h> → Enables ESP32 I2S peripheral to receive digital audio from INMP441.#include <math.h> → Provides mathematical operations like sqrt() for signal processing.
Pin Definitions
Defines I2S communication lines:
- WS → Channel sync
- SD → Audio data input
- SCK → Clock signal
I2S_PORT selects hardware I2S module.
Audio Configuration
SAMPLE_RATE → Audio sampled at 16 kHz.BUFFER_LEN → Number of samples processed per cycle.
Timing Control
DEBOUNCE_MS → Prevents multiple triggers from one clap.CLAP_GAP_MS → Max interval for detecting double clap.
Output Pins
- IN1, IN2 → Motor driver control
- LED_PIN → LED output
Global Variables
Stores raw I2S audio data.
Tracks clap timing and sequence.
Stores current output states.
-
noiseFloor→ Dynamic background noise level -
wasAbove→ Prevents repeated triggers
Setup I2S function
Configures ESP32 audio input.
- Master receive mode
- 32-bit samples
- Left channel only
- DMA buffers for continuous streaming
- Maps ESP32 pins to microphone.
- Initializes I2S driver and clears buffers.
RMS Calculation
- Converts raw audio (
>> 14) - Squares each sample
- Computes average
- Applies square root
Returns average signal energy.
Peak Detection
- Extracts absolute amplitude
- Finds maximum value
Detects sudden loud spikes.
Setup Function
- Initializes serial communication for debugging.
- Calls
setupI2S()to configure audio input. - Sets motor and LED pins as output.
- Ensures all outputs start in OFF state.
Main Loop Function
Working of Loop
- Reads digital audio data continuously from INMP441 using I2S.
- Calculates RMS (background noise level) and Peak (sound spikes).
- Updates adaptive noise floor to filter constant background noise.
- Detects clap using three conditions: amplitude, impulse, and rapid rise.
- First clap starts timing window.
- Second clap within gap toggles motor.
- If no second clap occurs, single clap toggles LED.
- Continuously prints signal values for debugging.
System Summary
The ESP32 continuously processes real-time audio from the INMP441 microphone using the I2S protocol. Instead of simple threshold detection, it applies signal analysis using RMS, peak detection, and adaptive noise filtering. This ensures reliable clap recognition even in noisy environments. Based on detected patterns, the system differentiates between single and double claps to control different outputs.
Why this Architecture Works
Using an I2S microphone is a massive upgrade over standard maker sensors. By bringing digital audio directly into the ESP32's memory, you bypass the electrical noise and limitations of analog pins. This split allows you to start simple—like clapping to turn on a fan—while giving you the exact hardware foundation needed to program offline voice assistants and keyword detection later.
Real-Life Applications
- Smart Home Automation: Turn lights, fans, or appliances on and off hands-free.
- Interactive Robotics: Build robots that respond to voice commands or turn toward specific acoustic triggers.
- Security Systems: Detect specific sound anomalies, like breaking glass or alarms.
- Accessibility Tools: Provide voice or sound-activated environmental controls for users with limited mobility.
Result

The system successfully listens to its environment and reacts instantly! When a sound threshold is met, the ESP32 accurately processes the I2S audio stream and immediately toggles the LED and DC Motor. The hardware runs smoothly without latency, proving that this compact ESP32 + INMP441 setup is highly capable of advancing from simple clap detection to full-scale audio automation.