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.
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
| Item | Value |
|---|---|
| Difficulty | ⭐⭐ Beginner–Intermediate |
| Build Time | 2–4 Hours |
| Supply Voltage | 5 V DC |
| Controller | ESP32 or Arduino |
| Sensor Type | Magnetic 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
| Quantity | Component |
|---|---|
| 1 | ESP32 or Arduino Nano |
| 1 | Magnetic Reed Switch |
| 1 | Permanent Magnet |
| 1 | Piezo Buzzer or Alarm Siren |
| 2 | Status LEDs (Power and Alarm) |
| 1 | Push Button (Arm/Disarm or Reset) |
| 1 | Relay Module (Optional) |
| 1 | 5 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
- Verify the power supply voltage.
- Confirm the reed switch changes state when the door opens.
- Arm the alarm system.
- Open the door slowly.
- Verify the buzzer or siren activates.
- Test manual reset and disarm functions.
- Verify Wi-Fi notifications if implemented.
- 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.