ESP32 C3 Super Mini - Buzzer

Learn how to program your ESP32 C3 Super Mini to control a 12V active buzzer and generate loud, attention-grabbing sounds perfect for alarms and notifications. This beginner-friendly tutorial walks you through everything you need to create a working buzzer project.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - Buzzer

Note: If you want to control 5V active/passive buzzer, check out this ESP32 C3 Super Mini Piezo Buzzer tutorial

There are two ways to drive the 12V buzzer. A relay is simple, but it clicks every time it switches. A MOSFET module does the same job with no sound, and it can switch very fast. This is good for alarm beeps. We will try both ways in this tutorial.

Hardware Preparation

1×ESP32 C3 Super Mini
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×Alternatively, MOSFET Module (AOD4184, LR7843 or FR120N)
1×12V Active Buzzer
1×12V Power Adapter
1×Optionally, DC Power Jack
1×Breadboard
1×Jumper Wires

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 12V Active Buzzer

The 12V Active Buzzer is an electronic buzzer that produces a loud, high-decibel sound suitable for alarm systems and attention alerts.

Key features:

  • Operates at 12V DC power supply
  • Produces loud sound (much louder than standard 5V buzzers)
  • "Active" means it has built-in oscillator - just apply power to make sound
  • Perfect for security alarms, notification systems, and warning signals
  • Requires external power supply (cannot be powered directly by ESP32)
  • Must be controlled through a relay module for safe operation

Why use a 12V buzzer?

  • Significantly louder than 5V buzzers
  • Better for outdoor or noisy environments
  • Ideal for alarm and alert systems where sound needs to carry

Pinout

The 12V Active Buzzer pinout is simple with only two connection points.

ESP32 C3 Super Mini 12V Active Buzzer Pinout
  • Negative (-) pin (black): Connect to GND of 12V DC power supply
  • Positive (+) pin (red): Connect to 12V positive of DC power supply

How to Control 12V Active Buzzer

The ESP32 C3 Super Mini outputs only 3.3V, which is not enough to power a 12V buzzer directly.

Control method:

  • Use a relay module as a switch between ESP32 and the buzzer
  • ESP32 C3 Super Mini controls the relay with a digital pin
  • Relay switches the 12V power supply to the buzzer ON or OFF
  • This keeps your ESP32 safe while controlling high-voltage devices

Important: If you're new to relays, check out the ESP32 C3 Super Mini - Relay tutorial to understand pinout, operation, and programming basics.

The MOSFET module is the second choice. The pins, the inside and the code of the module are explained in the ESP32 C3 Super Mini - MOSFET Module tutorial.

Relay vs MOSFET Module for a 12V Buzzer

Relay MOSFET Module
What it can do turn the buzzer on or off turn the buzzer on or off
Noise when switching a click every time, mixed with the beep no sound, you hear only the beep
How fast it switches slow, a few milliseconds very fast
Fast beeps the relay clicks loudly and wears out fast no problem
Life the contacts wear out after many switches nothing moves, so it lasts long
Type of power AC or DC DC only
Buzzer power supply any voltage the relay is rated for about 6V or more
Isolation from the ESP32 C3 Super Mini yes, between coil and contacts yes, by the PC817 optocoupler
Good for slow ON/OFF, like ON for a few seconds alarm patterns with many short beeps

If the buzzer beeps slowly, the relay is fine. If you want an alarm with many short beeps, the MOSFET module is the better pick.

Wiring Diagram

Follow this wiring diagram to connect your ESP32 C3 Super Mini to the 12V active buzzer through a relay module.

The wiring diagram between ESP32 C3 Super Mini 12V Active Buzzer

This image is created using Fritzing. Click to enlarge image

The diagram below shows the same connections without a breadboard:

The wiring diagram between ESP32 C3 Super Mini 12V Active Buzzer  (No Breadboard)

This image is created using Fritzing. Click to enlarge image

Safety notes:

  • Note: Double-check 12V power supply polarity before connecting - reversed polarity can damage the buzzer
  • Note: Keep 12V wiring separate from ESP32 signal wires to avoid electrical interference
Component Pin Connection Point
ESP32 Pin 2 Relay Signal Pin (IN)
ESP32 GND Relay GND
ESP32 5V Relay VCC
Relay COM 12V Power Supply (+)
Relay NO Buzzer (+) Red Wire
Buzzer (-) Black Wire 12V Power Supply GND (-)

ESP32 C3 Super Mini Code

Here's the code to control your 12V active buzzer - it turns the buzzer ON for 1 second, then OFF for 2 seconds in a repeating pattern.

What this code does:

  • Sets up GPIO pin 2 to control the relay
  • Turns the buzzer ON for 1 second (relay activated)
  • Turns the buzzer OFF for 2 seconds (relay deactivated)
  • Repeats the pattern continuously for alarm-like beeping
  • Uses simple digitalWrite commands for easy customization
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-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); }

Detailed Instructions

  • New to Arduino? Start with our ESP32 C3 Super Mini Getting Started guide first.
  • Setup environment: If this is your first time using ESP32 C3 Super Mini, follow the Arduino IDE setup guide
  • Connect hardware: Wire the ESP32 C3 Super Mini, relay, buzzer, and 12V power supply according to the wiring diagram above
  • Connect to PC: Plug your ESP32 C3 Super Mini into your computer using the USB Type-C cable
  • Open Arduino IDE: Launch the Arduino IDE and select the correct board and port
  • Upload code: Copy the code above, paste it into Arduino IDE, and click the Upload button
  • Test buzzer: Listen for the buzzer to beep ON for 1 second, OFF for 2 seconds repeatedly
  • Verify operation: The relay LED should also blink in sync with the buzzer sound
  • Pro Tip: Adjust the delay() values in the code to create different beep patterns - shorter delays make rapid alarm sounds, longer delays create slow warning beeps

Code Explanation

The code comments explain each line in detail - read through them to understand how the buzzer control works!

Key functions used:

  • pinMode() - Configures GPIO pin 2 as an output to control the relay
  • digitalWrite(HIGH) - Activates relay, connecting 12V to buzzer (sound ON)
  • digitalWrite(LOW) - Deactivates relay, disconnecting power (sound OFF)
  • delay() - Pauses program execution to control timing

Applications and Project Ideas

Use your ESP32 C3 Super Mini 12V active buzzer setup in these practical projects:

  • Security alarm system: Trigger loud alerts when motion sensors detect intrusion
  • Timer notifications: Create kitchen timers or workout interval buzzers
  • Door/window alerts: Sound alarm when doors or windows open unexpectedly
  • Water leak detector: Connect with moisture sensor to alert for leaks
  • Temperature warnings: Pair with temperature sensor for overheat alarms
  • Reminder system: Build medication or appointment reminder device
  • IoT alarm system: Combine with WiFi to create remote-controlled security alerts

How to Make Alarm Beeps with MOSFET Module

Now let's replace the relay with a MOSFET module. The buzzer works the same, but there is no click, so it can beep fast like a real alarm.

Wiring Diagram

The wiring diagram between ESP32 C3 Super Mini 12V active buzzer MOSFET module

This image is created using Fritzing. Click to enlarge image

From To
ESP32 C3 Super Mini GPIO4 MOSFET module PWM
ESP32 C3 Super Mini GND MOSFET module GND
12V adapter + MOSFET module +
Buzzer red wire (+) MOSFET module + (same terminal as the adapter +)
Buzzer black wire (−) MOSFET module LOAD
12V adapter − MOSFET module −

The 3.3V signal of the ESP32 C3 Super Mini is enough, because the LED in the optocoupler needs only a small current.

Most 12V active buzzers have a small circuit inside and do not need a flyback diode. If your buzzer is a magnetic type (it has a coil inside), add a 1N4007 or 1N5819 diode across it. The side with the stripe (cathode) goes to the buzzer +, the other side goes to the buzzer −.

ESP32 C3 Super Mini Code

/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-buzzer */ const int MOSFET_PIN = 4; // ESP32 C3 Super Mini GPIO4 connected to the PWM pin of the MOSFET module void setup() { Serial.begin(9600); pinMode(MOSFET_PIN, OUTPUT); digitalWrite(MOSFET_PIN, LOW); // start with the buzzer OFF } void loop() { // fast alarm beeps: 10 short beeps Serial.println("Alarm: fast beeps"); for (int i = 0; i < 10; i++) { digitalWrite(MOSFET_PIN, HIGH); // turn on buzzer delay(100); digitalWrite(MOSFET_PIN, LOW); // turn off buzzer delay(100); } // one long beep Serial.println("Alarm: long beep"); digitalWrite(MOSFET_PIN, HIGH); delay(1000); digitalWrite(MOSFET_PIN, LOW); // quiet time Serial.println("Quiet"); delay(3000); }

What the buzzer does: it beeps 10 times fast, then makes one long beep, then stays quiet for 3 seconds. Then it starts again.

An active buzzer makes its own sound. Only turn it fully ON or fully OFF with digitalWrite(). Do not use analogWrite() (PWM) to change the volume, because the sound will be weak or strange.

Detailed Instructions

  • Do the same setup as in the Quick Steps steps of the relay part above.
  • Wire the buzzer and the MOSFET module as shown in the diagram. Keep the 12V adapter unplugged.
  • Upload the code above to the ESP32 C3 Super Mini.
  • Plug in the 12V adapter.
  • Open the Serial Monitor at 9600 baud.
  • Listen to the buzzer: you hear the fast beeps with no relay click.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Alarm: fast beeps Alarm: long beep Quiet Alarm: fast beeps Alarm: long beep Quiet
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

※ NOTE THAT:

The MOSFET module works with DC only, and the buzzer power supply must be about 6V or more. For a 5V buzzer, see the ESP32 C3 Super Mini Piezo Buzzer tutorial. For an AC buzzer or siren, use the relay.

Video Tutorial

Watch the video below for a visual walkthrough of this project.

Challenge Yourself

Take your buzzer project to the next level with these challenges:

  • Easy: Modify the code to create an SOS pattern (3 short beeps, 3 long beeps, 3 short beeps)
  • Easy: Add a button to manually trigger the buzzer ON/OFF
  • Medium: Create a melody by programming different beep durations and pauses
  • Medium: Use a motion sensor to trigger the alarm only when movement is detected
  • Advanced: Build a smartphone-controlled alarm using ESP32 WiFi and Blynk app
  • Advanced: Create a multi-zone alarm system with multiple buzzers controlled independently

※ 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!