Files
OpenParcelBox/docs/firmware/buzzer.md
T

1.7 KiB

Buzzer

Purpose

This module provides audible feedback for keypad presses and access-code events.

The current hardware uses an active buzzer. The firmware does not generate PWM; it only drives a GPIO high for a short pulse.


Hardware

  • Seeed Studio XIAO nRF52840.
  • Active buzzer.
  • Buzzer driven through an external transistor.
  • Control signal: XIAO pin D0.

The GPIO must be used as a control signal only. The buzzer current is supplied through the transistor stage, not directly by the microcontroller pin.


Public API

int buzzer_init(void);

void buzzer_on(void);

void buzzer_beep_key(void);

void buzzer_beep_success(void);

void buzzer_off(void);

Current Behavior

  • buzzer_init() configures the buzzer control GPIO and leaves the buzzer off.
  • buzzer_beep_key() emits a short blocking beep.
  • buzzer_beep_success() emits a longer blocking beep when a valid access code or NFC badge is accepted.
  • The keypad calls buzzer_beep_key() only when a new key press is accepted, so holding a key does not produce a continuous beep.
  • Invalid six-digit access codes, unauthorized NFC badges, and duplicate tags during enrollment are signaled by the same higher-level sequence of three short GPIO pulses.
  • While the lock state feedback reports open, the main loop emits one short reminder beep every 2 seconds.
  • Each open-state reminder is also logged as Door open reminder beep so the feedback contact and buzzer behavior can be distinguished during diagnosis.

Notes

Because the buzzer is active, tone generation is handled by the buzzer itself.

Future sound patterns should stay as higher-level sequences built from GPIO on/off pulses.