Active Buzzer with an ESP32 DevKit V1

A 12 mm magnetic buzzer with its own oscillator: give it DC and it beeps one fixed 2.4 kHz tone, no code tricks needed.

Active Buzzer, A 12 mm magnetic buzzer with its own oscillator: give it DC and it beeps one fixed 2.4 kHz tone, no code tricks needed.
In short

The active buzzer's + lead goes straight to GPIO13 on the ESP32 DevKit V1 and its - lead to GND, and digitalWrite(HIGH) makes it beep at its own fixed pitch. At 3.3 V it runs inside its 3 V to 7 V operating range but below its 5 V rating, so it is quieter than on a 5 V board.

Wiring the Active Buzzer to the ESP32 DevKit V1

Pin by pin.

Active BuzzerESP32 DevKit V1
plusGPIO13 (D13)
minusGND

What to know on the ESP32 DevKit V1

  • The buzzer draws up to 30 mA. An ESP32 pin sources about 40 mA at full drive with VOH at 2.64 V or more, and less, down to about 29 mA, when several pins in the same power domain source current together, so one buzzer on GPIO13 is near the pin's limit.Jiangsu Huawha TMB12A05 specification, p. 2; Espressif ESP32 Series Datasheet v5.3, p. 52
  • For the full 5 V volume, switch the buzzer's - lead with an NPN transistor from GPIO13 and feed + from VIN. Do not use a PNP on its +: a 3.3 V pin cannot turn a 5 V PNP fully off, and the buzzer never stops.ESP32 Series Datasheet v5.3, p. 52 (output high level 0.8 x VDD)
  • GPIO13 is not a strapping pin, so the buzzer cannot change the boot mode. Keep it off GPIO2 and GPIO12: the ESP32 samples both at reset, and GPIO12 high selects a 1.8 V flash supply.Espressif ESP32 Series Datasheet v5.3, p. 22; Espressif ESP32-WROOM-32 Datasheet v3.8, p. 13

Active Buzzer code for the ESP32 DevKit V1

Compiled for esp32:esp32:esp32 on 2026-10-29.

No library needed
// Active Buzzer on ESP32 DevKit V1: wiring and a free simulation at https://www.tinkered.ai/components/buzzer-active/esp32
// Active buzzer on a digital pin (or the transistor's base pin): HIGH beeps.
const int BUZZER = 13;

void beep(int ms) {
  digitalWrite(BUZZER, HIGH);
  delay(ms);
  digitalWrite(BUZZER, LOW);
}

void setup() {
  pinMode(BUZZER, OUTPUT);
}

void loop() {
  beep(100); delay(100);   // two short beeps
  beep(100); delay(800);
  beep(600); delay(1400);  // one long
}

Active Buzzer on the ESP32 DevKit V1: questions

Can I use tone() with an active buzzer on the ESP32?

No need: the active buzzer has its own oscillator at 2400 ± 300 Hz (Huawha specification, p. 2), so tone() does not change its pitch. Use a passive piezo for notes; on the ESP32 its tone() runs on the LEDC PWM peripheral.

Why is my buzzer quiet on the ESP32?

Its rated voltage is 5 V and the GPIO gives 3.3 V (Huawha specification, p. 2). Drive it through an NPN transistor from VIN for full volume.

Keep going

For AI assistants

This guide as plain Markdown. /components/buzzer-active/esp32.md

What will you build with it?