How to make an RFID door lock system using an Arduino Nano board

How to make an RFID door lock system using an Arduino Nano board

Hello and welcome back, In this project, we will learn how to make an RFID door lock system using an Arduino Nano board. However, please note that you can use any other Arduino board for this project. We will also use an inexpensive method to implement the door lock, by utilizing a servo motor to control the lock. It’s important to remember that this project serves as a foundation for your own creative endeavors. Please use this knowledge for your own projects.

(adsbygoogle = window.adsbygoogle || []).push({});

What’s the RFID module?

The RFID module, or Radio Frequency Identification module, is a technology that allows for wireless communication between devices. It uses radio waves to transfer data from a tag or card to a reader. In this project, I used the RFID module to enable secure access control for our door lock system. It mainly consists of two parts. That’s,

1. RFID reader

The RFID reader is a device that emits radio waves and receives signals from the RFID tags. It acts as the communication interface between the RFID tags and the microcontroller (in our case, the Arduino Nano board).

2. RFID Tags

RFID tags, also known as RFID cards or transponders, are small electronic devices that contain a unique identification number. These tags consist of an integrated circuit (IC) and an antenna.

By combining the power of the Arduino Nano board, LCD screen, RFID reader, and servo motor, we can create an affordable and reliable solution to control access to our doors.

  • If you want to know more info about the RFID module – Click on me

OK, Let’s do this project. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 2

Secondly, cut the rigifoam or foam board following sizes.

Step 3

Thirdly, create the door using the following pictures. You have to remember that it is a DIY model.

Step 4

After that, cut the base of this door. Use the following sizes for that.

Step 5

Now, prepare the LCD screen and RFID positioning. For that, use the following pictures.

Step 6

Next, place the Arduino Nano board and Buzzer on the breadboard. And then, connect the buzzer to the Arduino board.

(adsbygoogle = window.adsbygoogle || []).push({});
How to make an RFID door lock system using an Arduino Nano board

Step 7

Now, connect the LCD screen and servo motor to the Arduino Nano board.

Step 8

Next, install the LCD screen and breadboard on the back of the door.

Step 9

Now, connect the servo motor to the door lock. For that, I used an iron stick. And then, install it on the door.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 10

Next, connect the RFID module to the Arduino Nano board. Then, install this module in front of the door.

Step 11

Next, install the door hinges and connect the door to the main frame.

Step 12

And then, install the slide latch lock and door handle.

Step 13

Now, connect the Arduino Nano board to the computer.

How to make an RFID door lock system using an Arduino Nano board
  • Code and circuit diagram — Download
  • RFID library — Download
  • Now, copy and paste the UID scan program on the Arduino IDE.
/*RFID tag scan code
 * https://srituhobby.com
 */
 
#include <SPI.h>
#include <MFRC522.h>

#define RST_PIN 9
#define SS_PIN  10

MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  while (!Serial);
  SPI.begin();
  mfrc522.PCD_Init();
  delay(4);
  mfrc522.PCD_DumpVersionToSerial();
  Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
  if ( ! mfrc522.PICC_IsNewCardPresent()) {
    return;
  }

  if ( ! mfrc522.PICC_ReadCardSerial()) {
    return;
  }
  mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
(adsbygoogle = window.adsbygoogle || []).push({});
  • And then, select the board and port. After, click the upload button.
  • Now, open the serial monitor and place the RFID tag on the RFID module. Then, you can see the UID on the serial monitor.
  • And then, copy this UID. For that, use the Ctrl+C shortcut. After, paste it into the main program.

/*Door lock system with Arduino Nano
   
Home Page
*/ #include <Servo.h> #include <LiquidCrystal_I2C.h> #include <SPI.h> #include <MFRC522.h> #define SS_PIN 10 #define RST_PIN 9 #define buzzer 2 #define servoPin 3 String UID = "*************";//Enter your card ID byte lock = 0; Servo servo; LiquidCrystal_I2C lcd(0x27, 16, 2); MFRC522 rfid(SS_PIN, RST_PIN); void setup() { Serial.begin(9600); servo.write(70); lcd.init(); lcd.backlight(); servo.attach(servoPin); SPI.begin(); rfid.PCD_Init(); pinMode(buzzer, OUTPUT); } void loop() { lcd.setCursor(4, 0); lcd.print("Welcome!"); lcd.setCursor(1, 1); lcd.print("Put your card"); if ( ! rfid.PICC_IsNewCardPresent()) return; if ( ! rfid.PICC_ReadCardSerial()) return; lcd.clear(); lcd.setCursor(0, 0); lcd.print("Scanning"); Serial.print("NUID tag is :"); String ID = ""; for (byte i = 0; i < rfid.uid.size; i++) { lcd.print("."); ID.concat(String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ")); ID.concat(String(rfid.uid.uidByte[i], HEX)); delay(300); } ID.toUpperCase(); if (ID.substring(1) == UID && lock == 0 ) { digitalWrite(buzzer, HIGH); delay(300); digitalWrite(buzzer, LOW); servo.write(50); delay(100); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Locked"); delay(1500); lcd.clear(); lock = 1; } else if (ID.substring(1) == UID && lock == 1 ) { digitalWrite(buzzer, HIGH); delay(300); digitalWrite(buzzer, LOW); servo.write(110); delay(100); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Unlocked"); delay(1500); lcd.clear(); lock = 0; } else { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Wrong card!"); digitalWrite(buzzer, HIGH); delay(200); digitalWrite(buzzer, LOW); delay(200); digitalWrite(buzzer, HIGH); delay(200); digitalWrite(buzzer, LOW); delay(200); digitalWrite(buzzer, HIGH); delay(200); digitalWrite(buzzer, LOW); delay(200); delay(1500); lcd.clear(); } }
  • Now, select the board and port. After, upload this program to the Arduino Nano board.
(adsbygoogle = window.adsbygoogle || []).push({});

Step 14

Finally, remove the USB cable and provide a 5VDC external power supply to the circuit. Use the circuit diagram above for that.

OK, now you can test this project using the RFID tags.

Troubleshooting tips

  • Check the Wiring.
  • Power Supply. (I used the 5VDC power supply)
  • RFID Tag Compatibility.
  • Code Verification.
  • RFID Reader Interference.
  • Servo Motor Calibration.

Ok, enjoy this project. The full video guide is below. We hope to see you in the next project or tutorial.

How to make an RFID door lock system using an Arduino Nano board

How to make an RFID door lock system using an Arduino Nano board

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *