Table of Contents
Reed Switch Basics
A magnetic door sensor for window and door alert with Arduino uses a reed switch – a pair of metallic reeds that close when a magnet is nearby and open when the magnet moves away. The sensor has two parts: a magnet (attached to the moving door or window) and the reed switch housing (attached to the fixed door frame). When the door opens, the magnet moves away, the reed opens, and the Arduino detects the change.
Reed switch door sensors are available in India for Rs 30-80 each (surface mount) or Rs 80-150 (recessed, flush-mount type for wood doors). They require no power to operate – the Arduino only reads the switch state.
Hardware
- Arduino Nano (controls entire system)
- Reed switch door sensors x 4 (one per entry point: front door, back door, 2 windows)
- 5V relay module (for siren)
- Buzzer (local alert)
- SIM800L GSM module (SMS alerts)
- I2C LCD 16×2 (status display)
- Arming button + LED
Wiring reed sensors: NC (Normally Closed) configuration – connect one wire to Arduino input pin with INPUT_PULLUP, other wire to GND. Door closed = LOW signal (magnet holds reed closed). Door opens = HIGH signal (magnet removed, pull-up pulls pin HIGH). This way, a cut wire also triggers the alarm (intrusion-proof).
Arduino Code
#define DOOR_FRONT 2
#define DOOR_BACK 3
#define WINDOW_1 4
#define WINDOW_2 5
#define RELAY_PIN 8
#define ARM_LED 9
#define ARM_BTN 10
const char* ZONE_NAMES[] = {
"Front Door", "Back Door", "Window 1", "Window 2"
};
int ZONE_PINS[] = {DOOR_FRONT, DOOR_BACK, WINDOW_1, WINDOW_2};
bool armed = false;
bool entryDelay = false;
unsigned long entryTimer = 0;
void setup() {
Serial.begin(9600);
for(int i=0; i<4; i++) pinMode(ZONE_PINS[i], INPUT_PULLUP);
pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, HIGH);
pinMode(ARM_LED, OUTPUT);
pinMode(ARM_BTN, INPUT_PULLUP);
}
void triggerAlarm(int zone) {
Serial.print("ALARM: "); Serial.println(ZONE_NAMES[zone]);
digitalWrite(RELAY_PIN, LOW); // Siren on
// Add SMS sending here
}
void loop() {
// Arm/disarm toggle
if(!digitalRead(ARM_BTN)) {
armed = !armed;
digitalWrite(RELAY_PIN, HIGH); // Reset siren
digitalWrite(ARM_LED, armed ? HIGH : LOW);
Serial.println(armed ? "ARMED" : "DISARMED");
delay(500);
}
if(!armed) return;
// Check all zones
for(int i=0; i<4; i++) {
if(digitalRead(ZONE_PINS[i]) == HIGH) { // Door/window OPEN
if(i == 0 && !entryDelay) { // Front door: 30-sec entry delay
entryDelay = true;
entryTimer = millis();
// Play warning beep
} else if(i != 0 ||
(entryDelay && millis()-entryTimer > 30000)) {
triggerAlarm(i);
}
}
}
if(entryDelay && armed) { // Disarmed during entry delay
// Would have been disarmed if armed became false
entryDelay = false;
}
delay(100);
}
Multi-Door System Design
For a complete Indian home (3BHK typical):
| Zone | Sensor Type | Entry Delay | 24-Hour Zone |
|---|---|---|---|
| Main entrance door | Reed + PIR inside | 30 seconds | No |
| Back door / service entrance | Reed switch | None (instant) | No |
| Bedroom windows (ground floor) | Reed switch | None | Yes (always active) |
| Kitchen window | Reed switch | None | No |
| AC unit openings | Reed switch | None | Yes |
24-hour zones remain active even when the alarm is disarmed – protecting sleeping family members from ground-floor window entry without requiring everyone to re-arm the system after moving around at night.
Integration with Alarm Panel
Reed sensors integrate with any alarm panel supporting NC (Normally Closed) zone inputs. Commercial alarm panels from CP Plus, Honeywell, and DSC (all available in India) accept reed sensor wiring directly. For DIY Arduino panels, each reed switch connects to one digital input pin. An Arduino Mega handles 16+ zones with one input per zone.
Frequently Asked Questions
Can I use surface mount or recessed sensors for Indian wooden doors?
Surface mount (Rs 30-80) are easiest to install – no drilling required, just stick/screw to door surface. Recessed sensors (Rs 80-150) install inside a routed channel in the door edge and frame for a clean look. Indian solid wood and hollow-core flush doors both accept recessed sensors. Sliding doors and aluminium-frame windows need surface mount sensors with extended mounting brackets.
How do I prevent false alarms from vibration?
Implement a debounce period: alarm only triggers if the door remains open for 500ms or more. This eliminates false triggers from slamming doors and vibration from passing trucks (common near Indian roads). Also ensure the magnet and reed housing are within 5-10mm gap when door is closed – excessive gap causes reed to barely hold and minor vibrations open it.
What about steel doors and windows?
Reed switches work through any non-magnetic material. Indian steel doors and aluminium windows are not magnetic, so the reed switch works normally. The magnet is attached to the moving part; the reed is in the fixed frame. Keep the gap between magnet and reed less than 10mm for reliable operation.
Can reed sensors work with a metal door frame?
Yes – the reed switch housing is plastic and the sensor operates through the air gap, not the frame. Metal frames do not interfere with the reed’s magnetic operation. However, nearby strong magnets (like those on refrigerator doors or security tags) within 15cm can occasionally trigger the reed switch.
How do I connect the alarm to my existing bell or chime?
Connect the siren output relay in parallel with your existing doorbell bell transformer secondary output. When the alarm triggers the relay, it completes the bell circuit causing your existing doorbell bell to ring continuously. This avoids purchasing a separate alarm siren and uses hardware already installed in Indian homes.
Add comment