Thursday, September 24, 2020

RFID based home automation with door lock

 

RFID-Based Home Automation Using Arduino: A Step-by-Step Guide

The advent of IoT has paved the way for smarter and more secure home automation systems. RFID (Radio Frequency Identification) technology, paired with Arduino, offers a simple yet effective solution for automated access control. In this blog, we’ll create an RFID-based home automation system that allows you to control appliances or secure access through RFID tags.


Overview of the System

This project leverages an RFID reader to identify unique RFID tags. Once a tag is detected, the Arduino processes the tag's ID and performs actions like turning appliances on/off, unlocking doors, or activating devices based on predefined logic.


Components Required

  1. Arduino Board (e.g., Uno, Mega)
  2. RC522 RFID Module
  3. RFID Tags
  4. Relay Module (for controlling appliances)
  5. 12V DC Power Supply (optional for external devices)
  6. LEDs (for status indication)
  7. Buzzer (optional for feedback)
  8. Connecting Wires and Breadboard
  9. Home Appliances (like a light bulb or fan)

Circuit Diagram

The setup involves connecting the RC522 RFID module, relay module, and any additional indicators like LEDs or buzzers to the Arduino.

Connections for RC522 RFID Module:

Pin Name RC522 Pin Arduino Pin
VCC 3.3V 3.3V
RST RST Pin 9
GND GND GND
IRQ Not Used -
MISO MISO Pin 12
MOSI MOSI Pin 11
SCK SCK Pin 13
SDA SDA Pin 10

Relay Module:

  • Connect the relay input to a digital pin on the Arduino (e.g., Pin 8).
  • The relay output connects to the appliance's power line.

Software Setup

Required Libraries

  • Install the MFRC522 library for the RFID module.
    1. Open Arduino IDE.
    2. Go to Sketch > Include Library > Manage Libraries.
    3. Search for MFRC522 and install it.

Arduino Code

Here’s a basic code example to read an RFID tag and control a relay:

#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN 10
#define RELAY_PIN 8

MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Ensure the relay is off initially
  Serial.println("Place your RFID tag near the reader...");
}

void loop() {
  // Look for new RFID cards
  if (!mfrc522.PICC_IsNewCardPresent()) return;
  if (!mfrc522.PICC_ReadCardSerial()) return;

  // Read RFID tag UID
  String tagID = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    tagID += String(mfrc522.uid.uidByte[i], HEX);
  }

  Serial.println("Tag ID: " + tagID);

  // Verify if tag ID matches the predefined ID
  if (tagID == "a1b2c3d4") { // Replace with your RFID tag's unique ID
    Serial.println("Access Granted! Activating Relay...");
    digitalWrite(RELAY_PIN, HIGH); // Turn ON appliance
    delay(5000); // Keep it on for 5 seconds
    digitalWrite(RELAY_PIN, LOW);  // Turn OFF appliance
  } else {
    Serial.println("Access Denied!");
  }

  mfrc522.PICC_HaltA();
}


Working Video





    How It Works

    1. Tag Scanning: When an RFID tag is brought near the RC522 module, the Arduino reads its unique ID.
    2. Authentication: The Arduino compares the tag ID with predefined IDs stored in the code.
    3. Action Trigger: If the tag ID matches, the Arduino activates the relay to turn on an appliance or unlock a door.

    Applications

    1. Home Automation: Control lights, fans, or other appliances using authorized RFID tags.
    2. Access Control: Secure doors by integrating a motorized lock with the relay.
    3. Office Management: Restrict access to specific areas for authorized personnel.

    Enhancements

    • Database Integration: Use an SD card module or IoT platform to dynamically update authorized RFID tags.
    • Mobile App Control: Combine RFID with a Wi-Fi module (e.g., ESP8266) for app-based monitoring and control.
    • Multiple Appliances: Use multiple relays to control various devices.

    Conclusion

    An RFID-based home automation system is an efficient way to enhance security and convenience in modern homes. With Arduino as the backbone, the system is both affordable and customizable. Dive into this project to explore the endless possibilities of RFID technology in IoT applications.



    No comments:

    Post a Comment

    Electronic Dice With 7 – Segment Display

    Aim The Aim of this project is to learn, study and create different ICs in digital logic and designing and create a unique project. This pro...