Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Heaven’s Light is our Guide

Rajshahi University of Engineering & Technology

Department of Electrical & Electronic Engineering, RUET

Group Project

Course No: EEE 4210


Course Title: Embedded System Design Sesional
Project Name: Arduino Nano-Based RFID Door Access Control using RUET ID Card

Submitted To:
Md. Mayenul Islam
Lecturer
Department of Electrical & Electronic Engineering, RUET

Submitted By:
Group Members:
1.Omar bin Harun- 1801103
2.Nasrin Sultana-1801106
3.Ahasanur Rahman Akash -1801109
1.1 Introduction
An RFID access control system is a type of key card or fob system that uses RFID technology to
verify a resident’s credentials.
RFID stands for Radio Frequency Identification. At its core, RFID enables wireless communication
between a reader and an RFID tag.
When RFID was invented in the 70s, RFID tags were costly and bulky. However, advances in
technology mean today’s RFID tags are tiny and inexpensive. Many industries have found countless
uses for RFID technology, from shipping to library cataloging and now access control.
RFID technology, as applied to access control, is found across a variety of buildings. RFID access
systems are used in residential apartments and industrial facilities, and commercial RFID door lock
systems for office complexes are popular as well.
RFID access control uses a system of tags, readers, and computer servers to allow door access to
registered residents who present the correct credentials.

There are two types of RFID access control systems: active and passive.

Active and passive RFID access control systems have different methods of establishing a connection
between an RFID tag and a reader. However, the overall process of using both systems remains the
same.
Active RFID tags use batteries, while passive RFID technology doesn’t. This means active RFID tags
power themselves when they interact with a reader, while passive tags must harvest power from the
reader’s electromagnetic field.
Some active readers are powerful enough to activate without even having to physically come in
contact with a reader, making active readers a popular choice for RFID touchless entry system
providers. On the other hand, while passive tags don’t need to be replaced as often, they have a shorter
range and aren’t as powerful.
1.2 Block Diagram of the Project

Passive RFID
Module

RFID
Module

LCD
Keypad Arduino Nano Display

LED

Solenoid
Buzzer
Lock

Fig 01: Block Diagram of RFID Door Access Control.


1.3 Flow Chart
1.4 Project Components
Arduino Nano V3:
The Arduino Nano is Arduino's classic breadboard-friendly board with the smallest dimension but
still all beginner-friendly features available. The Arduino Nano comes with pin headers that allow
for an easy attachment onto a breadboard and features a Mini-B USB connector.
The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328P.
It offers the same connectivity and specs as the UNO board in a smaller form factor. As the board
can be placed on a PCB with some female pin headers it was a perfect choice for the project.

MRF522 RFID Module:


An Radio Frequency Identification system consists of two main components, a tag attached to the
object to be identified, and a reader that reads the tag. A reader consists of a radio frequency module
and an antenna that generates a high-frequency electromagnetic field. Whereas the tag is usually a
passive device (it does not have a battery). It consists of a microchip that stores and processes
information, and an antenna for receiving and transmitting a signal. When the tag is brought close
to the reader, the reader generates an electromagnetic field. This causes electrons to move through
the tag’s antenna and subsequently powers the chip. The chip then responds by sending its stored
information back to the reader in the form of another radio signal. This is called backscatter. The
reader detects and interprets this backscatter and sends the data to a computer or microcontroller.
The RC522 RFID module based on this one of the cheapest RFID options one can get online for
less than 200tk.

4×3 Matrix Display:


Matrix keypads are the kind of keypads are on cell phones, calculators, microwave ovens, door
locks, etc. They’re practically everywhere. Membrane keypads are made of thin, flexible
membrane material. They do come in many sizes 4×3, 4×4, 4×1, etc. Regardless of their size, they
all work in the same way.
One of the great things about them is that they come with an adhesive backing so one can attach it
to nearly anything.

16x2 LCD
An LCD (Liquid Crystal Display) screen is an electronic display module and has a wide range of
applications. A 16x2 LCD is a very basic module and is very commonly used in various devices
and circuits. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In
this LCD each character is displayed in a 5x7 pixel matrix. The 16 x 2 intelligent alphanumeric
dot matrix display is capable of displaying 224 different characters and symbols. This LCD has
two registers, namely, Command and Data.

12V Solenoid Lock


12V Solenoid lock has a slug with a slanted cut and a good mounting bracket. It's basically an
electronic lock, designed for a basic cabinet, safe or door. When 9-12VDC is applied, the slug pulls
in so it doesn't stick out and the door can be opened. It does not use any power in this state.
12V LCD Adapter
The 12 Volt Adapter with a rated current of 2Amp, an original rating of 0.95amp Power Supply is
used in Pads, Laptop computers, lighting, mobile equipment, and many more. They are now
finding their way into more consumer toys, games, and other home goods.

Buzzer
Buzzer: A buzzer or beeper is an audio signaling device. Which may be mechanical,
electromechanical, or piezoelectric (piezo for short). Typical uses of buzzers and beepers include
alarm devices, training, and confirmation of user input such as a mouse click or keystroke. The
rating of this Buzzer was 5V.

LED
A light-emitting diode is a two-lead semiconductor light source. It is a p–n junction diode that
emits light when activated. When a suitable voltage is applied to the leads, electrons are able to
recombine with electron holes within the device, releasing energy in the form of photons. The LED
used in this project is red.

BJT
A bipolar junction transistor is a three-terminal semiconductor device that consists of two p-n
junctions which are able to amplify or magnify a signal. It is a current controlled device. The three
terminals of the BJT are the base, the collector, and the emitter. BD 135(1.5A,45V) and 2N2222
BJT (800mA, 40V) are used in this project. Here BD 135 is used to drive the relay whereas 2N2222
BJT is used to amplify the current of the buzzer. 2N2222 BJT is easy to find and one of the cheapest
BJT at market price.

Diode
A diode is a two-terminal Electrical device. Diodes are made from a semiconductor, most often
silicon but sometimes germanium. There are many types of diodes such as Zener, Rectifier,
Transient Voltage Suppressor, Thyristor, Silicon Controlled Rectifier, and TRIAC. Diod-1N4007
is a flyback diode. This is cheap as well as available in any Tech=shop

Opto Isolator
An opto isolator (also known as an optical coupler) is a semiconductor device that transfers an
electrical signal between isolated circuits using light.These electronic components are used in a
wide variety of communications and monitoring systems that use electrical isolation to prevent
high voltage emitters from affecting lower power circuitry receiving a signal. PC817 Optoisolator
is being used in this project.

Resistors
The resistor is a passive electrical component that creates resistance in the flow of electric current.
In almost all electrical networks and electronic circuits they can, be found. The resistance is
measured in ohms (Ω). Two resistors of (1/4) W and 5W is used.

Capacitors
A capacitor is a device that stores electrical energy in an electric field. It is a passive electronic
component with two terminals. Capacitor, a device for storing electrical energy, consisting of two
conductors in close proximity and insulated from each other. A simple example of such a storage
device is the parallel-plate capacitor.

Reset Push Button


Push-button reset is a recovery tool that repairs the OS while preserving data and important
customizations. It reduces the need for custom recovery applications by providing users with more
recovery options and the ability to fix their own PCs with confidence.

Header (Rails)
Pin headers are stiff metallic connectors that are soldered to a circuit board and stick up to receive
a connection from a female socket. While pin headers (often called PH, or headers) are male by
definition, female equivalents are also quite common, and we refer to them as female headers (FH)
or header connectors. The female header is used to
Avoid direct soldering of the components
Makes the circuit functional despite one of the components being damaged.
Flexibility to replace the components

Card Board
Cardboard is a generic term for heavy paper-based products. The construction can range from a
thick paper known as paperboard to corrugated fiberboard which is made of multiple plies of
material.

Glue Stick
Most glue sticks are designed to glue papers and card stock together and are not so strong as some
liquid-based variants. They can be used for craft and design, office use, and at school.

PCB
A printed circuit board (PCB) is a thin board made from fiberglass, composite epoxy, or other
laminate materials. PCBs are found in various electrical and electronic components such as
beepers, radios, radars, computer systems, etc. Different types of PCBs are used based on the
applications. A printed circuit board (PCB) is the board base for physically supporting and wiring
the surface-mounted and socketed components in most electronics. We use it to connect the devices
DC Barrel Connector
Barrel connectors are typically found on low-cost consumer electronics which can be plugged into
wall power via bulky AC wall adaptors. Wall adaptors are widely available, in a variety of power
ratings and voltages, making barrel connectors a common means for connecting power to small
projects.5.5 mm DC barrel Connector.

PH Connector
This is a thin, low-profile 2.0mm pitch connector 8.0mm in height after mounting and 4.5mm in
width. It is designed to meet the demand for high-density connection of internal wires to printed
circuit boards. It is compact, highly reliable, and low in cost.
1.5 Required Components
Arduino Nano V3
MRF522 RFID module
4x3 matrix keypad
16x02 LCD
12C LCD adapter
12V Solenoid lock
12V adapter (rated 2Amp, original rating 0.95 amp)
5V Buzzer
LED(RED)
BD 135 Transistor
2N2222 Transistor
Diode(1N4007)
PC817 Opto-couple

1.6 Cost Estimation of total project:


Serial Part Name Quantity Price no

01 Arduino Nano V3 1 850 /=


02 MRF522 RFID module 1 140 /=
03 4x3 matrix keypad 1 100 /=
04 16x02 LCD display 1 230 /=
05 I2C LCD adapter 1 100 /=
06 12V solenoid lock 1 450 /=
07 12 V adapter(rated 2Amp, 1 150 /=
original rating 0.95 amp)
08 5V buzzer 1 10 /=
09 LED (red) 1 4 /=
10 BD135 BJT 1 10 /=
11 2N2222 BJT 1 8 /=
12 Diode(1N4007) 3 6 /=
13 PC817 Opto-coupler 10 /=
14 Resistors 1/4W 4 1 /=
5W 1 10 /=
15 Capacitors 5 20 /=
16 Reset Push button 1 5 /=
17 Header(rails) 40 80 /=
18 Card Board 1 100 /=
19 Glue stick 1 25/=
20 PCB 8 / inch2 128/=
21 5.5 mm DC barrel connector 1 5/=
22 PH connector 1 10/=

Total BDT 2412 only

1.7 Methodology:
Step 1: First of all we uploaded the example sketches from Arduino ide to an Arduino UNO,
connected the RFID as instructed, and learned to use it
Step 2: By following the same method described in step 1 we learned to use a 5v buzzer, the LCD
display with an I2C module, and the keypad.
Step 3: We make the flow chart of the code in this step and programmed the code step by step. We
debugged the code when necessary.
Step 4: Then we make comments in the code so that it is well documented and easy to understand
for all.
Step 5: Then we prototyped the hardware and software part altogether and checked if everything
works perfectly. We modified the circuit slightly where necessary, for example, the relay seems to
become too hot when we run it in 12v, so we added an extra 5w resistor between the emitter pin
and GND pin of the BJT so that the relay operates at a lower voltage.
Step 6: Then we designed a PCB with ECAD software. We used EasyEDA for the purpose. We
designed the PCB in such a way that it can easily be manufactured locally.
Step 7: Then we make the PCB ourselves and make all the connections.
Step 8: At last we soldered all the components and decorated the project nicely so that it can be
explained to anybody easily.
1.8. PCB Layout of the project

Figure 1: Schematic design for PCB

Figure 2: TOP COPPER DESIGN


Figure 3: Bottom copper Design

1.9

Figure: RFID Door Access Control


1.10 Arduino Code

/*This code is written for a Project named Arduino Nano-Based RFID Door Access Control
using RUET ID Card
* It is a project for Embedded System Design
* of Department of EEE-Rajshahi University of Engineering & Technology
* The team members of this project are
* Roll no Name
* 1801103 Omar Bin Harun
* 1801106 Nasrin Sultana
* 1801109 Ahasanur Rahman Akash * Course Teacher :
* Md. Mayenul Islam
* Lecturer
* Department of EEE
* RUET
*/

/*
* The system scans any RFID tags and asks for password from the known tags
* An 3x4 matrix keypad is used to enter the password
* Entering correct password unlocks the door for 10 seconds and
* a countdown is shown on the lcd display
*/
#include <SPI.h> //Including SPI communication library
//A Serial Peripheral Interface (SPI) bus is a system for serial communication,
//which uses up to four conductors, commonly three.
//One for receiving data, another for sending,
//one for synchronization and one for selecting a device to communicate with.
#include <MFRC522.h> //Including MFRC522 library. this library is used for
programming the RFID module

#include <Wire.h> // Include Arduino Wire library for I2C


#include <LCD_I2C.h> // Include LCD display library for I2C #include
<Keypad.h> //Including classical matrix type keypad library int i;
const int doorlock=8; //connect pin 8 of the arduino uno with door lock sensor input pin
//lock should be connected with a proper bjt of FET switch
//To drive the solinoid lock or any type of relay opto-isolator is used
//to protect the microcontroller from surge currents and back emf const int
buzzer=7; //connect pin 7 of the arduino uno with a buzzer
//through atleast 100 ohm resistor not overload the GPIO pin #define
Password_Length 7 // Length of password + 1 for null character char
Master[Password_Length] = "123456"; // Password
void printHex(byte *buffer, byte bufferSize); void
printDec(byte *buffer, byte bufferSize);
const byte ROWS = 4; const
byte COLS = 3;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};

byte rowPins[ROWS] = {14, 15, 16, 17}; //connect r1,r2,r3,r4 of keypad with these pins byte
colPins[COLS] = {2, 3, 4}; //Connect c1,c2,c3,c4 of keypad with these pins

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS,


COLS);
LCD_I2C lcd(0x27, 16, 2); // CreateS LCD object
/*
MFRC-522 RFID door lock
* Typical pin layout used:
* -----------------------------------------------------------------------------------------
* MFRC522 Arduino Arduino Arduino Arduino Arduino
* Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
* Signal Pin Pin Pin Pin Pin Pin
* ----------------------------------------------------------------------------------------- *
RST/Reset RST 9 5 D9 RESET/ICSP-5 RST * SPI SS
SDA(SS) 10 53 D10 10 10
* SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
* SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 * SPI SCK
SCK 13 / ICSP-3 52 D13 ICSP-3 15
*/
constexpr uint8_t RST_PIN = 9; // Configurable, see typical pin layout above constexpr
uint8_t SS_PIN = 10; // Configurable, see typical pin layout above

MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;

// Init array that will store new NUID


byte nuidPICC[7];

void setup() { Serial.begin(9600);


SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
lcd.begin(); //Init LCD
lcd.backlight(); //Turns on LCD backlight
pinMode(doorlock,OUTPUT);
pinMode(buzzer,OUTPUT);

for (byte i = 0; i < 6; i++) {


key.keyByte[i] = 0xFF;
}

Serial.println(F("This code scan the MIFARE Classsic NUID."));


Serial.print(F("Using the following key:"));
//printHex(key.keyByte, MFRC522::MF_KEY_SIZE);
}

void loop() { lcd.clear();


lcd.setCursor(0,0);
lcd.print("Scan Your ID");
//Look for new cards
if( ! rfid.PICC_IsNewCardPresent())
return;

// Verify if the NUID has been readed


if( ! rfid.PICC_ReadCardSerial())
return;

Serial.print(F("PICC type: "));


MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
Serial.println(rfid.PICC_GetTypeName(piccType)); for (byte i = 0; i
< 7; i++) { //Store NUID into nuidPICC array nuidPICC[i] =
rfid.uid.uidByte[i];
}
Serial.println(F("The NUID tag is:"));
Serial.print(F("In hex: "));
printHex(rfid.uid.uidByte, rfid.uid.size);
Serial.println();
Serial.print(F("In dec: "));
printDec(rfid.uid.uidByte, rfid.uid.size);
Serial.println();
//this type of section should be added with each new RFID keys

if(nuidPICC[0]==195&&nuidPICC[1]==171&&nuidPICC[2]==233&&nuidPICC[3]==24){
Serial.print(F("Hi Roboboy.PLease enter your password"));
password(); for(i=0;i<7;i++){ nuidPICC[i]=0;
}
}
//section ends
else
if(nuidPICC[0]==140&&nuidPICC[1]==103&&nuidPICC[2]==217&&nuidPICC[3]==56){
Serial.print(F("Welcome KBM. Please Enter your password"));
password(); for(i=0;i<7;i++){
nuidPICC[i]=0;
}
}
else
if(nuidPICC[0]==04&&nuidPICC[1]==115&&nuidPICC[2]==131&&nuidPICC[3]==82){
if(nuidPICC[4]==207&&nuidPICC[5]==73&&nuidPICC[6]==128){//Nasrin
Serial.print(F("Welcome Nasrin. Please Enter your password"));
password(); for(i=0;i<7;i++){
nuidPICC[i]=0;
}
}
}
else
if(nuidPICC[0]==04&&nuidPICC[1]==28&&nuidPICC[2]==102&&nuidPICC[3]==82){
if(nuidPICC[4]==207&&nuidPICC[5]==73&&nuidPICC[6]==128){//Talha
Serial.print(F("Welcome Talha. Please Enter your password"));
password(); for(i=0;i<7;i++){
nuidPICC[i]=0;
}
}
}
else
if(nuidPICC[0]==04&&nuidPICC[1]==49&&nuidPICC[2]==143&&nuidPICC[3]==82){
if(nuidPICC[4]==207&&nuidPICC[5]==73&&nuidPICC[6]==128){ //Ahsanur
Serial.print(F("Welcome Ahsanur. Please Enter your
password")); password(); for(i=0;i<7;i++){
nuidPICC[i]=0;
}
}
}
else{
Serial.print(F("unknown id, access denied"));
lcd.clear(); lcd.setCursor(0,0); lcd.print("
Unknown ID"); lcd.setCursor(0,1);
lcd.print(" Access denied"); for(i=0;i<3;i++){
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(300); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(300); // ...for 1sec

}
delay(1000);
}
// Halt PICC
rfid.PICC_HaltA();

// Stop encryption on PCD


rfid.PCD_StopCrypto1();
}

/**
* Helper routine to dump a byte array as hex values to Serial.
*/
void printHex(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}
/**
* Helper routine to dump a byte array as dec values to Serial.
*/
void printDec(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], DEC);
}
}
byte data_count = 0; // Counter for character entries char
Data[Password_Length];// Character to hold password input char
customKey;// Character to hold key input int TimeCount;
void password(){ // a function that checks Password and opnes the lock
delay(500); lcd.clear(); lcd.setCursor(0, 0);
lcd.print("Enter Password:");
Serial.print("Enter Password:");
while(data_count < Password_Length - 1){
customKey = customKeypad.getKey(); // Look for keypress
if (customKey) {
Data[data_count] = customKey; // Enter keypress into array and increment counter
lcd.setCursor(data_count, 1); lcd.print(Data[data_count]);
Serial.print(Data[data_count]); data_count++;
}
} // See if we have reached the password length
lcd.clear();
if (!strcmp(Data, Master)) { // Password is correct
lcd.print("Correct"); Serial.print("Correct\n");
delay(500);
digitalWrite(doorlock, HIGH);
for(TimeCount=0;TimeCount<10;TimeCount++){
lcd.clear();
lcd.print("Door is Open for");
Serial.print("Door is Open for");
lcd.setCursor(4,1); lcd.print(10-
TimeCount); Serial.print(10-
TimeCount); lcd.print(" Seconds");
Serial.print(" Seconds\n");
delay(1000);
}
digitalWrite(doorlock, LOW);
lcd.clear();
lcd.print("Door Closed");
Serial.print("Door closed\n");
delay(2000);
}
else {
// Password is incorrect
lcd.clear();
lcd.print("Incorrect");
Serial.print("Incorrect\n"); for(i=0;i<3;i++){
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(300); // ...for 1 sec noTone(buzzer);
// Stop sound...
delay(300); // ...for 1sec

}
delay(1000);
}
lcd.clear(); // Clear data
while (data_count != 0) {
Data[data_count--] = 0;
}
}

1.11 Conclusion
The project was successful and we found the interesting fact that there is a built-in RFID chip
inside our University ID cards that is ISO standard. So some modified versions of the system may
be used for different purposes of the Institute. For example by introducing fingerprint verification
of the user
Instead of password the same system can be used to take attendance of the students. That will save
a lot of time and Productivity can be increased. So it can be concluded that it is a successful project
and further optimization and modification of the same project may solve different real life issues.

You might also like