The transistor and the diode
Your pin never carries the buzzer's current. It pushes about 2.5 mA into an S8050's base through 1 kΩ, and the transistor switches up to 95 mA of coil current from VCC. When it lets go, the coil keeps pushing for a moment, and the SS14 across it gives that current a loop.
A switch in the ground wire
The buzzer's + pad is on VCC. Its other pad goes to the transistor's collector, and the transistor's emitter goes to GND. So the transistor is a switch in the buzzer's ground wire: on, current flows from VCC through the coil to GND; off, it cannot.
Your pin drives the switch, not the buzzer. A HIGH from an ESP32-S3 pushes about 2.5 mA through the 1 kΩ into the transistor's base; from an Uno's 5 V pin, about 4.2 mA. The transistor passes up to a few hundred times its base current, and the buzzer needs at most 95 mA, so it switches fully on. Fully on matters: a transistor half on wastes power as heat and gives the buzzer less than VCC.
The coil's current comes from VCC. On 3V3 that is your board's 3.3 V supply; on 5V, the USB supply.
The diode
A coil stores energy while current flows in it and gives it back when the current is interrupted. Switch the transistor off and the coil tries to keep its current flowing; with nowhere to go, the voltage at the collector would jump far above VCC, on every cycle, thousands of times a second.
The SS14 across the buzzer gives it somewhere to go. It points from the collector back up to VCC, so it does nothing while the transistor is on, and the moment it turns off the coil's current runs round through the diode and dies away. The transistor, rated 25 V, sees VCC plus a few tenths of a volt. The buzzer's own datasheet draws a diode in the same place in its recommended circuit.
The LED rides along
The LED and its 1 kΩ run from VCC to the collector, beside the buzzer. It lights whenever the transistor is on, with about 1.2 mA from 3V3 and about 3 mA from 5V, worked out for a red LED rather than measured. Its current does not go through the coil, so a lit LED says the transistor switched, not that the buzzer worked.
Nothing holds the base down
There is no resistor from the base to GND. When SIGNAL is driven, LOW or HIGH, that does not matter. When the wire is unplugged, or the pin has not been set up yet, the base floats and the transistor stays off by itself in almost every case; a long loose wire can occasionally pick up enough to tick.
When it does not work
Yes, with room to spare. About 2.5 mA goes into the base from a 3.3 V pin. The S8050 on this board has a current gain of 200 to 350, so that base current could hold on around 500 mA, and the buzzer needs at most 95 mA. The buzzer's datasheet asks for a transistor driven hard enough to saturate, and this one is.
There is no resistor from the transistor's base to GND on this board, so an unconnected SIGNAL is left floating. Normally the transistor stays off, but a loose wire with nothing driving it can pick up enough to tick. Once the sketch has set the pin up, the pin holds it firmly.
It switches on thousands of times a second, once per cycle of the tone, and a Schottky diode turns on and off faster and with a smaller drop than an ordinary one. The designer's note on the schematic insists on it. The fitted SS14 is rated 40 V and 1 A.
No. VCC reaches the buzzer, the diode and the LED's resistor, all on the collector side. SIGNAL only reaches the base through 1 kΩ, and the base never sits more than about a volt above GND. A 3.3 V pin is safe with 5V on VCC.
Frequency is pitch, and 2.7 kHz is where this buzzer is loudest.
Pitch, and where it is loudest →Edit this page — content/books/passive-buzzer/the-transistor-and-the-diode.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Passive Buzzer
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.