Attendance is one of the most important activities during a lecture. Almost 5 to 10 minutes are spent while marking students absent or present during each lecture, time which can be otherwise utilized for teaching or something productive. Today we are going to design a RFID based Attendance System so that students can automatically mark their presence in the system without the need of teacher having to do it manually.

 

COMPONENTS REQUIRED

Arduino RFID attendance system required components

RC522 RFID Module

For most of our RFID based Arduino projects, RC522 RFID Reader/Writer module is a great choice. It is low power, low cost, pretty rugged, easy to interface with and insanely popular. It consists of two components a transponder/tag attached to a object to be identified and a transceiver/interrogator or reader.

RFID attendance system

RFID module working

A Reader consists of a Radio Frequency module and an antenna which generates high frequency electromagnetic field. On the other hand, the tag is usually a passive device, meaning it doesn’t contain a battery. Instead it contains a microchip that stores and processes information, and an antenna to receive and transmit a signal. To read the information encoded on a tag, it is placed in close proximity to the Reader (does not need to be within direct line-of-sight of the reader). A Reader generates an electromagnetic field which causes electrons to move through the tag’s antenna and subsequently power the chip. The powered chip inside the tag then responds by sending its stored information back to the reader in the form of another radio signal. This is called backscatter. The backscatter, or change in the electromagnetic/RF wave, is detected and interpreted by the reader which then sends the data out to a computer or microcontroller. The Module work at 13.5 Mhz frequency and uses SPI Communication Protocol for communicating with the microcontroller so always make sure you connect the pins correctly to the different Arduino boards. If you have a Mega, the pins are different! You’ll want to use digital 50 (MISO), 51 (MOSI) and 52 (SCK).

Pin

Wiring to Arduino Uno

SDA

Digital 10

SCK

Digital 13

MOSI

Digital 11

MISO

Digital 12

IRQ

unconnected

GND

GND

RST

Digital 9

3.3V

3.3V

 

After connecting the wires you need to download from https://github.com/miguelbalboa/rfid/archive/master.zip and put the library in the library folder of the Arduino. 

 

Reading the data from the tag

After having the circuit ready, go to File > Examples > MFRC522 > DumpInfo and upload the code. This code will be available in your Arduino IDE (after installing the RFID library). You will see something like this

 

Now put the RFID tag on the reader.

 

The keys highlighted in yellow are card Unique ID. Write it down as it will be used in the program. This is the information that you can read from the card, including the card UID that is highlighted in yellow. The information is stored in the memory that is divided into segments and blocks as you can see in the previous picture. You have 1024 bytes of data storage divided into 16 sectors and each sector is protected by two different keys, A and B.

 

Circuit Diagram

After you get your card UIDs connect the wires as shown in figure.

Arduino RFID based Attendance System Circuit Diagram

Just make sure that you are powering the RFID reader from 3.3V supply though the board is 5V tolerant it is not advisable to put 5V pin to its power pin. All the ground connections are depicted by black wire. There is a buzzer to confirm the reading of the card which is connected to digital pin 4 of the Arduino. Pin 4 (RS) and pin 6 (E) are connected to Arduino digital pins 3 and 2 respectively and 4 data bus pins are connected to digital pins 5,6,7 and 8 respectively.

 

Arduino Code Explanation

First of all, make sure that you have installed all the relevant libraries in the IDE. As the module works on SPI interface so make sure that correct SPI pins are connected in Arduino board. Now all the relevant information is written in the comment section in the code please go through it. Now for the code explanation first we start be including the header files from the links given alongside in the code. Then define the pins connected to the LCD and RFID Tag reader and two variables a and b to be used in the code later.

 

#include <SPI.h>   

#include <MFRC522.h>   

#include<LiquidCrystal.h>  

LiquidCrystal lcd(3,2, 5, 6, 7, 8); 

#define SS_PIN 10

#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN);  

int a,b;

 

In the setup part we initialise the SPI bus and serial data communication and initialise the LCD.

 

Serial.begin(9600);

SPI.begin();     

mfrc522.PCD_Init();  

Serial.println("Tap your card on the reader...");

Serial.println();

  lcd.begin(16, 2);

 

The Unique IDs we identified earlier from the rest program is used here to match against the RFID cards put on the reader. In this section of code, we read the card Unique ID and compare it against the IDs already in the system.

 

if (content.substring(1) == "83 CB 96 1A" && a==0) //change here the UID of the card/cards that you want to give access the variable 'a' is 0 here which means student is not present in the classroom

  {

    Serial.println("Hello");

    Serial.println("Welcome Student 1");

    a++;        // this variable will indicate if the student is present or absent if a=1 then student 1 is present and if a=0 then student 1 is absent in this code i configured it in a way if second tap is made then the a's value will decrease and with using timing function we can determine the amount of time the student was in the classroom.

    Serial.println();

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("Hello, Welcome");

    lcd.setCursor(0,1);

    lcd.print("Student 1");

    digitalWrite(4, HIGH);

    delay(3000);

    digitalWrite(4, LOW);

    lcd.clear();

  }

 

If student A put his card on the reader while entering the class the attendance variable ‘a’ will become 1 and student will be marked present and when he tap the card again while exiting the class the variable ’a’ becomes 0. In this way we can mark any student present or absent in the class. The people who did not show up will be marked absent and their attendance variable will remain ‘0’.

 

{

    Serial.println(" Access denied");

    lcd.print("Unknown student");

    lcd.setCursor(0,1);

    lcd.print("Unauthorised");

    digitalWrite(4, HIGH);

    delay(6000);

    digitalWrite(4, LOW);

 

Any unauthorized person trying to enter the class will be shown a massage with access denied and sounding a long buzzer. You can check the comments in the code section to see how it is working.

 

Video

Leave a comment

Please note, comments must be approved before they are published

Your cart

×