ESP32 S3 UNO - Buzzer
This ESP32 S3 Uno buzzer tutorial shows you how to make a loud 12V active buzzer beep with the ESP32 S3 Uno form board and a relay. The board cannot power a 12V buzzer by itself, so a relay does the switching while your code decides when the alarm sounds. If you want to use a small 5V active or passive buzzer instead, see the ESP32 S3 Uno Piezo Buzzer tutorial.
In this tutorial, you will:
- Learn how a 12V active buzzer works and why it needs a relay
- Wire the relay, the 12V power adapter and the buzzer to the ESP32 S3 Uno
- Write Arduino code that turns the loud buzzer on and off
- Upload the code with the Arduino IDE and test your alarm

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 | × | Relay | |
| 1 | × | 12V Active Buzzer | |
| 1 | × | 12V Power Adapter | |
| 1 | × | DC Power Jack | |
| 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 12V Active Buzzer
A 12V active buzzer is much louder than the tiny buzzers you often find in starter kits. That makes it a good choice for alarms, warning signals and doorbells that people must hear from another room.
"Active" means the buzzer has its own oscillator inside. You do not need to send a tone or a PWM signal. Give it 12V and it beeps; take the 12V away and it stops.
Pinout

Most 12V active buzzers have just two wires, so the wiring is easy.
Negative (-) pin
This is usually the black wire. Connect it to the GND (minus) of the 12V DC power supply.
Positive (+) pin
This is usually the red wire. Connect it to the 12V (plus) of the DC power supply, through the relay in this project.
How to Control 12V Active Buzzer
The ESP32 S3 Uno works with 3.3V logic, and its pins give only a small current. A 12V buzzer needs a higher voltage and more current, so you can never connect it straight to a GPIO pin.
A relay solves this problem. The ESP32 S3 Uno drives the relay's input pin, and the relay's contacts open or close the 12V circuit of the buzzer. When the relay closes, the buzzer gets 12V and sounds. When it opens, the buzzer goes quiet.
If you have not used a relay before, read the ESP32 S3 Uno relay tutorial to learn about its pinout and how to program it.
ESP32 S3 Uno Pinout
The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the Uno header pin D3 and its GPIO number when you wire the relay.

Wiring Diagram
The ESP32 S3 Uno controls the relay, and the relay switches the 12V power to the buzzer. Keep the 12V circuit fully separate from the board's pins.

This image is created using Fritzing. Click to enlarge image
Relay to ESP32 S3 Uno
| Relay Pin | ESP32 S3 Uno Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | D3 (GPIO17) |
12V circuit
| From | To |
|---|---|
| 12V power adapter (+) | Relay COM |
| Relay NO | Buzzer positive (+) red wire |
| Buzzer negative (-) black wire | 12V power adapter (-) |
WARNING
Never connect the 12V supply to any ESP32 S3 Uno pin. The ESP32 S3 Uno pins work at 3.3V and are NOT 5V tolerant, so 12V will destroy the board at once. Only the relay contacts (COM and NO) should touch the 12V circuit.
※ NOTE THAT:
Most 5V relay modules switch fine with the 3.3V signal from the ESP32 S3 Uno. If your relay clicks weakly or does not switch at all, use a relay module that accepts a 3.3V input signal.
ESP32 S3 Uno Code
The sketch below turns the 12V buzzer on for two seconds, then off for five seconds, and repeats this forever. It only sets the relay pin HIGH or LOW, because the active buzzer makes its own sound.
Detailed Instructions
Follow these steps one by one:
- 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 the Arduino IDE.
- Upload the code by clicking the Upload button.
- Plug in the 12V adapter and listen: the buzzer beeps for 2 seconds, then stays quiet for 5 seconds.
- Tip: The relay clicks each time it switches. If you hear the click but no beep, check the 12V side of the wiring.
Code Explanation
The code is short, and the comments inside it explain each line. In setup(), GPIO17 (D3) becomes an output. In loop(), digitalWrite() sets the pin HIGH to close the relay and start the buzzer, and LOW to open the relay and stop it. The two delay() calls set how long the sound is on and off.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
FAQ
Can I connect a 12V buzzer directly to the ESP32 S3 Uno?
No. The ESP32 S3 Uno pins give only 3.3V and a small current, and they are not 5V tolerant. A 12V buzzer needs its own power supply, so you must switch it with a relay or a transistor (MOSFET) circuit.
Which ESP32 S3 Uno pin should I use for the relay?
This tutorial uses D3, which is GPIO17 on the ESP32 S3 Uno. In code you write the GPIO number, so the line is #define RELAY_PIN 17. You can use another free digital pin, but avoid D0 and D1 (USB serial) and the boot strapping pins D6 (GPIO3) and D9 (GPIO46).
Will a 5V relay module work with the 3.3V ESP32 S3 Uno?
Most 5V relay modules work, because their input board accepts 3.3V as HIGH. Power the module from the 5V pin and drive IN from the GPIO. If the relay does not switch reliably, choose a module rated for a 3.3V trigger.
Can I play different tones with a 12V active buzzer?
No. An active buzzer has a fixed tone made by its built-in oscillator, and the relay can only turn it on or off. For melodies, use a passive piezo buzzer with the tone() function, as shown in the ESP32 S3 Uno Piezo Buzzer tutorial.
Is the code different from the UNO R4 version?
The logic is the same. Only the pin number changes: D3 on the ESP32 S3 Uno is GPIO17, so the code uses 17 instead of 3. In the Arduino IDE you also select the ESP32S3 Dev Module board instead of an UNO R4 board.
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 (I/O, PWM, analog), GPIO45 and GPIO35 to GPIO42 (I/O, PWM), and GPIO47/GPIO48 (output only, PWM). Solder pin headers to them and write the GPIO number in code. For extra relays or buzzers, GPIO35 to GPIO42 are a good first choice. Be careful with two groups: 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. 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 appears in the Arduino IDE | Missing USB driver or a charge-only cable | Install the CP210x or CH340 driver, use a data USB cable, or hold BOOT while you press RESET |
| Upload fails or the board does not start | Board in the wrong mode or wrong board selected | Select ESP32S3 Dev Module, hold BOOT while you press RESET, then upload again |
| Relay clicks but the buzzer is silent | 12V circuit wired wrong or adapter not plugged in | Check that 12V (+) goes to COM, NO goes to the buzzer (+), and the buzzer (-) goes to the adapter (-) |
| Relay does not click at all | Relay not powered or IN on the wrong pin | Power the relay from 5V and GND, and connect IN to D3 (GPIO17) |
| Buzzer sounds all the time | Buzzer wired to NC instead of NO, or relay is active-low | Move the wire from NC to NO, or swap HIGH and LOW in the code |
| Buzzer is very quiet | Supply voltage too low | Use a real 12V adapter that can give enough current |
| Board resets when the relay switches | Power dip from the relay coil | Power the board from a stable USB port and keep the 12V wires away from the board |