You are currently viewing RFID MFRC522 Door Access System DIY Kit

RFID MFRC522 Door Access System DIY Kit

SuperKitz.com ​Project Manual

Door Security System​ using RFID(MFRC522) DIY Kit

Using MFRC522 RFID sensor

In this project, we design an Arduino based RFID door lock system used in the access control mechanism. Arduino makes designing easy, so as by programming code and upload it to Arduino just like a plug and play device makes a simple and cost-efficient project.
Here the door is opened using a tag that functions as an access badge. If the wrong tag scanned, the door stays closed. Only the person with the right information allowed to enter the door. Their main advantage is that contactless communication and RFID tags can work in any environmental condition. Sg90 servo motor controls the opening and closing of the door with Arduino UNO as its controlling unit.

 

Requirements :

  • Computer with an internet connection
  • Download and install Arduino IDE

Components

1. MFRC522 RFID sensor

1 nos

2. Arduino UNO

1 nos

mini breadboard

3. Breadboard

1 nos

4. 16 * 2 LCD (parallel interface)

1 nos

5. servo motor sg90

1 nos

6. Jumper wires

1 nos

Hardware

MFRC522 RFID sensor

RFID means radio-frequency identification. Radiofrequency identification is a non-contactless method to transfer data between the transmitter and receiver over a short distance. These modules have applications in personal access, toll gate system, control access system, etc. Here we design an RFID-based door system.

An RFID system consists of a tag attached to the object to be identified with its own unique identification number(UID). Only the person with the right information is allowed to enter the door. In this two-way radio transmitter, the reader sends the signal to the tag and read its response

 An RFID system uses:

  • tags attached to the object to be identified, with its own unique identification number(UID). In this door access system, we have a keychain and an electromagnetic card. 
RC522 NFC reader
  • Reader: acts as a two-way radio transmitter-receiver that send a signal to the tag and read its response.

ARDUINO UNO

Although there are many types of boards from arduino . Here we are going to be using the Arduino UNO as it is the most commonly used one. The arudino UNO has :

  • The operating voltage is 5V
  • The recommended input voltage will range from 7v to 12V
  • Digital input/output pins are 14
  • Analog i/p pins are 6
  • DC Current for each input/output pin is 40 mA
  • Flash Memory is 32 KB
  • SRAM is 2 KB
  • EEPROM is 1 KB
  • CLK Speed is 16MHz

Another wonderful feature of the arduino is the option of using a add-on boards to the arduino which comes as a module and they are known as “Shields”

Pin out diagram
Arduino UNO

Micro Servo Motor

Micro servo motors provide precise control of linear and angular position, velocity, and acceleration. They are useful in many robotics projects, such as for turning the front wheels on an RC model for steering or pivoting a sensor to look around on a robotic vehicle.

Servo is a general term for a closed-loop control system which consists of a suitable motor, couple to a sensor for position feedback signal, in order to adjust the speed and direction of the motor and to achieve the desired result

RC servo motor works on the same principle. It contains a small DC motor connected to the output shaft through the gears.
A servo motor works with a small DC motor connected to the output shaft through the gears. The output shaft drives a servo arm which is connected to the potentiometer (pot). The potentiometer provides position feedback to the servo control unit where the current position of the motor compared to the target position.
According to the error, The control unit corrects the actual position of the motor according to the error so that it matches the target position.

How Servo Motors Work?

A servo motor can be controlled by sending a series of signal pulses to the signal. A conventional analog servo motor can receive a pulse roughly every 20 milliseconds (i.e. signal should be 50Hz). The position of the servo motor determines the length of the pulse.

  • If the pulse is high for 1ms, then the servo angle will be zero.
  • If the pulse is high for 1.5ms, then the servo will be in its center position.
  • If the pulse is high for 2ms, then the servo will be at 180 degrees.

In this servo motor, the pulses ranging between 1ms and 2ms will rotate the servo shaft to full 180 degrees of its travel.

 

Liquid Crystal 16*2 LCD Display

output of the sketch on a 16×2 LCD

LCD modules are the most prominent as they are low cost and program friendly, hence these modules are commonly used in the embedded system. 16*2 LCD modules consist of 16 columns and 2 rows, so it has 32 (16*2) characters in total. Each character has 40pixels (5*8) and thus for 32 characters there 1280 pixels (32*4). An interface IC HD447480 is attached on the backside of the LCD module to determine the position of the pixel. This IC gets commands and data from the microcontroller and processes it, thus display it on the screen. Using a resistor or PWM the color can be dimmed easily.

LCDs have a parallel interface consisting of the following pins: meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins:

 The Register Select (RS) controls LCD s memory where it is writing to. The data register consist of the data and the instruction register looks for the next instruction to be executed.

The Read/ Write pin indicates whether the display is in reading mode or writing mode.

Enable pin enables writing to the register.

Data pins (D0 -D7) (high or low) indicate whether you’re writing to a register when you write, or the values you’re reading when you read.

The Display contrast pin (Vo) is used to power the LCD.

Power supply pins (+5V and Gnd), and LED Backlight (Bklt+ and BKlt-) pins turn on and off the LED backlight.
These LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O pins from the Arduino, whereas the 8-bit mode requires 11 pins.

CIRCUIT DIAGRAM

CONNECTING MFRC522 RFID sensor Sensor To ARDUINO

STEP1:

Wire up the data lines and power lines of the Ultrasonic sensor. 

  • MFRC522 Sensor VCC 3.3V -> Arduino 3.3V
  • MFRC522 Sensor RST -> Arduino PIN 9
  • MFRC522 Sensor GND -> Arduino Analog  GND
  • MFRC522 Sensor MISO -> Arduino Analog Pin 12
  • MFRC522 Sensor MOSI> Arduino PIN 11
  • MFRC522 Sensor SCK -> Arduino PIN 13
  • MFRC522 Sensor SCA -> Arduino Analog Pin 10

STEP2: Wire up the LCD screen Module

LCD Module Pin out

 

  • 1 Ground (0V)
  • 2 Vcc Supply voltage; 5V (4.7V – 5.3V)
  • 3 Vo / VEE Contrast adjustment; the best way is to use a variable resistor such as a potentiometer. The output of the potentiometer is connected to this pin. Rotate the potentiometer knob forward and backward to adjust the LCD contrast.
  • 4 Enable Selects command register when low, and data register when high RS (Register Select )
  • 5  R/W Low to write to the register; High to read from the register read/write
  • 6 En Enable Sends data to data pins when a high to low pulse is given; Extra voltage push is required to execute the instruction and EN(enable) signal is used for this purpose. Usually, we set en=0, when we want to execute the instruction we make it high en=1 for some milliseconds. After this we again make it ground that is, en=0.
  • 7 8-bit data pins DB0
  • 8 DB1
  • 9 DB2
  • 10 DB3
  • 11 DB4
  • 12 DB5
  • 13 DB6
  • 14 DB7
  • 15 Backlight VCC (5V) Led+
  • 16 Backlight Ground (0V) Led-

 Wire up the LCD screen Module

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image above. To wire your LCD screen to your board, connect the following pins:

  • 1 LCD Ground (0V)
  • 2 LCD Vcc Supply voltage; 5V (4.7V – 5.3V)
  • 3 LCD Vo / VEE Contrast adjustment; the best way is to use a variable resistor such as a potentiometer. The output of the potentiometer is connected to this pin. Rotate the potentiometer knob forward and backward to adjust the LCD contrast.
  • 4 LCD RS pin to digital pin 2
  • 5 LCD R/W pin to GND
  • 6 LCD Enable pin to digital pin 3
  • 11 LCD D4 pin to digital pin 4
  • 12 LCD D5 pin to digital pin 5
  • 13 LCD D6 pin to digital pin 6
  • 14 LCD D7 pin to digital pin 7
  • 15 LCD LED+ to 5V through a 220-ohm resistor / directly
  • 16 LCD LED- to GND

PROGRAMMING

Getting started with Arduino

Arduino Integrated Development Environment (IDE) is a common and prominent software running on the system which allows to write programs in Arduino language for different Arduino boards (sketch). Processing is known as the hardware programming language for Arduino, is somewhat similar to c language.  After the sketch is written in the Arduino IDE, it should be uploaded on the Arduino board for execution.

Before starting any project, we need to interface Arduino with computers. So we have to write and compile code for the Arduino to execute, as well as providing Arduino to function with a computer.

Installing The Arduino Software Package On Windows

Download a version of Arduino software suitable for your version of Windows from Arduino website / superkitzs.com. After downloading, check the instructions below to install the Arduino Integrated Development Environment (IDE).

 

Connect your Arduino Uno board with an A B USB cable; sometimes this cable is called a USB printer cable.

In order to program the board, the USB connection with the PC is necessary to program the board and not just to power it up. The Arduino Uno is capable of withdrawing power from either the USB or an external power supply. Connect the board to your computer using the USB cable. The green power LED (labeled PWR) should go on.

If you used the Installer, as soon as you connect your board the Windows – from XP up to 10 – will install drivers automatically

If the board is not properly recognized when the zip package is downloaded and expanded, please follow the procedure below.

  • START menu> CONTROL PANEL MENU
  • From the control panel, check for System and Security
  • Select system
  • Select Device Manager from the System window
  • Select open port named “Arduino UNO (COMxx)”, under Ports (COM & LPT). If there is no COM & LPT section, check “Other Devices” for “Unknown Device”.
  • Choose the “Update Driver Software” option by right-clicking on the “Arduino UNO (COmxx)” port
  • Navigate to the “Browse my computer for Driver software” option.
  • Choose the driver file named “arduino. inf”, located in the “Drivers” folder of the Arduino Software download (not the “FTDI USB Drivers” sub-directory). If you are using an old version of the IDE (1.0.3 or older), Choose the Uno driver file named “Arduino UNO.inf”, If an old version of the IDE (1.0.3 or older) is used
  • Thus the windows driver installation is completed

Install Libraries for Arduino IDE

 Install MFRC522-1.4.7 as ZIP file in Arduino IDE

Arduino-MFRC522-1.4.7  library is available as a downloadable ZIP . Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE.

Download MFRC522-1.4.7 Library by clicking the button: Download MFRC522-1.4.7

Do not unzip the downloaded library, leave it as is.

  1. In the Arduino IDE, choose Sketch, then goes to Include library. Select the option to “Add .ZIP Library ’‘and then select the zip file you downloaded, from the top-down list.
  2. Then go back to Sketch > Include Library menu. From the library at the bottom of the drop-down menu, choose the library. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.

Select your board type : Arduino UNO and select the  port

  • Choose Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino board. Reconnect the board and select that serial port.

Press CNTRL + A & press DELETE for clearing the Arduino IDE

Upload the program

Copy the Sketch Code given below And try to understand 

After that click on the “Upload” button. Then we can see the RX and TX LED on the board flashing. The message “Done uploading.” will appear if the uploading is a success

 

 

Arduino Code

Programming Logic 

Before we start, restart the Arduino IDE after installing the library.


#include
#include
#include
#include

#define rs 2
#define en 3
#define d4 4
#define d5 5
#define d6 6
#define d7 7

MFRC522 mfrc522(10,9);
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
Servo myservo;

void setup()
{
  Serial.begin(9600);
  SPI.begin();
  lcd.begin(16,2);
  myservo.attach(8);
  myservo.write(170);
  lcd.print("#ACCESS CONTROL#");
  lcd.setCursor(0,1);
  lcd.print("    Scan Tag");
  mfrc522.PCD_Init();
  Serial.println("Scan Tag");
}

void loop()
{
  if(!mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  if(!mfrc522.PICC_ReadCardSerial())
  {
    return;
  }
  String uid="";
  Serial.println();
  Serial.print("UID=");
  for(int i=0;i<mfrc522.uid.size;i++)
  {
    Serial.print(mfrc522.uid.uidByte[i]<0x10 ? "0" : "");
    Serial.print(mfrc522.uid.uidByte[i],HEX);
    uid.concat(String(mfrc522.uid.uidByte[i]<0x10 ? "0" : ""));
    uid.concat(String(mfrc522.uid.uidByte[i],HEX));
  }
  uid.toUpperCase();
  if(uid=="CC60140F")
  {
    Serial.print(":Tony stark");
    lcd.clear();
    lcd.print(" ACCESS DENIED");
    lcd.setCursor(0,1);
    lcd.print("  Tony stark");
    myservo.write(10);
  }
  else if(uid=="C6D2CA2C")
  {
    Serial.print(":Captain America");
    lcd.clear();
     lcd.print(" ACCESS GRANTED");
    lcd.setCursor(0,1);
    lcd.print("Captain America");
    myservo.write(170);
  }
  else
  {
    Serial.print("ACCESS DENIED");
    lcd.clear();
    lcd.print("  ACCESS DENIED");
    myservo.write(170);
  }
  delay(5000);
  myservo.write(170);
  lcd.clear();
  lcd.print("    Scan Tag");
  return;
}
 

Then, click the Upload button in the Arduino IDE and wait a few seconds until you see the message “Done uploading.” in the bottom left corner.

Output

After connecting , it should look like this 

before turning it on , keep the gyroscope in a suitable position from where its going to take the calibration of the coordinates as 0,0,0 (x,y,z axis) , then move your hand to get the output on the relay

You should see the Pitch and Roll coordinates

Leave a Reply