ESP32 S3 UNO - Sound Sensor
This ESP32 S3 Uno sound sensor tutorial shows you how to detect sound, such as a clap or a loud noise, with the ESP32 S3 Uno form board and Arduino code. You use a simple sound detector module and see a message on the Serial Monitor each time a sound starts and stops.
In this tutorial, you will:
- Compare the digital and analog sound detector modules
- Wire a sound sensor to the ESP32 S3 Uno safely at 3.3V
- Write Arduino code that detects when a sound starts and stops
- Adjust the sound sensor sensitivity with its potentiometer

Once it works, you can change the code to switch on an LED, turn on a lamp through a relay, or move a servo motor when a sound is heard.
Hardware Preparation
| 1 | × | ESP32 S3 Uno-form Board | |
| 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 | × | Jumper Wires |
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Sound Sensor
A sound sensor listens to the noise around it and tells your board when the sound gets loud enough. Knowing which type of module you have helps you pick the right pin and the right code.
You can buy two kinds of sound sensor modules. The digital module only gives an ON or OFF signal. The analog module gives the same ON or OFF signal, and it also gives a changing voltage that follows the sound level. On both modules, a small potentiometer sets how loud a sound must be before the digital output changes.
The Digital Sound Sensor Pinout
The digital module is the simplest one to use. It has only three pins.
VCC pin
Connect it to a supply between 3.3V and 5V. With the ESP32 S3 Uno, use the 3.3V pin.
GND pin
Connect it to GND (0V).
OUT pin
This is the output pin. It stays HIGH when the room is quiet and goes LOW when the sensor hears a sound. Connect it to a digital input pin on the ESP32 S3 Uno.

The board also has a potentiometer to set the sensitivity, and two small LEDs. One LED shows that the module has power. The other LED turns on while a sound is present and turns off when it is quiet.
The Analog Sound Sensor Pinout
The analog module has one extra pin, so you can read how loud the sound is, not only whether there is a sound.
+ pin
The power pin. The module works from 5V, but with the ESP32 S3 Uno it is safer to power it from 3.3V so its outputs never go above 3.3V.
G pin
Connect it to GND (0V).
DO pin
The digital output. It is HIGH when it is quiet and LOW when a sound is detected. Connect it to a digital input pin on the ESP32 S3 Uno.
AO pin
The analog output. Its voltage follows the sound level. Connect it to an analog input pin on the ESP32 S3 Uno, such as A0 (GPIO2). The ESP32 S3 Uno reads it with a 12-bit ADC, so analogRead() returns a value from 0 to 4095.

Like the digital module, it has a potentiometer that sets the sensitivity of the digital output. It also has a power LED and a sound LED that lights up while a sound is heard.
How It Works
The logic of the sensor is inverted, which surprises many beginners. Once you know this, the code is easy to read.
The potentiometer sets a threshold. When the sound is louder than this threshold, the output pin goes LOW. When the sound is quieter than the threshold, the output pin stays HIGH. So in your code, LOW means "sound" and HIGH means "quiet".
ESP32 S3 Uno Pinout
The image below shows the pinout diagram of the ESP32 S3 Uno form board. Use it to find the Uno header pins (D2, A0, SDA…) and their GPIO numbers when you wire the circuit.

Wiring Diagram
Connect the sound sensor's OUT pin to the D8 header of the ESP32 S3 Uno, and power the module from the 3.3V pin.

This image is created using Fritzing. Click to enlarge image
| Sound Sensor Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| OUT | D8 (GPIO21) |
WARNING
The ESP32 S3 Uno GPIO pins are NOT 5V tolerant. If you power the sound sensor from 5V, its OUT pin also outputs 5V, which can damage GPIO21. Power the sensor from 3.3V, or put a voltage divider (for example 10kΩ and 20kΩ) between the OUT pin and the ESP32 S3 Uno pin.
How To Program For Sound Sensor
Reading a digital sound sensor takes only two functions. You set the pin as an input once, then read it again and again.
- In setup(), set the ESP32 S3 Uno pin as a digital input with pinMode(). Here the pin is GPIO21, which is the D8 header.
- In loop(), read the pin state with digitalRead(). A LOW value means a sound is heard.
ESP32 S3 Uno Code - Detecting the sound
The sketch below reads the sensor on GPIO21 all the time and compares the new state with the last one. It prints a message only when the state changes, so you see one line when a sound starts and one line when it stops, instead of a flood of messages.
Detailed Instructions
Follow these steps in order:
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Copy the code above and paste it into Arduino IDE.
- Upload the code by clicking the Upload button.
- Open the Serial Monitor and set the baud rate to 9600.
- Clap your hands close to the sound sensor.
- Check the result on the Serial Monitor.
- Tip: If the sound LED on the module is always on, or never turns on even when you clap, turn the potentiometer slowly with a small screwdriver until the LED is off in silence and turns on when you clap.
Tips to Improve Sound Detection
A sound sensor is a small analog circuit, so it is sensitive to its surroundings. These tips help you get steady and reliable results.
Adjust the sensitivity
Turn the potentiometer to set how loud a sound must be to trigger the output. Small turns make a big difference.
Reduce vibrations
The microphone also picks up vibration and wind. Fix the module to a solid surface so that bumps on the table do not count as sounds.
Stay within the sensing range
This sensor only hears sounds up to about 10 inches (25 cm) away. Make your test sounds close to it.
Use a clean power supply
Noise on the power line can trigger the sensor by mistake. Use a stable supply and short wires.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
The demo in the video uses the code below. It counts your claps and plays a different light effect on eight LEDs: one clap blinks all LEDs, two claps run a water wave, three claps light from the inside out, and four claps make a random dance. The LEDs are active-LOW, so each LED turns on when its pin goes LOW.
| Part | ESP32 S3 Uno Pin |
|---|---|
| Sound sensor OUT | D10 (GPIO10) |
| LED 1 to LED 4 | D2 (GPIO18), D3 (GPIO17), D4 (GPIO19), D5 (GPIO20) |
| LED 5 to LED 8 | D6 (GPIO3), D7 (GPIO14), D8 (GPIO21), D9 (GPIO46) |
WARNING
This demo uses D6 (GPIO3) and D9 (GPIO46). Both are boot strapping pins on the ESP32 S3 Uno. The board reads them at power-up to choose its boot mode. If an LED circuit pulls one of them to the wrong level at startup, the board may not boot or may fail to upload code. If that happens, unplug the LED wires from D6 and D9, upload the code, then plug them back in.
Function References
FAQ
Can I power the sound sensor from 5V on the ESP32 S3 Uno?
The module itself works at 5V, but then its output pins also give 5V. ESP32 S3 Uno GPIO pins are not 5V tolerant, so a 5V signal can damage them. Power the sensor from the 3.3V pin, or use a voltage divider on the output.
What range does analogRead() give for the analog sound sensor on the ESP32 S3 Uno?
The ESP32 S3 Uno has a 12-bit ADC, so analogRead() returns 0 to 4095, not 0 to 1023 like on many Arduino boards. Connect AO to an analog header such as A0 (GPIO2) and use analogRead(2) in your code. Also add analogSetAttenuation(ADC_11db); in setup(). It sets the ADC range to about 0–3.3V, so the full sensor signal fits in 0 to 4095.
Why does my code print "detected" when the pin is LOW?
The sensor output is inverted. It is HIGH in silence and LOW when it hears a sound. That is why the code looks for a change from HIGH to LOW to detect the start of a sound.
Can the sound sensor recognize words or voices?
No. It only tells you that a sound is louder than the threshold you set. To recognize speech, you need a microphone module and a voice recognition module or library.
Which ESP32 S3 Uno pin should I use for the sound sensor?
Any normal digital pin works for the OUT or DO pin, such as D8 (GPIO21) in this tutorial. Avoid D0 and D1, which are used for USB serial, and avoid D6 (GPIO3) and D9 (GPIO46) if you can, because they are boot strapping pins.
What if my project needs more pins than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 support I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 support I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them and write the GPIO number in your code. For an extra analog sound sensor, use GPIO15 or GPIO16. For more digital sound sensors, use GPIO35 to GPIO42, and never GPIO47 or GPIO48 because they cannot be inputs. Keep two warnings in mind. First, GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port shows up in Arduino IDE | USB driver missing or board not in upload mode | Install the CP210x or CH340 driver, use a data USB cable, or hold BOOT while pressing RESET |
| Nothing prints on the Serial Monitor | Wrong baud rate | Set the Serial Monitor to 9600 baud |
| "detected" never prints when you clap | Sensitivity too low or OUT wire on the wrong pin | Turn the potentiometer and check that OUT goes to D8 (GPIO21) |
| Messages print all the time in silence | Sensitivity too high or power noise | Turn the potentiometer the other way and use short wires and a stable supply |
| Sensor works for a while then the GPIO stops responding | Sensor powered from 5V so OUT gives 5V to a 3.3V pin | Power the sensor from 3.3V or add a voltage divider |
| Power LED on the module is off | VCC or GND not connected | Check the 3.3V and GND wires |
| Board does not boot or upload with the demo wired | LEDs on strapping pins D6 (GPIO3) or D9 (GPIO46) | Unplug D6 and D9 while uploading, then reconnect |