JACK
Published

RFID Base Door Lock System Using Arduino

In this Article, we learn about how to make RFID Base Door Lock System Using Arduino.

ExpertFull instructions provided4 hours315
RFID Base Door Lock System Using Arduino

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
SparkFun RFID Reader Breakout
SparkFun RFID Reader Breakout
×1
1-Channel Signal Relay 1A SPDT I²C Mini Module
ControlEverything.com 1-Channel Signal Relay 1A SPDT I²C Mini Module
×1
Solenoid Valve, 2 Way
Solenoid Valve, 2 Way
×1
60W PCIe 12V 5A Power Supply
Digilent 60W PCIe 12V 5A Power Supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires

Story

Read more

Schematics

rfid_door_lock_diagram_KUYOOdZeh0.jpg

Code

Untitled file

C/C++
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>

#define RST_PIN     9
#define SS_PIN      10

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
const int relayPin = 8;
const int buzzerPin = A0;
void setup() {
  Serial.begin(9600);
  SPI.begin();      // Initiate SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC52
 pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
digitalWrite(relayPin, HIGH);  // Activate relay

delay(2000);
}

void loop() {
  if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
    String cardUID = "";
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      cardUID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : ""));
      cardUID.concat(String(mfrc522.uid.uidByte[i], HEX));
    }
    cardUID.toUpperCase();
    if (isValidCard(cardUID)) {  
      digitalWrite(relayPin, LOW);  // Deactivate relay
      delay(10000);  // Keep the relay active for 2 seconds
      digitalWrite(relayPin, HIGH);  // Activate relay
    } else { 
      digitalWrite(buzzerPin, HIGH);  // Activate buzzer
      delay(2000);  // Keep the buzzer active for 2 seconds
      digitalWrite(buzzerPin, LOW);  // Deactivate buzzer
    }
    delay(1000);  // Delay to prevent multiple reads
  }
}

bool isValidCard(String cardUID) {
  // Replace with the UID of your valid RFID cards
  String validCard1 = "43884203";
  String validCard2 = "90467989";

  return (cardUID == validCard1 || cardUID ==validCard2);
}

Credits

JACK

JACK

21 projects • 2 followers

Comments