ESP32 S3 - Sound Sensor

Sound sensors detect the presence of sound and enable your ESP32 S3 to create interactive, sound-responsive projects like clap-activated lights or voice-triggered devices. This tutorial will show you how to connect and program a sound sensor with your ESP32 S3 board.

What you'll build:

  1. A sound detection circuit with ESP32 S3 and a digital or analog sound sensor
  2. Arduino code that reads the sensor state and identifies sound events
  3. Serial Monitor output that reports when sound is detected or disappears
  4. A foundation you can extend to trigger LEDs, relays, or servo motors on sound
ESP32 S3 sound sensor

After completing this tutorial, you can modify the code to trigger actions when sound is detected - turn on an LED, activate a relay to control lights, or rotate a servo motor based on sound input.

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Digital Sound Sensor
1×Analog Sound Sensor
1×Breadboard
1×Jumper Wires
1×Optionally, 5V Power Adapter for ESP8266

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Sound Sensor

A sound sensor is a detection module that senses sound waves in the surrounding environment and converts them to electrical signals. It uses a microphone element and onboard circuitry to produce both digital and analog outputs that microcontrollers like the ESP32 S3 can read directly. The module's built-in potentiometer lets you fine-tune the detection threshold so the sensor responds to exactly the sound level your project requires.

Key Specifications

  • Output types: Digital (HIGH/LOW) and analog (voltage proportional to sound level)
  • Operating voltage: 3.3V to 5V — compatible with the ESP32 S3's 3.3V GPIO
  • Sensitivity: Adjustable via onboard potentiometer
  • Indicators: Power LED (always on) and status LED (blinks on detection)
  • Interface: Simple 3-pin (digital) or 4-pin (analog) connection

The Digital Sound Sensor Pinout

The digital sound sensor has three connection pins that map directly to your ESP32 S3.

  1. VCC pin: Connect to power supply (3.3V to 5V)
  2. GND pin: Connect to ground (0V)
  3. OUT pin: Digital output pin - outputs HIGH when quiet, LOW when sound is detected - connect to ESP32 S3 digital input pin
Sound Sensor Pinout
image source: diyables.io

Additional features:

  • Built-in potentiometer for adjusting sound sensitivity threshold
  • Power LED indicator shows when the sensor is powered
  • Status LED indicator lights up when sound is detected

The Analog Sound Sensor Pinout

The analog sound sensor has four connection pins offering both digital and analog outputs.

  1. + pin: Connect to 5V power supply
  2. G pin: Connect to ground (0V)
  3. DO pin: Digital output - outputs HIGH when quiet, LOW when sound detected - connect to ESP32 S3 digital input pin
  4. AO pin: Analog output - outputs analog voltage representing sound level - connect to ESP32 S3 analog input pin
analog sound sensor Pinout
image source: diyables.io

How It Works

The sound sensor module detects sound and converts it to electrical signals your ESP32 S3 can read. The digital output toggles LOW when sound exceeds the sensitivity threshold and returns HIGH when the environment is quiet, while the analog output provides a continuous voltage representing the current sound level. You can tune the detection threshold at any time by rotating the onboard potentiometer — clockwise to require louder sounds, counterclockwise to detect quieter sounds.

Digital output behavior:

  • When sound is detected: Output pin goes LOW
  • When no sound (quiet): Output pin stays HIGH
  • Sensitivity threshold adjustable via onboard potentiometer

Wiring Diagram

Connect your sound sensor to the ESP32 S3 following the diagram below, then double-check every connection before applying power. The digital sound sensor requires only three wires, while the analog version adds a fourth wire for the AO pin.

Safety Notes

Always verify that VCC connects to the correct voltage rail (3.3V or 5V) before powering on — reversing the power polarity can damage the sensor module. Keep jumper wires tidy and away from the potentiometer adjustment screw so accidental contact does not shift your sensitivity setting during testing.

The wiring diagram between ESP32 S3 Sound Sensor

This image is created using Fritzing. Click to enlarge image

Sound Sensor Pin ESP32 S3 Pin
VCC 3.3V or 5V
GND GND
OUT (or DO) 16 (GPIO16)

How To Program For Sound Sensor

Programming the ESP32 S3 to read a sound sensor is straightforward — you configure one GPIO as a digital input, read its state in a loop, and interpret the result as sound detected or not detected. The following code demonstrates this approach with clear Serial Monitor output so you can verify the sensor is working before building your larger project.

Step 1 - Initialize the pin:

pinMode(16, INPUT);

Step 2 - Read the sensor state:

int soundState = digitalRead(16);

ESP32 S3 Code - Detecting the sound

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-sound-sensor */ #define SENSOR_PIN 16 // The ESP32 S3 pin 16 connected to the OUT pin of the sound sensor int prev_sound_state = HIGH; // The previous state from the input pin int sound_state; // The current reading from the input pin void setup() { // Initialize the Serial to communicate with the Serial Monitor. Serial.begin(115200); // initialize the ESP32's pin as an input pinMode(SENSOR_PIN, INPUT); } void loop() { // read the state of the the ESP32's input pin sound_state = digitalRead(SENSOR_PIN); if (prev_sound_state == HIGH && sound_state == LOW) Serial.println("The sound has been detected"); else if (prev_sound_state == LOW && sound_state == HIGH) Serial.println("The sound has disappeared"); // save the the last state prev_sound_state = sound_state; }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Check the wiring: Verify all connections match the wiring diagram above
  3. Copy the code: Copy the provided code and open it in Arduino IDE
  4. Select your board: Choose ESP32 S3 from the boards menu
  5. Upload the code: Click the Upload button to transfer code to your ESP32 S3
  6. Open Serial Monitor: Set baud rate to 115200 in the Serial Monitor
  7. Test the sensor: Clap your hands or make noise near the sound sensor
  8. Observe the output: Check the Serial Monitor for sound detection messages
  9. Adjust sensitivity: If needed, turn the potentiometer to fine-tune detection threshold
  10. Pro Tip: If the status LED stays constantly on or off regardless of sound, adjust the potentiometer slowly while making noise until the LED blinks in response to sound.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
2026-06-16 14:23:15.342 - The sound has been detected 2026-06-16 14:23:16.891 - The sound has disappeared 2026-06-16 14:23:18.127 - The sound has been detected 2026-06-16 14:23:19.004 - The sound has disappeared 2026-06-16 14:23:21.556 - The sound has been detected 2026-06-16 14:23:22.332 - The sound has disappeared
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

If the LED indicator stays constantly on or off even when sound is present, rotate the potentiometer to adjust the sound sensitivity threshold until the sensor responds correctly.

Now you can customize the code to trigger actions when sound is detected - activate an LED, control a relay to switch lights, or rotate a servo motor in response to sound. Check the application ideas and challenge sections below for inspiration.

Application and Project Ideas

The ESP32 S3's wireless capabilities and processing power open up a wide range of sound-activated applications beyond simple detection.

  1. Clap-activated switch: Build a clap-activated light switch using a relay module
  2. Sound-level meter: Create a sound-level meter display with an LED bar graph
  3. Knock detection lock: Design a knock-detection door lock system
  4. Pet feeder: Make a sound-triggered pet feeder or treat dispenser
  5. Noise monitor: Build a noise monitoring system for quiet zones
  6. Voice alert system: Create a voice-activated notification system with buzzer alerts

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenge Yourself

These challenges let you progressively extend your ESP32 S3 sound sensor project from simple LED feedback to sophisticated pattern recognition.

  1. Beginner: Add an LED that lights up when sound is detected and turns off when quiet
  2. Beginner: Display the sound state on an LCD screen instead of Serial Monitor
  3. Intermediate: Create a clap counter that counts the number of claps detected within a time window
  4. Intermediate: Combine the sound sensor with a relay to build a clap-activated lamp
  5. Advanced: Build a sound pattern recognition system that responds to specific clap sequences (e.g., double-clap vs triple-clap)

Troubleshooting

If your ESP32 S3 sound sensor isn't working properly, try these solutions.

Common issues and fixes:

  • Reduce vibrations: Mount the sound sensor on a stable, vibration-free surface - mechanical vibrations and wind noise interfere with detection accuracy
  • Check sensing range: This sound sensor detects sound within approximately 10 inches - move closer to the sensor when testing
  • Verify power supply: Ensure clean, noise-free power - the sound sensor's analog components are sensitive to power supply interference
  • Adjust sensitivity: Rotate the potentiometer while testing until the sensor responds appropriately to your sound level
  • Check wiring: Verify all connections match the wiring diagram - loose or incorrect connections cause erratic behavior
  • Test LED indicators: Power LED should be on constantly; status LED should blink when sound is detected

Function References

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!