Passive buzzer
piezo speaker
A small speaker that plays whatever frequency you give it. Use it for alarms, melodies, button feedback.
Open the course →How it works
A passive buzzer is just a piezo element — it vibrates at the frequency of the signal it receives. The ESP32 produces a square wave with ledcWriteTone(pin, 1000) → you hear 1 kHz. An active buzzer has its own oscillator and beeps at one tone as soon as it gets voltage (with digitalWrite HIGH). Tell them apart: the active one has a sticker on top and a longer leg marked +.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| + (S) | Signal / positive | → GPIO (PWM) pin. Optionally through 100 Ω for a quieter sound. |
| − | Ground | → GND. |
Specifications
Voltage3 – 5 V
Current< 30 mA
Resonant frequency~2 kHz (loudest)
Range100 Hz – 10 kHz
Tips and typical mistakes
- A passive buzzer with digitalWrite(HIGH) only "clicks" — it needs a tone (PWM).
- For a melody: each note is a frequency (C4 = 262 Hz, A4 = 440 Hz).