Ecesd Report
Ecesd Report
Ecesd report
Project Report
Submitted in the partial fulfillment of the requirements for the
(Assoc.Prof)
Department of ECE
Declaration
The Project Report entitled “Door Lock System Using Rfid” is a record of the bonafide work of
submitted in partial fulfillment for the subject titled “EMBEDDED CONTROLLERS &
EMBEDDED SYSTEMS DESIGN” in Dept of ECE, KL University. The results embodied in
this report have not been copied from any other departments/universities/ institutes
Certification
This is to certify that the Project Report entitled “ Door Lock System Using Rfid ”is being
submitted by Student name(Reg No), Student name(Reg No), Student name(Reg No) in partial
fulfillment for the subject titled EC&ESD(21EC2106) in Dept of ECE, KL University is a
record of bonafide work carried out under our guidance and supervision. The results embodied in
this report have not been copied from any other departments/ University/ Institute.
Acknowledgment
It is great pleasure for me to express my gratitude to our honorable President
Sri.KoneruSatyanarayana, for giving the opportunity and platform with facilities in
accomplishing the project-based laboratory report.
I express my sincere gratitude to our principal Dr. T Rama Krishna for his administration
towards our academic growth.
I record it as my privilege to deeply thank our pioneer DR. M Suman, HOD-ECE for providing
us with the efficient faculty and facilities to make our ideas into reality.
I express my sincere thanks to our project supervisor Mr.C.Preethem Reddyfor his/her novel
association of ideas, encouragement, appreciation, and intellectual zeal which motivated us to
venture into this project successfully.
Finally, it is pleased to acknowledge the indebtedness to all those who devoted themselves
directly or indirectly to make this project report successful.
CONTENTS
Content Page No
Abstract 6
Chapter 1: Introduction 7
Chapter 3: Methodology 16
Chapter 6: Simulation 30
References 34
LIST OF FIGURES
1. Block diagram 17
2. Circuit diagram 18
3 RFID Tag 19
4 Simulation Diagram 30
5 output 32
ABSTRACT
RFID, Radio Frequency Identification is an inexpensive technology, that can be implemented for
several applications such as security, asset tracking, people tracking, inventory detection, and
access control applications. The main objective of this paper is to design and implement digital
security synthetics that can deploy in a secured zone where only an authentic person can be
entered. We implemented a security system containing a door-locking system using a passive
type of RFID that can activate, authenticate, and validate the user and unlock the door in real
time for secure access. The advantage of using passive RFID is that it functions without a battery
and passive tags are lighter and less expensive than tags. A centralized system manages the
controlling, transaction, and, operation tasks. The door locking system functions in real-time as
the door opens quickly when the user put their tag in contact with reader. The system also creates
a log containing check-in and check-out of each user along with basic information of user.
CHAPTER 1: INTRODUCTION
RFID, Radio Frequency Identification is a fundamental and inexpensive technology that enables
wireless data transmission. This technology has not been very often used in industry due to a lack
of standardization among the manufacturing companies earlier. RFID technologies are efficient
and secure compare to other networks. With RFID, wireless automatic identification takes a very
specific form: the object, location, or individual is marked with a unique identifier code
contained with an RFID tag, which is in some way attached to or embedded in the target. RFID
is not a single product but a comprehensive system, a typical RFID system includes three basic
elements: RFID tag (transponder), reader (transceiver), and back-end application system (or
database), which demands the support of the computer network. The software is used for
management, controlling, transaction, operation, and maintaining the record of the various users.
6
A digital door-locking system is also implemented and governed by an RFID reader which
authenticates and validates the user and opens the door automatically. It also keeps a record of
the check-in and check-out of the user. It’s very important to authenticate the user before entering
a secure space and RFID provides this solution. The system enables users to check in and check
out under fast, secure, and convenient conditions. The system includes a door locking system
which opens when the user puts their tag in contact with the reader and the user information
matches with the information already stored in a database. The RFID controls the opening and
closing of the door. In this study, we utilize RFID technology to provide the solution for secure
access to a space while keeping a record of the user. We used a passive type of RFID here. The
passive types of RFID are battery-less, and they obtain the power to operate from the reader. The
major advantages of passive RFID are it’s cost-effective and small in the size. Due to the above
advantages, it is widely used by inventory tracking technology. Current antenna technology
makes it possible to be smaller in size. In an RFID door lock access control system, the user’s
credential (usually a key card or fob with an RFID chip) contains unique identifying
information called a tag. When the user comes within proximity of a reader, the reader’s
signal locates the information stored on the user’s RFID tag and sends it through antennas and
transceivers to authorize the tag in the access control system. Once read, the system will either
accept or deny the request to unlock the door. Data from an RFID-enabled
CHAPTER 2: REQUIREMENTS
• RFID module
• Arduino Uno
• I2C module
• Servo motor
• 16×2 LCD Display
• Door lock x 1
• Foamboard
• Iron stick
• Jumper wires
RFID MODULE
The term RFID stands for Radio Frequency Identification, as the name defines the operation
of the device based on the Radio frequency signals. The RFID system consists of an RFID
Reader and a tag which is normally used in the identification and tracking of objects. Before
discussing RFID, let’s see the uniqueness of this technology and its general application. Today in
most cases barcodes are used for identifying an item in a warehouse or a supermarket using a
barcode scanner, this existing system can be upgraded with RFID technology. Similar to
barcodes the RFID can also give unique identification numbers to all products, but the added
advantage is unlike the barcode system’s line of sight, this system can detect the RFID tag within
its proximity range. Meaning you do not need a human to search for the barcode and point the
barcode scanner at it. With this feature, most of the system can be automated and human
intervention can be minimized because the tag can be scanned and billed automatically when it
reaches the RFID reader.
An RFID reader stays powered on all the time and is normally powered by an external power
source. So when it is ON, the oscillator in it generates a signal with the desired frequency but as
the signal strength will be very less (which may lead to fading off the signal if it is transmitted
directly) it has to be amplified which can be done using an amplifier circuit, in order to propagate
the signal to a long distance we need to modulate the signal which is done by a modulator. With
all these improvements the signal is now ready to be transmitted which can be done by an
antenna that converts the electrical signal into an electromagnetic signal. RFIDs are broadly
categorized into two types mainly based on the type of RFID tag used. The two systems are
called Active RFID system and Passive RFID system. RFID is like barcoding in that data from a
tag or label are captured by a device that stores the data in a database. RFID, however, has
several advantages over systems that use barcode asset tracking software. The most notable is
that RFID tag data can be read outside the line of sight, whereas barcodes must be aligned with
an optical scanner
ARDUINO UNO
The Arduino UNO is categorized as a microcontroller that uses the ATmega328 as a controller in
it. The Arduino UNO board is used for electronics projects and is mostly preferred by beginners.
The Arduino UNO board I type of Arduino board only. The Arduino board is the most used board
of all Arduino boards. The board contains 14 digital input/ output pins of which 6 are analogy
input pins, one power jack, a USB connector, one reset button, an ICSP header, and other
components. All these components are attached to the Arduino UNO board to make it function
and can be used in the project. The board is charged by a USB port or can be directly charged by
the DC supply to the board. The board contains USB interface support that enables the board to
act as a serial device and provide the functionality to connect the board to other interfaces. The
USB interface is also used to provide a power supply to the board.
In the Arduino UNO board, there is a chip placed that is directly plugged into the USB port and
acts as a virtual type of serial port for the computer system. Through this, communication
becomes very smooth and helps the board to connect to various types of computer systems. The
microcontroller used in the Arduino UNO board ATMega328 is easy to available and can be used
easily. The board contains other components like PWM pins, timers, external interrupts or
internal interrupts, and other types of sleep modes. The board is provided as an open-source tool
that has its own advantage as a large number of users use this board and help to troubleshoot
other problems related to the board. By this, the debugging activities related to the project
become easy steps. The pins used in the board act as an oscillator that has a frequency of around
16 MHz which is beneficial for most applications. The speed of the microcontroller does not
change by this.
I2C MODULE
I2C Module has an inbuilt PCF8574 I2C chip that converts I2C serial data to parallel data for the
LCD display. These modules are currently supplied with a default I2C address of either 0x27 or
0x3F. To determine which version, you must check the black I2C adaptor board on the underside
of the module. If there are 3 sets of pads labeled A0, A1, & A2 then the default address will be
0x3F. If there are no pads the default address will be 0x27. The module has a contrast adjustment
pot on the underside of the display. This may require adjusting the screen to display text
The I2C protocol requires only an SDA and SCL pin. SDA is short for Serial Data Line and SCL
is short for Serial Clock Line. These two bidirectional lines have pull-up resistors.
Having pull-up resistors is an open drain scheme. Bus devices pull down the voltage on the bus
instead of using their own operating voltage. This allows devices with different operating
voltages to be used but only if the lower voltage is still readable by the higher-voltage device.
For example, it’s OK to connect a 3.3V I2C sensor to a 5V Arduino because the latter can still
read 3.3V. But a 5V I2C sensor will not work with a 3.3V microcontroller. The I2C bus is
currently still a common communication peripheral used by various circuits and is simple to
implement. No matter how many devices are connected to the bus, only two signal lines (clock
SCL and data SDA) are needed. It is a true multi-master bus, which is superior to SPI. In
addition, the I2C interface is also flexible which allows it to communicate with slow devices
while also having high-speed mode to transmit large data. The transmission rate can reach
100kbit/s in standard mode, 400kbit/s in fast mode, and 3.4Mbit/s in high-speed mode; Because
of how flexible it is, I2C will always remain one of the best communication peripherals to
connect devices.
SERVO METER
Have you ever thought about how a robotic vehicle commonly used in a military application with
bomb detention is controlled or how metal cutting and forming machines provide precise motion
for milling, lathes, and bending for metal fabrication, or how an antenna positioning system
controls the precision in azimuth and elevation?
As you will learn within this lesson, servo motor applications are most used in closed-loop
systems where precise position control is commonly found in industrial and commercial
10
applications. Together with the recent Real Pars published a blog post, what is a Stepper Motor
and How it Works, and this lesson, you will learn about motion control using different types of
motors available, primarily stepper and servo motors. In this lesson we will discuss what a servo
motor is and how it works, so let’s first determine what a servo motor is and examine some
unique features of the types of servo motors and their application. Let’s begin, with the servo
motor basics. Servo motors are part of a closed-loop system and are comprised of several parts
namely a control circuit, servo motor, shaft, potentiometer, drive gears, amplifier, and either an
encoder or resolver.
A servo motor is a self-contained electrical device, that rotates parts of a machine with high
efficiency and with great precision. The output shaft of this motor can be moved to a particular
angle, position, and velocity that a regular motor does not have. The Servo Motor utilizes a
regular motor and couples it with a sensor for positional feedback. The controller is the most
important part of the Servo Motor designed and used specifically for this purpose.
The motor is controlled with an electric signal, either analog or digital, which determines the
amount of movement which represents the final command position for the shaft.
A type of encoder serves as a sensor providing speed and position feedback. This circuitry is
built right inside the motor housing which usually is fitted with a gear system.
The servo motor is a closed-loop mechanism that incorporates positional feedback in order to
control the rotational or linear speed and position.
16×2 LCD is 32 digits display screen for all kinds of CMOS/TTL devices. This word comes
from the liquid crystal and 16X2 represents its screen size. In the Liquid crystal display 16×2,
there are 2 rows and 16 columns. Besides, 5×8 pixel makes a single digit. Any digit from the
ASCII code is viewable on the module. It supports custom signs and designs but those require
some specific methods and have some limitations. This display module has too much use in most
commercial projects and there is almost a library in every programming language about it. The
premade libraries made it easy to interface with other devices. There are two section pins on the
whole 16×2 LCD module. Some of them are data pins and some are command pins. Somehow,
every pin has a role in controlling a single pixel on the display.
11
In the LCD the registers are used to store the data and commands. The command registers store
the data of different functions that can be performed on the screen. The Data registers help to
store the data and then pass it to the controller. The Data and command registers are only able to
store the operation of basic light control. The liquid crystals are placed between the two glass
sheets on the screen. The two sheets are also placed between these sheets. The sheets are used to
stop the lights basic principle in LCD is the passing of light from one layer (sheet) to another
layer with the use of modules. The modules vibrate and align their position at 90 degrees, which
allows the polarized sheet to pass the light through it. The molecules are responsible for showing
the data on each pixel. Each pixel uses the light-absorbing method to show the digit. To show the
value, molecules need to change their position to change the angle of light. So, this deflection of
light will make the human eye see the light of the remaining part which will make the dark part a
value and digits on the grid pixels. The data, we can see, will be the part where the light gets
absorbed. The data will pass toward the molecules and will be there until they are changed.
DOOR LOCK
Most people don't think of door locks as anything special. Because we use them regularly —
when we go to the bathroom, when we leave home for the day, when we get in and out of our
cars — they're often considered mundane and ignored. However, the lock hidden inside the
average door is much more complex than you might expect. Though there are slight differences
depending on the lock's manufacturer, there are three primary parts of a door lock to keep in
mind when learning about the way they work. Understanding the function of each part can help
you troubleshoot problems with a lock on your own, which might save you a call to your local
locksmith if trouble comes around. Every door lock has both internal and external components.
Door handle or doorknob parts — in addition to the keypad or scanner on an electronic lock —
can be considered external, while the internal parts are composed of everything hidden inside the
door and everything behind the key slot. The internal components can be considered the lock
itself
12
These are the parts of the lock assembly that secure the door and allow it to be opened by using
the appropriate key, while the external components are used to operate the door or interact with
the locking mechanisms. While the shape and style of the external components can vary
depending on the type of doorknob or handle or whether you unlock the door with a traditional
metal key, your fingerprint, or a card, the internal components will always involve a spring latch
or deadbolt, secured with a box and strike plate. These latches or bolts are extended or retracted
by the mechanisms in the lock's body. The lock body, or lock cylinder, is the core of a door lock.
The lock body turns to engage or disengage the lock's bolt or latch when the appropriate key is
used. In a mechanical lock, the lock body uses a series of spring-loaded pins to allow or stop the
turning. The combination of pins that need to be pushed to turn the lock is unique to each lock
body and matches the grooves of the door's key. When the key is inserted, it allows the lock body
to turn. In an electronic lock, small, motorized components controlled by the keypad, scanner or
wireless signal reader control the bolt or latch — sometimes alongside a mechanical lock's pins
and sometimes replacing the pin system entirely. When the appropriate code or key signal is
read, an electronic signal engages the bolt or latch by way of a motor. This is more secure than a
mechanical lock, but it is also more expensive to maintain.
FORMBOARD
Foam board is a material that you have probably seen but may not have known or understood
exactly what it was, its uses, and how versatile it is. So, what is foam board? Here’s the definitive
description of what foam board is, along with what it’s used for. Starting with the quick answer.
A Foam board or foam core board is a rigid, lightweight material that can be moulded or
fabricated into shapes and painted. Commonly used in architecture, design, costumes, and props,
mounting prints, displays, and picture frame backing. It consists of three layers that can easily be
cut with a knife. Well, that’s the simple summary. But let’s go on to describe exactly what foam
board is, and other aspects. There are many types of foam boards on the market, each best suited
to certain needs. Some of the common types of foam board include: Self-adhesive, Heat-
activated, Modelling board, Digital print, Bright white, Heavy-duty, and Smooth Aside from
13
these, foam board types, like other types of foam, also differ based on one of two finishes: matte,
or glossy.
Foamboard belongs to the family of graphic artboards. It can be mounted, printed, and laminated.
It’s used for different display purposes and comes in a variety of thicknesses, sizes, and densities.
It is often the choice of material for model makers, designers, prop specialists, and more, as it
provides an excellent array of applications that require rigidity yet is a lightweight and versatile
material that can be accurately cut, molded, and fabricated, as well as painted. Foam boards are
commonly used for displays at trade shows and presentations, architectural models, and
structures. Some also use foam board signs in events or to display sales at fairs. As they can be
easily formed into shapes. Foam boards are often used for interior design, costume and film prop
design, and art.
IRON STRICK
The iron strike is a type of steel that has strength and hardness making it ideal for many projects
such as bridges, buildings, and machines iron strike can be used to form parts or beams with
complex shapes and sizes depending on the desired properties and applications. Iron strike can
also be welded, cold rolled, hot rolled, or galvanized to enhance its correction resistance and
durability. The iron strike is a type of steel that has high strength and hardness, making it ideal
for many projects such as bridges, buildings, and machines. Iron strikes can be used to form parts
and plates. Or beams with complex shapes and sizes, depending on the desired properties and
applications. Iron strike can also be welded, cold rolled, hot rolled, or galvanized to enhance its
correction resistance and durability.
14
In the mechanics of materials, the strength of a material is its ability to withstand an applied load
without failure or plastic deformation. The strength of materials basically considers the
relationship between the external loads applied to a material and the resulting deformation or
change in material dimensions. In designing structures and machines, it is important to consider
these factors, in order that the material selected will have adequate strength to resist applied
loads or forces and retain its original shape. The strength of a material is its ability to withstand
this applied load without failure or plastic deformation.
JUMPER WIRES
Jumper wires are simply wires that have connector pins at each end, allowing them to be used to
connect two points to each other without soldering. Jumper wires are typically used
with breadboards and other prototyping tools to make it easy to change a circuit as needed. Fairly
simple. In fact, it doesn’t get much more basic than jumper wires. Though jumper wires come in
a variety of colors, the colors don’t mean anything. This means that a red jumper wire is
technically the same as a black one. But the colors can be used to your advantage in order to
differentiate between types of connections, such as ground or power. Jumper wires typically
come in three versions: male-to-male, male-to-female, and female-to-female. The difference
CHAPTER 3: METHODOLOGY
RFID system constitutes of namely two components, which are tag and receiver. A high-
frequency electromagnetic field produced by a control unit, a module of radio frequency, and an
antenna coil constitute to make up an RFID reader. The tag, on the other hand, is a passive
component that consists just of an electronic microchip and an antenna, so when it comes into
contact with the transceiver's electromagnetic field, voltage is generated via induction in the
antenna coil, which functions as power for the microchip.
15
A plastic-covered smart chip is used by these RFID key cards that utilize a particular frequency
to transmit a signal to the reader. Generally, the reader is placed on the door, which analyses the
information recorded from the card and unlocks the door when it is within a specific distance of
the reader. The door can be unlocked after this, which will autonomously lock when closed
again.
There will typically be a reader attached to the door which reads the information stored on the
card and releses the door lock when the card is presented with in a sufficient proximity of the
reader. Once the lock has been released the door can be opened and will automatically lock once
the door close again
In this the radio waves to transmit signals that active the tag. Once activated the tag sends a wave
back to the antenna where it is translated into data. The transponder is in the RFID tag itself
LCD DISPLAY
SERVO
MOTOR
DC POWER SUPPLY
From the block diagram we can understand that by the RFID tag will transmit the signal to the
RC522 RFID reader module it collects the information and it check the signal is related to the
old given input if the it is wrong input it send another output has wrong input it not open the door
like input or if it is right it send the signal of give permission to open the door and after that it
transmit that signal to Arduino uno. Arduino uno will see the information it pass that to the servo
17
The RFID system consists of two components: an RFID tag and a Reader. The RFID tag
consist of integrated circuit and an antenna, integrated circuit is for the storage of the data, and
an antenna is for transmitting the data to the RFID Reader module. Whenever the RFID tag
comes in the range of an RFID reader, an RF signal power the tag, and then the tag starts
transmitting data serially. Data is further received by the RFID reader and the reader sends it to
the Arduino board. And, after that as per the code in the micro-controller different tasks are
performed.
In our circuit, we have already saved the value of the RFID tag in the code. So, whenever that tag
comes in range, the relay gets activated. Here we have connected a LED with the Relay to
demonstrate, but this LED can be replaced by an Electric Door Lock so that whenever the Relay
gets activated the lock will be opened.
If we scan any other RFID card, the buzzer will start beeping as it’s the wrong RFID tag. Hence,
for the door lock system, we have used the concept that the door will only get opened by using
the right RFID tag. The relay will itself get deactivated after 5 seconds, the door will be closed
after 5 seconds, and you can change this delay in the code.
CODE
19
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
String UID = "";
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(3);
SPI.begin();
rfid.PCD_Init();
}
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 :");
20
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();
CODE EXPLANATION
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
Second, the RST and SDA pins are defined. Also, a string variable is created for placing the UID.
#define SS_PIN 10
#define RST_PIN 9
String UID = “”;
Third, three objects have been created for Servo, I2C, and RFID.
Servo servo;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 rfid(SS_PIN, RST_PIN);
In the setup function, the Serial monitor, LCD, SPI bus, servo, and RFID module are started.
Also, the servo motor rotates 70 degrees.
void setup() {
Serial.begin(9600);
servo.write(70);
lcd.init();
lcd.backlight();
servo.attach(3);
SPI.begin();
rfid.PCD_Init();
}
In the loop function, first printed on the LCD is “Welcome, put your card”.
lcd.setCursor(4, 0);
lcd.print(“Welcome!”);
lcd.setCursor(1, 1);
lcd.print(“Put your card”);
Also, the second code part reads the RFID tag. At that point, appears as “scanning” on the LCD.
if ( ! rfid.PICC_IsNewCardPresent())
return;
if ( ! rfid.PICC_ReadCardSerial())
return;
22
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();
Next, the third part of this code tests this UID using the IF condition. Also, the servo motor
rotates 70 degrees and 160 degrees. Then, the lock moves forward and backward. On the LCD
appears as “Door open” and “Door locked”. If the RFID tag is incorrect, it will be printed as
“Wrong Card” on the LCD display.
MAIN CODE
23
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
String UID = "";
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(3);
SPI.begin();
rfid.PCD_Init();
}
void loop() {
lcd.setCursor(4, 0);
24
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();
25
servo.write(160);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Door is open");
delay(1500);
lcd.clear();
lock = 0;
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Wrong card!");
delay(1500);
lcd.clear();
}
}
CODE EXPLANATION
Firstly, servo, SPI, I2C, and RFID libraries are included.
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
26
Second, the RST and SDA pins are defined. Also, a string variable is created for placing the UID.
#define SS_PIN 10
#define RST_PIN 9
String UID = “”;
Third, three objects have been created for Servo, I2C, and RFID.
Servo servo;
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 rfid(SS_PIN, RST_PIN);
In the setup function, the Serial monitor, LCD, SPI bus, servo, and RFID module are started.
Also, the servo motor rotates 70 degrees.
void setup() {
Serial.begin(9600);
servo.write(70);
lcd.init();
lcd.backlight();
servo.attach(3);
SPI.begin();
rfid.PCD_Init();
}
In the loop function, first printed on the LCD is “Welcome, put your card”.
lcd.setCursor(4, 0);
lcd.print(“Welcome!”);
lcd.setCursor(1, 1);
lcd.print(“Put your card”);
27
Also, the second code part reads the RFID tag. At that point, appears as “scanning” on the LCD.
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();
Next, the third part of this code tests this UID using the IF condition. Also, the servo motor
rotates 70 degrees and 160 degrees. Then, the lock moves forward and backward. On the LCD
appears as “Door open” and “Door locked”. If the RFID tag is incorrect, it will be printed as
“Wrong Card” on the LCD display.
28
lcd.clear();
lock = 1;
} else if (ID.substring(1) == UID && lock == 1 ) {
servo.write(160);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Door is open”);
delay(1500);
lcd.clear();
lock = 0;
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Wrong card!”);
delay(1500);
lcd.clear();
}
CHAPTER 6: SIMULATION
29
30
Initially, the IR sensor module checks whether the door is open or closed. When the door is open
the IR sensor produces High (1) output value from the output pin. The Arduino reads this value
and understands the door is open, then sends a command to the servo motor to pull back the
barrel handle of the sliding lock to unlock the door. This time the LCD display screen shows the
message “Door is Open! Close The Door”, and the Red LED starts blinking and the buzzer
generates the “Beep Beep” sound. In this condition, the RFID Reader Module does not read the
card and key fob tags.
When the door is closed the IR sensor produces Low (0) output value from the output pin. Again
the Arduino reads this value and understands the door is closed, then sends a command to the
servo motor to push the barrel handle of the sliding lock forward to lock the door. This time the
LCD display screen shows the message “Welcome – Scan Your Card>>”, and the Red LED is
turned on. In this condition, the RFID Reader Module is Ready to read the card and key fob tags.
When an RFID Card/tag comes in the range of the RFID Reader Module (transceiver), it is
scanning the Card/tag and reads the value. Then Arduino Nano board reads this value from the
RFID Reader and matches this value with the pre-defined value in the code. Already we have
saved the value of the Card/tag in the code.
If the Card/tag value is matched, then the Arduino produces PWM output from Pin 6 to activate
the servo motor. Now the servo motor will pull back the barrel handle of the sliding lock
to unlock the door. For a few seconds, the LCD display screen shows the message “Welcome,
Door is Open”, and the Green LED starts blinking, and the buzzer generates the “Beep Beep”
sound.
After this time if the door is not closed then the LCD display screen shows the message
“Door is Open! Close The Door”, and the Red LED starts blinking and the buzzer
generates the “Beep Beep” sound.
If the door is closed during this time period, then the servo motor pushes the barrel
handle of the sliding lock forward to lock the door. Now the system is ready to read the
cards again.
CHAPTER 8: CONCLUSION
31
In this study, we have implemented a digital security system containing a door lock system using
passive RFID. A centralized system is being deployed for controlling and transaction operations.
The door locking system functions in real time as when the user puts the tag in contact with the
reader, the door opens, and the check-in information is stored in the central server along with
basic information of the user. We utilize RFID technology to provide solutions for secure access
of space while keeping a record of the user.
FUTURE SCOPE
32
A hex keypad can be interfaced to microcontroller board by which user can enter his
password then only the lock can be opened. This ensures even if some one has card, then
also without the password, he can’t get the access
Connection to pc and development of PC side software to read from microcontroller
Implementing the security system with different levels by using different types of Mi fare
cards
Cryptanalysis of the link between the card and the reader
Study of other RFID techniques for better service and security
Interfacing the system with a GSM so that data can be transmitted through messages
Attendance system in educational institutions and other workplaces
Bank locker secured access
General framework to implement any other RFID-based applications
Warehouses and storage places where lot inventory movement is expected
REFERENCES
33
1. Zeydin Pala and Nihat Inan, “Smart parking application using RFID technology”, RFID
Eurasia, 1st Annual in RFID Eurasia, 2007.
2. Zhang, L., “An Improved Approach to Security and Privacy of RFID application
System”, Wireless Communications, Networking and Mobile Computing. International
Conference. pp 1195- 1198, 2005.
3. Xiao, Y., Yu, S., Wu, K., Ni, Q., Janecek., C., Nordstad, J,” Radio frequency
identification: technologies, applications, and research issues” Wiley Journal of Wireless
Communications and Mobile Computing, Vol 7, May 2007.
4. Goodrum, P., McLaren, M., Durfee, A.,” The application of active radio frequency
identification technology for tool tracking on construction job sites.” Automation in
Construction, 15 (3), 2006, pp 292-302.
6. Yu-Chih Huang; ”Secure Access Control Scheme of RFID System Application”, Fifth
International Conference on Information Assurance and Security, China, 2009.
34