Creating A RFID Door Latch With Arduino: Instructables
Creating A RFID Door Latch With Arduino: Instructables
by KEV_123456
This is an RFID(otherwise known as Radio-Frequency Identi cation) door latch, made to unlock then lock a
door/cabinet/locker when the corresponding RFID tag is scanned.
This is a project I have been working on for about 2 weeks, and I will show you how to make it in this instructable. There
is wood construction in this project and I will brie y discuss it. I am not good with wood or construction but it is a model
to show the project mounted.
There are also 3d print les in this that are necessary and I will discuss them when it comes up. The 3d les are not my
own and I discovered them on Makerbot Thingiverse https://www.thingiverse.com/& the DIY Life https://www.the-
diy-life.com/.
Proper credit will be given to the original creators when the 3d les are discussed.
Supplies:
Tinkercad can show the wiring for the LCD and the Micro servo but not the RFID. For the RFID I will tell you speci cally
which pin to go where.
For the 3d print les, the LCD Screen bezel is created by TheMakersWorkbench
https://www.thingiverse.com/thing:651963
The RFID reader holder is made by DZSYhttps://www.thingiverse.com/thing:3853458
The lock was made by Sagittario and then modi ed by Michael Klements and the micro servo holder was created by
Michael Klements, RFID Lock 3D Print Files
You could also use a metal slide lock from the department store as well.
Step 3: Code
To begin downloading the libraries, code, and view your RFID cards UID, use the video above that I created to see how to
do it. I am using Arduino create for education, so this doesn't apply to Arduino IDE, also lower your volume because it is a
bit loud.
After following its instructions, in the serial monitor after scanning your RFID card, you will see a code like 39 AA E3 B3.
This is your RFID card's UID.
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#include <LiquidCrystal.h>
Here are what the libraries would look like in your code.
#define SERVO_PIN 8
Servo myservo;
This is de ning the pins for the RFID module, the Mini Servo pins, and the LCD pins.
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
lcd.begin(16, 2);
lcd.print("Scan RFID Card");
myservo.attach(SERVO_PIN);
myservo.write( 75 ); // starting degree the motor will be at
Serial.println("Put your card to the reader...");
Serial.println();
This code is initiating a serial communication, SPI bus, and the MFRC522( RFID module)
the LCD turns on and then starts on the grid (16,2), displaying "Scan RFID Card".
the Mini servo begins and moves to degree 75, while the serial monitor prints, "Put your card to the reader."
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
lcd.clear();
lcd.begin(16, 2);
lcd.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
this is looking for the UID of the RFID card and when it is found the Cursor goes to (1,0), printing Access Granted while
moving the Mini Servo to degree 158, keeping it there for about 7 1/2 seconds then going back to 65 degrees, clearing
the LCD, then printing "Scan RFID card" again.
else {
lcd.clear();
lcd.setCursor(1,0);
lcd.print(" Access Denied");
delay(4000); // displays Access Denied for about 4 seconds
lcd.clear();
delay(DENIED_DELAY);
lcd.print("Scan RFID Card");
setup();
}
}
This part is when an RFID card is scanned but it is not an approved UID so "Access Denied" is displayed for about 4
seconds, then the LCD clears and says "Scan RFID Card" and the whole process restarts
In summary, this code is looking for a card while displaying "Scan RFID Card". when the incorrect card is scanned, then
the words "Access Denied" are displayed for about 4 seconds and the motor doesn't move. When the correct Card is
scanned the motor will open a certain amount of degrees to unlock the lock for about 7 seconds, displaying "Access
Granted" then it will lock again, continuing to display "Scan RFID Card".
https://vimeo.com/647551607
This is a model to show what the layout could look like on a door, with the front having the doorknob, 3d print RFID case,
LCD screen bezel, and a random piece of metal that serves as the door stopper.
The backside has the 3d printed lock, micro servo holder, the hole where the LCD screen goes, Arduino, mini breadboard,
and the negative and positive part of a breadboard that I ripped out.
So, there we go! You have made a functional RFID Security door latch for your cabinet, door, or locker.
If you wish to use this for actual security make sure to use a metal door latch from a Home improvement company, like
Home Depot, also make sure to keep the LCD and the RFID module well protected and secure to prevent tampering.