Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Create a Door/Window Opening Detection System Using Arduino

Creating a door/window opening detection system with Arduino is a practical project that can enhance home security or automate home environments. This system can be built using basic components such as magnetic reed switches or infrared sensors, along with an Arduino board. Here's a step-by-step guide to building this system.

Components Needed

  • Arduino Uno or any compatible Arduino board
  • Magnetic reed switch or infrared proximity sensor
  • Resistors (10k ohm for pull-down)
  • Jumper wires
  • Breadboard
  • LED (optional, for visual indication)
  • Buzzer (optional, for audible alert)

Step-by-Step Guide

  1. Wiring the Components:

    • Connect one terminal of the magnetic reed switch to the ground (GND) pin on the Arduino.
    • Connect the other terminal of the reed switch to a digital pin on the Arduino (e.g., pin 2).
    • Use a pull-down resistor (10k ohm) between the digital pin and ground to ensure a stable reading.
    • If using an LED for indication, connect the longer leg (anode) to a digital pin (e.g., pin 13) and the shorter leg (cathode) to ground through a resistor (220 ohm).
    • If using a buzzer, connect it similarly to an LED but on a different digital pin.
  2. Arduino Code: Here's a simple Arduino sketch to detect when a door or window is opened:

    const int reedSwitchPin = 2;  // Pin connected to the reed switch
    const int ledPin = 13;        // Pin connected to the LED
    const int buzzerPin = 3;      // Pin connected to the buzzer
    
    void setup() {
     pinMode(reedSwitchPin, INPUT);
     pinMode(ledPin, OUTPUT);
     pinMode(buzzerPin, OUTPUT);
     Serial.begin(9600);
    }
    
    void loop() {
     int sensorState = digitalRead(reedSwitchPin);
    
     if (sensorState == HIGH) {
       // Door/window is open
       digitalWrite(ledPin, HIGH);
       digitalWrite(buzzerPin, HIGH);
       Serial.println("Door/Window is OPEN!");
     } else {
       // Door/window is closed
       digitalWrite(ledPin, LOW);
       digitalWrite(buzzerPin, LOW);
       Serial.println("Door/Window is CLOSED.");
     }
    
     delay(500); // Delay for debounce
    }
  3. Testing the System:

    • Upload the code to your Arduino board.
    • Open the Serial Monitor to observe the status messages.
    • Test the system by moving the magnet close to and away from the reed switch. The LED should light up and the buzzer should sound when the magnet is away from the switch, indicating an open state.

Explanation

  • Magnetic Reed Switch: This switch closes its circuit when a magnet is near, making it ideal for detecting open/close states.
  • Pull-Down Resistor: Ensures the pin reads a low signal when the switch is open, preventing false positives.
  • Serial Monitor: Used to display the status of the door/window for debugging and monitoring purposes.

This project is a straightforward introduction to using sensors with Arduino and can be expanded with wireless modules to send alerts to a smartphone or a computer.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.