Skip to content

Passive buzzer guide

Arik Yavilevich edited this page Jun 6, 2017 · 5 revisions

The Fochica devices communicates a lot of information to the user through sound. For this purpose it uses a buzzer, which is an audio signaling device that can generate beeps at various frequencies.

Passive vs active buzzer

There are two main types of buzzers for hobby use, active and passive. An active buzzer has additional circuitry in it which makes it easier to use but limits the buzzer to only making one type of a sound (tone). An active buzzer only requires DC power source for a beep to be generated.

A passive buzzer (AKA magnetic transducer) can make different tones, but the devices that controls the buzzer has to provide it with an oscillating electronic signal at a desired frequency. The supplied frequency will determine the tone. Supplying just a fixed voltage will generate no sound, except perhaps a slight "tick" at the point when the power source is connected or disconnected from the buzzer.

A passive buzzer is required for a Fochica build. The passive variant was selected because it allows to communicate a wider set of events through a variety of tones.

Controlling the buzzer by Arduino (driving the buzzer)

An Arduino can generate an oscillating signal as required by a passive buzzer. The signal can be emitted at one of the digital pins. However, an Arduino can only provide up to about 40mA of current on its pins. Because some buzzers can consume more than 40mA and because we would like our buzzer to be loud, we will want to operate our buzzer at higher currents than Arduino's max. For this purpose we will use a transistor. The signal from Arduino will connect to the base of the transistor through a resistor and will open/close it to allow higher current flow from the power source to power the buzzer.

You can risk it and drive your buzzer directly from an Arduino pin, but your Arduino pin might become damaged or your buzzer might not work at full volume. Decide on your own. You can always use a DMM to measure how much current your buzzer takes when it is driven through a transistor and compare it to Arduino's max current.

Popular buzzers are usually 16Ω and usually take about 100mA when making a sound. A transistor that can drive 0.5A will be sufficient to handle the buzzer. Therefore, the recommended components that will be needed for the sound emitting part of the device are:

  • A passive buzzer
  • A transistor capable of 0.5A or more (NPN preferred but PNP can also be used)
  • A 1kΩ resistor for the base of the transistor

Buying online

You can get just a passive buzzer component and wire it with a transistor and a resistor,

Passive buzzer

or you can get a ready-made module with all the components.

FC-49 YL-44

You would go for the individual components directly if you are building your own board or if you can get the parts or already have the parts (these are common). On the other hand, you would go for the module if you are a beginner and are building the device on a breadboard and don't want to mess with the individual components and their wiring.

When shopping online for the module, search for "passive buzzer module", otherwise when shopping for just the buzzer search for "passive buzzer". Note that buzzers, transistors and resistors are cheap components, so they are often sold at bulk for roughly the price of one piece.

Pay attention to the pins of the module. An example above features a module with the pins sticking only partially from the PCB. This may affect your ability to plug the module directly into a breadboard. Other modules may feature male pins sticking up which might or might not fit the way you are planning to assemble your build.

Mind that a buzzer on a PCB doesn't automatically mean that the module has a transistor! If you don't see the transistor on the photo (a small 3 pin SMD part in the images above) assume that this module is just a bare buzzer on a breakout board. This can be true even if the PCB has 3 pins.

KY-006

PNP vs NPN transistor

The oscillating signal that is generated for the buzzer changes from high to low at a high frequency. For a sound emitting state, it doesn't matter if you have a PNP or a NPN transistor. The type of the transistor does matter for the no-sound state, which is the state most of the time. Though the buzzer will make no sound if a constant current is flowing through it, it does create a waste of power and heats the buzzer since it functions as a resistor. For a proper build, the Arduino has to emit an idle signal that matches the type of the transistor so that the transistor doesn't conduct on idle. For a NPN transistor the Arduino has to emit LOW at idle and for a PNP transistor it has to emit HIGH.

You have to identify the type of the transistor used in your circuit. NPN is the default, so if you are using a PNP then you have to find and uncomment the line

#define BUZZER_PNP

in the main Fochica Arduino file. You can declare it in a persistent-like manner in a main-flags-override-X.h file.

Failing to identify and declare your PNP correctly will result in higher power consumption and could drain your battery faster.

To identify the transistor look at the marking on it and search for the matching datasheet online. For example, marking "J3Y" is an SMT S8050 NPN transistor. Marking "2TY" is an SMT S8550 PNP transistor.

If you are looking at an existing module, you can also determine the type based on the way the circuit is wired. An NPN is wired on the "low side", between the buzzer and ground. An PNP is wired o the "high side", between the buzzer and Vcc.

Wiring

NPN - transistor on the low side

  • Emitter to ground
  • Collector to - of buzzer

PNP - transistor on the high side, needs low signal at base to conduct

  • Emitter to vcc
  • Collector to + of buzzer

Diagrams:

Breadboard Schematic

Once wired, cause the device to make a tone. One way to do that is to restart the device, causing a start tune. If there is no tone check your wiring. If the buzzer is "too loud" or if the sound is distorted, try putting a 100Ω or a 200Ω resistor in series with the buzzer to reduce the current.