Alarm Circuit
The buzzer provides the audible warning when the Smart Door Alarm detects that the door has been opened. Connect the positive terminal of the buzzer to a suitable ESP32 GPIO output pin and connect its negative terminal to GND. The ESP32 will control this GPIO pin to turn the buzzer on or off.
An LED can be added as a visual indicator for the alarm. Connect the LED’s anode to another suitable ESP32 GPIO output through a 220Ω current-limiting resistor, and connect the cathode to GND. The resistor helps protect the LED from excessive current.
When the magnetic reed switch detects that the door has opened, the ESP32 changes the output state of the alarm circuit. The buzzer then produces an audible sound, while the LED illuminates to provide a clear visual indication that the alarm is active.
Keep the wiring neat and verify the polarity of the LED and buzzer before powering the circuit. After connecting all components, test the system by opening the door and confirming that both the buzzer and LED respond correctly.