A 12V active buzzer puts out a lot more sound than the usual 5V piezo, which makes it a good fit for alarms and notifications you actually want people to notice. Since the ESP32 S3 only outputs 3.3V logic, you can't drive the buzzer directly — you need a relay in between acting as a switch. This tutorial covers the wiring and a minimal sketch that beeps the buzzer on a fixed interval.
The full tutorial, with every detail and the line-by-line code explanation, is on our site: ESP32 S3 - Buzzer
What you need
- ESP32 S3 WROOM N16R8
- ESP32 S3 SuperMini Dev Module
- ESP32 S3 Uno-form Board
- ESP32 S3 Camera Board
- USB Cable Type-A to Type-C (for USB-A PC)
- USB Cable Type-C to Type-C (for USB-C PC)
- Relay
- 12V Active Buzzer
- DC Power Jack
- Breadboard
- Jumper Wires
- Screw Terminal Expansion Board for ESP32 S3
- Breakout Expansion Board for ESP32 S3
- Power Splitter for ESP32 S3
- DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
- DIYables Sensor Kit (18 sensors/displays)
Wiring
The buzzer has two leads: the black negative lead goes to GND on the 12V power supply, and the red positive lead goes to the 12V positive rail, switched through the relay. The ESP32 S3 drives the relay coil from GPIO 2, and the relay's output contacts handle the actual 12V connection to the buzzer. Keep the 12V wiring on one side of the breadboard and the ESP32 S3 signal wires on the other to cut down on interference, and double check the power supply polarity before turning it on since reversed polarity can damage the buzzer.
How it works
An active buzzer has a built-in oscillator, so it makes sound the instant it gets power — there's no need to generate a tone signal from code like with a passive buzzer. Because it needs 12V and the ESP32 S3 can only supply 3.3V, the relay sits between them: the ESP32 S3 toggles the relay coil with a digital pin, and the relay mechanically connects or disconnects the 12V supply to the buzzer. This also keeps the microcontroller electrically isolated from the higher-voltage circuit.
Code
The sketch sets GPIO 2 as an output with pinMode(), then in loop() calls digitalWrite(RELAY_PIN, HIGH) to energize the relay and connect 12V to the buzzer, waits 1 second with delay(), then calls digitalWrite(RELAY_PIN, LOW) to release the relay and silence the buzzer for 2 seconds. This repeats forever, giving a simple alarm-style beep pattern you can adjust by changing the delay() values.
esp32-s3-buzzer.ino
/* * 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-buzzer */ #define RELAY_PIN 2 // The Arduino Nano ESP32 that connects to relay to control the 12V buzzer // The setup function runs once on reset or power-up void setup() { // initialize digital pin as an output. pinMode(RELAY_PIN, OUTPUT); } void loop() { digitalWrite(RELAY_PIN, HIGH); delay(1000); digitalWrite(RELAY_PIN, LOW); delay(2000); } Things that go wrong
If nothing happens, check the relay's onboard LED — it should blink in sync with the beep pattern, which confirms the relay is switching even if you can't hear the buzzer yet. If the LED blinks but there's no sound, recheck the buzzer's polarity and the 12V supply connection. Keep the 12V wiring routed away from the ESP32 S3 signal lines, since noise from the higher-voltage side can cause erratic behavior on the microcontroller.
Full tutorial
The complete tutorial - wiring diagram, code explanation and troubleshooting - is here: https://newbiely.com/tutorials/esp32-s3/esp32-s3-buzzer
