Skip to main content

buzzer

Control active and passive piezo buzzers for audio alerts and tones.

Overview

The buzzer node controls both active and passive piezo buzzers for generating audio alerts, notification tones, and alarm sounds. Active buzzers produce a fixed tone with a simple on/off signal, while passive buzzers allow frequency control for melodies and variable tones. Supports timed beeps with configurable duration for precise audio feedback in IoT systems.

3.3V
Signal Level
2 Types
Active / Passive
20kHz
Max Frequency
Timed
Beep Support

Active vs Passive Buzzers

Active Buzzer

  • Built-in oscillator circuit
  • Fixed frequency tone (~2.7kHz)
  • Simple on/off control (HIGH/LOW)
  • No PWM required
  • Best for simple alerts and alarms

Passive Buzzer

  • No internal oscillator
  • Variable frequency via PWM
  • Can play melodies and tones
  • Requires PWM signal input
  • Best for custom tones and music

Properties

Property Type Required Default Description
pin number Yes 18 GPIO pin number (BCM numbering)
type select No "active" Buzzer type: "active" or "passive"
frequency number No 1000 Default tone frequency in Hz (passive only)
activeLow boolean No false Invert logic for active-low buzzer modules
duration number No 100 Default beep duration in milliseconds

Inputs

msg.payload

Object with action, optional frequency and duration.

{
  "action": "beep",
  "frequency": 2000,
  "duration": 200
}
"beep" Sound for specified duration then stop
"on" Turn buzzer on continuously
"off" Turn buzzer off

Outputs

Buzzer State

Outputs current buzzer state with configuration.

{
  "state": "beep",
  "type": "passive",
  "frequency": 2000,
  "duration": 200,
  "timestamp": 1709251200000
}

Wiring / Connection Diagram

Active Buzzer (Direct)

  Raspberry Pi          Active Buzzer
  +-----------+        +-----------+
  |           |        |     (+)   |
  |  GPIO 18  |--------| Signal    |
  |           |        |           |
  |  GND      |--------| GND (-)  |
  |           |        +-----------+
  +-----------+

  Note: Active buzzers have a
  built-in oscillator. Just send
  HIGH to activate.

Passive Buzzer (with Transistor)

  Raspberry Pi          NPN Transistor
  +-----------+        +------+
  |           |  1kΩ   |  B   |   Passive Buzzer
  |  GPIO 18  |--[R]---| NPN  |   +----------+
  |           |        |  C   |---| (+)      |
  |  GND      |--------| E   |   |          |
  +-----------+        +------+   | GND (-)  |
                                  +----------+
                          |            |
                        [GND]     [3.3V/5V]

  Note: Transistor needed for
  passive buzzers to provide
  sufficient current.

Example Use Cases

Temperature Alarm

Sound an alarm when temperature exceeds a critical threshold.

dht22 switch buzzer
[
  {
    "id": "temp-sensor",
    "type": "dht22",
    "pin": 4,
    "interval": 5000
  },
  {
    "id": "threshold-check",
    "type": "switch",
    "property": "payload.temperature",
    "rules": [
      { "t": "gt", "v": "40" }
    ]
  },
  {
    "id": "alarm-set",
    "type": "change",
    "rules": [
      { "t": "set", "p": "payload", "to": { "action": "beep", "duration": 500 } }
    ]
  },
  {
    "id": "alarm-buzzer",
    "type": "buzzer",
    "pin": 18,
    "type": "active",
    "duration": 500
  }
]

Doorbell with Custom Melody

Play a tone sequence using a passive buzzer when a button is pressed.

button function buzzer
[
  {
    "id": "door-button",
    "type": "gpio-in",
    "pin": 25,
    "edge": "rising"
  },
  {
    "id": "melody-gen",
    "type": "function",
    "func": "// Doorbell ding-dong sequence
var notes = [
  { action: 'beep', frequency: 659, duration: 300 },
  { action: 'beep', frequency: 523, duration: 500 }
];
for (var i = 0; i < notes.length; i++) {
  var m = { payload: notes[i] };
  node.send(m);
}
return null;"
  },
  {
    "id": "doorbell-buzzer",
    "type": "buzzer",
    "pin": 18,
    "buzzerType": "passive",
    "frequency": 1000
  }
]

Motion Detection Alert

Quick beep notification when motion is detected by a PIR sensor.

pir change buzzer
[
  {
    "id": "motion-sensor",
    "type": "pir",
    "pin": 7,
    "retriggerable": false
  },
  {
    "id": "beep-cmd",
    "type": "change",
    "rules": [
      { "t": "set", "p": "payload", "to": { "action": "beep", "duration": 100 } }
    ]
  },
  {
    "id": "alert-buzzer",
    "type": "buzzer",
    "pin": 18,
    "buzzerType": "active",
    "duration": 100
  }
]

Common Use Cases

Safety Alarms

Temperature, gas, and intrusion alert systems

Doorbell Systems

Custom tones for visitor notification

Timer Notifications

Audible alerts for scheduled events and timers

User Feedback

Audio confirmation beeps for button presses and actions

Related Nodes