Beginner to Intermediate

Build a Door Alarm System

A door alarm system detects when a door is opened unexpectedly and activates an audible alarm or sends a notification. These systems are widely used in homes, offices, shops and warehouses to improve security and provide early warning of unauthorised entry. This project demonstrates how to build a reliable door alarm using an Arduino or ESP32, a magnetic reed switch and optional Wi-Fi connectivity.

Door Alarm System

Project Overview

A magnetic reed switch is mounted on the door frame while a small permanent magnet is attached to the door.

When the door is closed, the magnet keeps the reed switch in its normal state. Opening the door changes the switch state, allowing the microcontroller to activate a buzzer, siren, relay or smartphone notification.

Additional sensors can be incorporated for complete home security systems.

Project Difficulty

ItemValue
Difficulty⭐⭐ Beginner–Intermediate
Build Time2–4 Hours
Supply Voltage5 V DC
ControllerESP32 or Arduino
Sensor TypeMagnetic Reed Switch

Main Sections

Section Function
Magnetic Reed Switch Detects whether the door is open or closed.
Permanent Magnet Operates the reed switch.
Microcontroller Processes sensor signals.
Buzzer or Siren Provides an audible warning.
Status LEDs Show system status.
Wi-Fi Module (Optional) Sends remote notifications.

Typical Components

QuantityComponent
1ESP32 or Arduino Nano
1Magnetic Reed Switch
1Permanent Magnet
1Piezo Buzzer or Alarm Siren
2Status LEDs (Power and Alarm)
1Push Button (Arm/Disarm or Reset)
1Relay Module (Optional)
15 V Power Supply

How the System Works

When the door is closed, the magnet keeps the reed switch closed (or open, depending on the switch type).

As soon as the door opens, the magnetic field moves away from the reed switch, changing its electrical state.

The microcontroller immediately detects this change and activates the alarm output.

In advanced versions, the system can also record the event, trigger a camera or send a notification via Wi-Fi or MQTT.

Typical Features

Feature Description
Door Open Detection Detects when the door is opened.
Audible Alarm Activates a buzzer or siren.
Status LEDs Display armed and alarm conditions.
Manual Arm/Disarm Enable or disable the alarm.
Wi-Fi Notifications Alert users remotely.
Event Logging Store alarm events for later review.

Applications

  • Home security.
  • Office access monitoring.
  • Garage doors.
  • Shop entrances.
  • Storage rooms.
  • Server rooms.
  • Warehouse security.
  • Smart home automation.

Testing

  1. Verify the power supply voltage.
  2. Confirm the reed switch changes state when the door opens.
  3. Arm the alarm system.
  4. Open the door slowly.
  5. Verify the buzzer or siren activates.
  6. Test manual reset and disarm functions.
  7. Verify Wi-Fi notifications if implemented.
  8. Repeat several opening and closing cycles.

Troubleshooting

Problem Possible Cause
No alarm Incorrect reed switch wiring or software error.
Alarm always active Magnet misaligned or reed switch faulty.
False alarms Loose wiring or poor mechanical alignment.
No Wi-Fi connection Incorrect network settings.
Buzzer silent Faulty buzzer or output wiring.

Project Improvements

  • Add a keypad for secure arming and disarming.
  • Send email, SMS or MQTT notifications.
  • Capture images using an ESP32-CAM.
  • Log alarm events to a MicroSD card.
  • Add battery backup.
  • Monitor multiple doors and windows.
  • Integrate with Home Assistant.
  • Add RFID or fingerprint access control.

Skills Learned

  • Magnetic reed switch operation.
  • Digital input programming.
  • Alarm system design.
  • ESP32 development.
  • Relay control.
  • IoT home security.

Safety Notes

  • Mount the reed switch and magnet securely to prevent false alarms.
  • Protect outdoor sensors from moisture and physical damage.
  • Use battery backup if continuous operation is important.
  • Test the alarm system regularly.
  • Do not rely solely on a DIY alarm system for high-security applications.

Key Points

  • Magnetic reed switches provide a simple and reliable way to detect door openings.
  • An ESP32 enables remote monitoring and smartphone notifications.
  • Door alarms can easily be expanded into complete home security systems.
  • Battery backup improves reliability during power outages.
  • This project is an excellent introduction to electronic security and smart home automation.

Next Project

Continue by building a Smart Home Security System, combining door sensors, motion detectors, smoke alarms, gas detectors and Wi-Fi notifications into a single integrated security platform.

Next Project → Smart Home Security System