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

Arduino-Based Access Control System

Access control systems are essential in various environments, from securing homes to managing entry points in commercial buildings. With the flexibility and affordability of Arduino, creating a custom access control system becomes accessible to hobbyists and professionals alike. This article will guide you through building an Arduino-based access control system, highlighting its importance in enhancing security and demonstrating how to implement it effectively.

Project: The project involves creating an access control system using an Arduino board, RFID reader, and a relay module to control a door lock. The system will read RFID tags, verify them against a list of authorized tags, and activate the relay to unlock the door if the tag is valid. The objective is to provide a secure and user-friendly method to control access to a restricted area.

Components List:

  • Arduino Uno (1)
  • RFID Reader Module (MFRC522) (1)
  • RFID Tags (2-3)
  • Relay Module (1)
  • Door Lock (1)
  • Breadboard (1)
  • Jumper Wires (various)

Examples:

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

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

MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600); // Initialize serial communications
  SPI.begin();        // Initialize SPI bus
  mfrc522.PCD_Init(); // Initialize MFRC522
  pinMode(RELAY_PIN, OUTPUT); // Set relay pin as output
  digitalWrite(RELAY_PIN, LOW); // Ensure relay is off
  Serial.println("Access Control System Initialized");
}

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

  // Read the card UID
  String uid = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    uid += String(mfrc522.uid.uidByte[i], HEX);
  }
  uid.toUpperCase();
  Serial.println("Card UID: " + uid);

  // Check if the UID is authorized
  if (isAuthorized(uid)) {
    Serial.println("Access Granted");
    digitalWrite(RELAY_PIN, HIGH); // Activate relay to unlock door
    delay(5000);                   // Keep the door unlocked for 5 seconds
    digitalWrite(RELAY_PIN, LOW);  // Deactivate relay to lock door
  } else {
    Serial.println("Access Denied");
  }

  // Halt PICC
  mfrc522.PICC_HaltA();
  mfrc522.PCD_StopCrypto1();
}

bool isAuthorized(String uid) {
  // List of authorized UIDs
  String authorizedUids[] = {"UID1", "UID2", "UID3"};

  for (String authorizedUid : authorizedUids) {
    if (uid == authorizedUid) {
      return true;
    }
  }
  return false;
}

Explanation:

  1. Libraries and Pin Definitions:

    • #include <SPI.h> and #include <MFRC522.h>: Include necessary libraries for SPI communication and RFID functionality.
    • Define pins for the RFID reader and relay module.
  2. Setup Function:

    • Initialize serial communication for debugging.
    • Initialize SPI bus and RFID reader.
    • Set relay pin as output and ensure it is off initially.
  3. Loop Function:

    • Continuously check for new RFID cards.
    • Read the UID of the detected card and convert it to a string.
    • Check if the UID is in the list of authorized UIDs.
    • If authorized, activate the relay to unlock the door for 5 seconds, then lock it again.
  4. Authorization Function:

    • Compare the detected UID against a predefined list of authorized UIDs.

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.