Skip to Content

Active and Passive Piezo Buzzers with Arduino

Active and Passive Piezo Buzzers with Arduino

Piezo Buzzers are simple sound-producing devices widely used in electronics projects. They alert users with beeps, tones, or alarms.

There are two main types of buzzers: active and passive. Each type works differently and suits different applications. Active buzzers have built-in oscillators, so they produce sound when powered. Passive buzzers need an external signal, like a square wave, to generate sound.

In the following sections, we will explore the differences between active and passive buzzers, how to connect them, and how to program them effectively.

Required Parts

You will need a passive and an active buzzer. I listed two below but there are many alternatives. Note that the active buzzer is for 5V, while the the passive buzzer works for 3V to 5V.

As for the microcontroller, I used an Arduino Uno for this project, but any other Arduino or ESP32 will work as well. Also, a breadboard, some cables and a set of resistors will come in handy.

Active Buzzer 5V

Passive Buzzer 3..5V

Resistor kit

Arduino

Arduino Uno

USB Data Sync cable Arduino

USB Cable for Arduino UNO

Dupont wire set

Dupont Wire Set

Half_breadboard56a

Breadboard

Makerguides is a participant in affiliate advertising programs designed to provide a means for sites to earn advertising fees by linking to Amazon, AliExpress, Elecrow, and other sites. As an Affiliate we may earn from qualifying purchases.

Working Principle of Piezo Buzzers

A piezo buzzer works based on the piezoelectric effect. This effect occurs in certain ceramic materials that change shape when a voltage is applied.

Inside the buzzer there is a thin piezoelectric ceramic disc. This disc is bonded to a metal diaphragm. The metal diaphragm acts as a flexible membrane.

Piezo Element
Piezo Element

When a voltage is applied across the terminals, an electric field is created in the ceramic material. The ceramic expands or contracts depending on the polarity of the voltage. The change in dimension is very small, but it is enough to bend the attached metal diaphragm.

Piezo element bending depending on polarity
Piezo element bending depending on polarity

If a constant DC voltage is applied, the disc moves to one position and stays there (passive buzzer). No continuous sound is produced in this case. To generate sound, an alternating voltage must be applied. The voltage changes polarity at a specific frequency. Active buzzers have a built-in oscillator circuit that generates the alternating voltage.

Active buzzer with piezo element and oscillator circuit
Active buzzer with piezo element and oscillator circuit

As the voltage alternates, the ceramic disc rapidly expands and contracts. This causes the metal diaphragm to flex up and down. The diaphragm movement pushes and pulls the surrounding air. This creates pressure waves in the air, which we hear as sound.

The sound frequency is equal to the frequency of the applied signal. The loudness depends on the amplitude of the voltage and the mechanical design of the buzzer. Many piezo buzzers are designed to resonate at a specific frequency to increase sound volume.

Differences between Passive and Active Buzzers

Passive Buzzer

A passive buzzer contains only the piezoelectric element and the diaphragm. It does not include an internal oscillator circuit. When you apply DC voltage, it does not produce a continuous sound. It only clicks when the voltage changes.

The following picture shows the parts of a passive buzzer. As you can see the housing just holds the piezo element but no electronics:

Parts of a passive buzzer

To generate a tone with a passive buzzer, you must apply an alternating signal. This is usually a square wave generated by an Arduino or ESP32 using PWM. The output frequency directly defines the sound frequency. This allows you to generate different tones and simple melodies.

Active Buzzer

An active buzzer includes a built-in oscillator circuit. When you apply a DC voltage within the rated range, the internal circuit automatically generates an AC signal for the piezo element. The buzzer produces a fixed tone without any external signal generation. You only need to set the control pin HIGH to make it sound. The frequency is predefined by the internal oscillator – typically around 2 to 4 kHz – and cannot be changed.

Summary

Passive buzzers provide full control over frequency and timing. They are suitable for applications where different tones or melodies are required. Active buzzers are simpler to use. They are suitable for alarms or status indicators where only a single fixed tone is needed.

From a microcontroller perspective, a passive buzzer requires a PWM-capable pin or timer-based signal generation. An active buzzer only requires a digital output pin that can switch between HIGH and LOW.

Recognizing Active and Passive Buzzers

Passive and active buzzers look similar from the outside and are easily confused. Identifying whether a buzzer is active or passive is crucial before wiring it to your Arduino or ESP32.

As mentioned before, Active buzzers have a built-in circuit with an oscillator. This means they only need a DC voltage to produce sound. On the other hand, passive buzzers lack this internal oscillator. They require an external signal, such as a square wave, to generate sound.

Back

Typically the back of an active buzzer is completely covered with black, epoxy resin, while passive buzzers expose a circuit board:

Back of active versus passive buzzer

Height

Due to the internal circuitry the housing of an active buzzer is typically also higher than that of a passive buzzer and the pin for the plus terminal is often longer:

Height of active versus passive buzzer

Sticker

Finally, if you buy a new buzzer, active buzzers often have a sticker over the sound hole that you need to remove before using the buzzer:

Resistance

Apart from the appearance you can also measure the resistance of the buzzer to determine its type. Active buzzers have a higher resistance of around 40 Ω or measure as an open circuit. Passive buzzers, on the other hand, have a lower resistance of >20 Ω between their terminals.

Test with voltage

The surest method to determine the type of buzzer is to connect it to 5V. An active buzzer will sound, while a passive buzzer will remain silent or will produce a single click.

Summary

The following table summarizes the differences between active and passive buzzers:

Feature Active BuzzerPassive Buzzer
Internal OscillatorYesNo
Direct DC SoundYesNo or clicks
BacksideSealed with black epoxyOpen PCB/circuit board
Sound CapabilityFixed toneVarious tones/musical
ResistanceHigh (≈ 40 Ω) Low (≈ 20 Ω)
Current1 … 15 mA1 … 5 mA (but current spikes)

Choosing the Right Buzzer for Projects

Selecting the right buzzer depends on your project’s needs and complexity. Active buzzers are simple to use. They have a built-in oscillator, so you only need to supply power to produce sound. This makes them ideal for straightforward alerts or alarms where you want a constant tone without extra coding.

On the other hand, passive buzzers require an external signal to generate sound. They don’t produce sound on their own. Instead, you send a square wave or tone signal from your Arduino to control the pitch and duration. This flexibility makes passive buzzers perfect for projects that need melodies, sound effects, or variable tones.

If you want to save time and keep your code simple, choose an active buzzer. It’s plug-and-play and works well for basic notifications. However, if your project involves music or complex sound patterns, a passive buzzer offers more control and creativity.

Also, consider the power requirements and size. Active buzzers often consume more current because of the internal oscillator. Passive buzzers can be more energy-efficient if you control the signal carefully. Furthermore, you can buy them without a housing, which makes passive buzzers especially suited for compact projects.

Don’t forget to check the datasheet for voltage and current ratings to ensure compatibility.

Connecting an Active Buzzer to Arduino

Connecting an active buzzer to an Arduino is straightforward. Since active buzzers have built-in oscillators, they only need a DC voltage to produce sound. This means you don’t have to generate a tone signal from the Arduino; simply powering the buzzer will make it beep. However

Start by identifying the buzzer’s positive and negative terminals. The positive terminal is usually marked with a plus sign (+) or a longer lead.

Positive and negative terminal of active buzzer
Positive and negative terminal of active buzzer

Connect this terminal to one of the Arduino’s digital pins, such as pin 8. Then, connect the negative terminal to the Arduino’s GND (ground) pin as shown below:

Connecting Active Buzzer to Arduino UNO
Connecting Active Buzzer to Arduino UNO

Once wired, you can control the buzzer by setting the digital pin HIGH or LOW – just like you would control an LED. Setting the pin HIGH powers the buzzer and makes it sound, while setting it LOW turns it off.

Below is a minimal example sketch that turns the buzzer on for one second, then off for one second, repeatedly:

const int buzzerPin = 8;

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

void loop() {
  digitalWrite(buzzerPin, HIGH);  // Turn buzzer on
  delay(1000);                    // Wait for 1 second
  digitalWrite(buzzerPin, LOW);   // Turn buzzer off
  delay(1000);                    // Wait for 1 second
}

This code makes the buzzer beep on and off every second. Because the active buzzer handles tone generation internally, you can’t use the tone() function or PWM signals to control the buzzer.

Connecting a Passive Buzzer to Arduino

Connecting a passive buzzer to an Arduino is easy but requires a bit more attention than an active buzzer. Unlike active buzzers, passive buzzers need a PWM signal to produce sound, so you will use one of the Arduino’s digital pins capable of generating PWM. The following table lists the PWM pins for common Arduino boards:

BoardPWM Pins
Arduino UNO3, 5, 6, 9, 10, 11
Arduino Nano3, 5, 6, 9, 10, 11
Arduino Mega 25602, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 44, 45, 46
Arduino Leonardo3, 5, 6, 9, 10, 11, 13
Arduino Micro3, 5, 6, 9, 10, 11, 13
Arduino Due2 to 13
Arduino Zero3, 4, 5, 6, 8, 9, 10, 11, 12, 13

To connect the buzzer, start by identifying the buzzer’s positive and negative terminals. The positive terminal is usually marked on the PCB or there is a plus sign on the casing. Often the plus sign is very weak and hard to see:

Positive and negative terminal of passive buzzer
Positive terminal of passive buzzer

Connect the positive terminal to a PWM-capable digital pin on the Arduino, such as pin 11. Then, connect the negative terminal to the Arduino’s ground (GND).

Passive buzzers draw very little current 1 to 5mA on average. But they can have current spikes during switching. It is therefore recommended to add a current-limiting resistor in series with the buzzer. A 100 Ω resistor works well in most cases. Connect the resistor between the Arduino PWM pin 11 and the buzzer’s positive terminal as shown below.

Connecting Passive Buzzer to Arduino UNO
Connecting Passive Buzzer to Arduino UNO

However, if you find that the volume is too low, you can try to remove the 100 Ω resistor or replace it by a lower resistor value.

The circuit allows the Arduino to send varying frequency signals to the passive buzzer, enabling it to produce different tones. Remember, the passive buzzer won’t sound unless you generate a PWM signal through your code.

Code Examples for Active Buzzers

Active buzzers are simple to use with Arduino because they only need a DC voltage to produce sound. You don’t have to generate a tone signal; just turn the buzzer on or off by connecting it to a digital GPIO pin.

Here is a basic example to make an active buzzer beep for one second:

int buzzerPin = 8; 

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

void loop() {
  digitalWrite(buzzerPin, HIGH);  // Turn buzzer on
  delay(1000);                    // Wait for 1 second
  digitalWrite(buzzerPin, LOW);   // Turn buzzer off
  delay(1000);                    // Wait for 1 second
}

This code sets the buzzer pin as an output. Then it switches the buzzer on for one second and off for one second repeatedly. The buzzer will emit a steady beep during the HIGH state.

You can also create simple patterns by changing the delay times. For example, to make a short beep followed by a pause:

void loop() {
  digitalWrite(buzzerPin, HIGH);
  delay(200);                   // Short beep
  digitalWrite(buzzerPin, LOW);
  delay(800);                   // Longer pause
}

This approach works well for alarms, notifications, or simple sound effects. Since active buzzers have built-in oscillators, you don’t need to worry about generating frequencies in your code. However, you can slightly change the frequency by adding a series resistor in the same way we did for the passive buzzer. Try the 100 Ω resistor and you will hear a slightly lower tone.

In summary, controlling an active buzzer with Arduino is straightforward. Just apply HIGH or LOW signals to turn the sound on or off.

Code Examples for Passive Buzzers

Passive buzzers need a bit more work than active buzzers because they don’t generate sound on their own. Instead, you have to send them a square wave signal at a specific frequency to produce a tone. But the Arduino tone() function makes this easy.

Here’s a simple example that plays a 1 kHz tone for one second on a passive buzzer connected to pin 11:

int buzzerPin = 11;

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

void loop() {
  tone(buzzerPin, 1000);  // Play 1000 Hz tone
  delay(1000);            // Wait for 1 second
  noTone(buzzerPin);      // Stop the tone
  delay(1000);            // Wait for 1 second before repeating
}

This code sets pin 11 as an output and uses tone() to generate a 1000 Hz square wave. The buzzer sounds for one second, then stops for one second, creating a beep pattern.

You can also create melodies by changing the frequency and duration. For example, to play two different notes in sequence:

int buzzerPin = 11;

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

void loop() {
  tone(buzzerPin, 523);  // Play C5 note (523 Hz)
  delay(500);
  tone(buzzerPin, 659);  // Play E5 note (659 Hz)
  delay(500);
  noTone(buzzerPin);
  delay(1000);
}

In this example, the buzzer plays a C5 note followed by an E5 note, each lasting half a second. The noTone() function stops the sound before the pause.

If you want more control, you can generate tones manually using digitalWrite() and delayMicroseconds(), but tone() is usually sufficient and easier to use. Here is the same code as before but with tone() replaced:

int buzzerPin = 11;

void playTone(int frequency, int durationMs) {
  long halfPeriod = 1000000L / (2L * frequency);   
  long cycles = (long)frequency * durationMs / 1000L;

  for (long i = 0; i < cycles; i++) {
    digitalWrite(buzzerPin, HIGH);
    delayMicroseconds(halfPeriod);
    digitalWrite(buzzerPin, LOW);
    delayMicroseconds(halfPeriod);
  }
}

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

void loop() {
  playTone(523, 500);  // C5 (523 Hz) for 500 ms
  delay(10);           // Short pause between notes

  playTone(659, 500);  // E5 (659 Hz) for 500 ms
  delay(1000);         // Equivalent to noTone() + delay(1000)
}

Remember, passive buzzers require a frequency signal to produce sound, so always use tone() or equivalent methods to drive them. For more examples see our Use A Piezo Buzzer With Arduino tutorial.

You can use the following tool to find the frequencies and durations for the tone() function to play the sounds you want:

Troubleshooting Common Issues

When working with buzzers, you might encounter a few common problems. Fortunately, most of these issues are easy to fix with some simple checks and adjustments.

First, if your buzzer doesn’t make any sound, start by verifying your wiring. Make sure the buzzer’s positive and negative pins connect correctly to the Arduino’s output pin and ground. Reversed polarity can prevent the buzzer from working, especially with active buzzers.

Next, check your code. For active buzzers, a simple digitalWrite to HIGH should produce sound. For passive buzzers, you need to use the tone() function to generate a frequency. If you forget this, the buzzer will stay silent or you will just hear a clicking sound.

If the buzzer emits a weak or distorted sound, the problem might be your power supply. Ensure your Arduino board provides enough current. Sometimes, using a separate power source or adding a transistor to drive the buzzer helps.

Another issue is continuous buzzing when you expect intermittent sounds. This usually happens if your code lacks proper timing or delays. Use the delay() function or timers to control when the buzzer turns on and off.

Finally, note that you cannot adjust the buzzer volume via code; regardless if it is a passive or an active buzzer. However, you can add a series resistor to a passive buzzer to reduce the voltage and therefore the volume to some degree.

Conclusions

Buzzers add sound and feedback to your Arduino projects in simple and effective ways. Active buzzers are easy to use because they only need power to produce sound. You just connect them to a digital pin and ground, then turn the pin HIGH to hear a tone. Passive buzzers, on the other hand, require more control. You must generate a square wave signal to create different tones, giving you more flexibility for melodies and sound effects.

Choosing the right buzzer depends on your project needs. If you want a quick beep or alarm, an active buzzer is the best choice. If you want to play tunes or custom sounds, go with a passive buzzer. Always check the buzzer’s datasheet to confirm its type and voltage requirements.

When connecting buzzers to your Arduino, remember to use current-limiting resistors if needed and avoid powering them directly from pins that cannot supply enough current.

If you have any questions feel free to leave them in the comment section.

Happy Tinkering 😉