Index
Introduction
The sound sensor module is a great tool for detecting sound levels and is perfect for projects like sound-activated lights or alarms.
It features a microphone and provides an analog output that reflects the ambient sound intensity.
This guide will show you how to connect the sound sensor to an ESP32-S3 and read sound level values accurately using the ADC (analog-to-digital converter).
Required Components
- ESP32-S3 Board
- Sound Sensor
- LED
- 220 Ohm Resistor
- Jumper Wires
- Breadboard (optional)
Pinout

Circuit Diagram / Wiring
- SOUND SENSOR
- SOUND SENSOR VCC → VIN, 3.3V (ESP32-S3)
- SOUND SENSOR GND → GND (ESP32-S3)
- SOUND SENSOR AO (Analog Output) → Pin 14 (ESP32-S3)
- LED
- Connect the longer leg (anode) of the LED to digital pin 13 through a 220-ohm resistor.
- Connect the shorter leg (cathode) to the GND pin.

Code / Programming
/***********************************************************************
* Filename : sound_sensor_led_alert.ino
* Description : ESP32-S3 reads analog sound level from a sound sensor on GPIO34.
* If the sound exceeds a defined threshold, an LED connected
* to GPIO13 lights up for a short time.
* Author : www.oceanlabz.in
* Modification: 1/4/2025
***********************************************************************/
const int LED = 13; // Use any valid GPIO pin for the LED (e.g., 13)
const int Sensor = 14; // Use an ADC-capable pin on ESP32-S3 (e.g., GPIO 14)
int level;
const int threshold = 640; // Adjust based on your sound sensor's response
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
}
void loop() {
level = analogRead(Sensor); // Read sound level
Serial.println(level); // Print value for debugging
if (level > threshold) {
digitalWrite(LED, HIGH); // Turn on LED if sound level is high
delay(1000);
digitalWrite(LED, LOW);
} else {
digitalWrite(LED, LOW);
}
}
Explanation
- The sound sensor detects ambient sound levels and sends an analog voltage to the ESP32-S3.
- The ESP32-S3reads this value using its ADC pin (e.g., GPIO 14) and compares it to a threshold.
- If the sound level exceeds the threshold, the LED turns ON as an alert or response.
Troubleshooting
- Make sure the sound sensor is connected to an ADC-capable pin (like GPIO14 on ESP32-S3).
- If the LED doesn’t turn on, verify the LED wiring and test it separately.
- Adjust the threshold value based on your environment and sensor sensitivity using Serial Monitor readings.