Active Buzzer with a Raspberry Pi Pico
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.

On the Raspberry Pi Pico the page drives the active buzzer straight from GP0, plus to the pin and minus to GND, switching it with digitalWrite(). It sounds, but a 3.3 V RP2040 pin is a weak source for a buzzer rated 5 V and up to 30 mA, so expect it quieter than on a 5 V board; the page's warning moves it behind an NPN transistor such as a 2N2222.
Wiring the Active Buzzer to the Raspberry Pi Pico
Pin by pin.
| Active Buzzer | Raspberry Pi Pico |
|---|---|
| plus | GP0 |
| minus | GND |
- Typical 5 V active buzzers are rated up to about 30 mA. An RP2040 pin drives 4 mA by default and 12 mA at most, so drive the buzzer through an NPN transistor such as a 2N2222: GP0 to the base through 1 kΩ, the buzzer from VBUS to the collector, the emitter to GND.
What to know on the Raspberry Pi Pico
- The buzzer operates from 3 V to 7 V and draws up to 30 mA. An RP2040 pin's drive strength is 2, 4, 8 or 12 mA, 4 mA by default, so GP0 cannot hold 3.3 V at that current and the tone is quieter.Jiangsu Huawha TMB12A05 specification, p. 2; RP2040 datasheet, section 2.19.4
- For full volume, put plus on VBUS (5 V on USB) and switch minus to ground through an NPN transistor such as a 2N2222, its base driven from GP0 through 1 kΩ. Never switch plus with a PNP from a 3.3 V pin: the pin cannot turn it off.Raspberry Pi Pico datasheet, release 21, p. 8
- The pitch is fixed by the buzzer's own oscillator at 2400 ± 300 Hz, so tone() and PWM add nothing; HIGH beeps, LOW stops.Jiangsu Huawha TMB12A05 specification, p. 2
Active Buzzer code for the Raspberry Pi Pico
Compiled for rp2040:rp2040:rpipico on 2026-10-29.
// Active Buzzer on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/buzzer-active/raspberry-pi-pico
// Active buzzer on a digital pin (or the transistor's base pin): HIGH beeps.
const int BUZZER = 0;
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 Raspberry Pi Pico: questions
Can a Raspberry Pi Pico drive an active buzzer directly?
It sounds, since the buzzer works from 3 V (TMB12A05 specification, p. 2), but it can draw 30 mA while an RP2040 pin is set for 4 mA by default and 12 mA at most (RP2040 datasheet, section 2.19.4). For full volume use an NPN transistor and 5 V.
Why is my buzzer so quiet on the Pico?
The pin sags under the buzzer's current and 3.3 V is below its rated 5 V. Switch it through an NPN from VBUS on USB.
Can I play melodies on this buzzer with the Pico?
No. An active buzzer has a fixed tone near 2400 Hz (TMB12A05 specification, p. 2). Use a passive piezo for tone().
Keep going
This guide as plain Markdown. /components/buzzer-active/raspberry-pi-pico.md