RFID Door Control System Documentation
Summary
This document provides a detailed overview of an RFID Door Control System. The system uses an RFID-RC522 module to read RFID tags. If an authorized tag is detected, a servo motor is activated to open a door. The system is controlled by an Arduino UNO microcontroller, and it also includes an I2C display for visual feedback. Power is supplied by a 9V battery.
Component List
Servo
- Description: A servo motor used to open and close the door.
- Pins: gnd, vcc, pulse
RFID-RC522
- Description: An RFID reader module used to read RFID tags.
- Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
Arduino UNO
- Description: A microcontroller board used to control the system.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
I2C Display
- Description: A display module used to provide visual feedback.
- Pins: GND, VCC, SDL, SCL
9V Battery
- Description: A battery used to power the system.
- Pins: -, +
Wiring Details
Servo
- gnd connected to Arduino UNO GND and RFID-RC522 GND
- vcc connected to Arduino UNO 5V, I2C Display VCC, and 9V Battery +
- pulse connected to Arduino UNO D3
RFID-RC522
- GND connected to Arduino UNO GND and Servo gnd
- VCC (3.3V) connected to Arduino UNO 3.3V
- RST connected to Arduino UNO D9
- SCK connected to Arduino UNO D13
- MISO connected to Arduino UNO D12
- MOSI connected to Arduino UNO D11
- SDA connected to Arduino UNO D10
Arduino UNO
- GND connected to Servo gnd, RFID-RC522 GND, I2C Display GND, and 9V Battery -
- 5V connected to Servo vcc, I2C Display VCC, and 9V Battery +
- 3.3V connected to RFID-RC522 VCC (3.3V)
- D3 connected to Servo pulse
- D9 connected to RFID-RC522 RST
- D10 connected to RFID-RC522 SDA
- D11 connected to RFID-RC522 MOSI
- D12 connected to RFID-RC522 MISO
- D13 connected to RFID-RC522 SCK
- A4 connected to I2C Display SDL
- A5 connected to I2C Display SCL
I2C Display
- GND connected to Arduino UNO GND and 9V Battery -
- VCC connected to Arduino UNO 5V, Servo vcc, and 9V Battery +
- SDL connected to Arduino UNO A4
- SCL connected to Arduino UNO A5
9V Battery
- - connected to Arduino UNO GND, I2C Display GND
- + connected to Arduino UNO 5V, Servo vcc, I2C Display VCC
Code Documentation
/*
* RFID Door Control System
* This code reads an RFID tag using the RFID-RC522 module. If the tag is
* authorized, it opens the door by rotating a servo motor. If the tag is not
* authorized, the door remains closed.
*/
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN 3
MFRC522 rfid(SS_PIN, RST_PIN);
Servo doorServo;
// List of authorized RFID tag UIDs
const byte authorizedUID[4] = {0xDE, 0xAD, 0xBE, 0xEF};
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
doorServo.attach(SERVO_PIN);
doorServo.write(0); // Door closed position
Serial.println("RFID Door Control System Initialized");
}
void loop() {
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return;
}
if (isAuthorized(rfid.uid.uidByte)) {
Serial.println("Authorized tag detected. Opening door...");
doorServo.write(90); // Open door
delay(5000); // Keep door open for 5 seconds
doorServo.write(0); // Close door
} else {
Serial.println("Unauthorized tag detected. Access denied.");
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
bool isAuthorized(byte *uid) {
for (byte i = 0; i < 4; i++) {
if (uid[i] != authorizedUID[i]) {
return false;
}
}
return true;
}
This code initializes the RFID reader and the servo motor. It continuously checks for new RFID tags. If an authorized tag is detected, the servo motor rotates to open the door for 5 seconds before closing it again. Unauthorized tags are denied access.
