3 Jaswanthdoc
3 Jaswanthdoc
A Project Report
Submitted in partial fulfilment of the Requirements for
the Award of Degree
of
BACHELOR OF TECHNOLOGY
in
ELECTRICAL AND ELECTRONICS ENGINEERING
By
A. MURALIKRISHNA 18B91A0212
B. CHIHINITHA 18B91A0219
B. JASWANTH 18B91A0223
G. BHAVYA DEEPIKA 18B91A0266
A. SUBRAHMANYA ADITYA 18B91A0209
D. SAI PAVAN 18B91A0245
1
S.R.K.R. ENGINEERING COLLEGE (A)
(AFFILIATED TO JNTU, KAKINADA) (RECOGNISED BY A.I.C.T.E., NEW DELHI)
(Accredited by N.B.A., NEW DELHI)
BHIMAVARAM-534204
DEPARTMENT OF ELECTRICAL AND ELECTRONICS
ENGINEERING
Certificate
This is to certify that this project work entitled
RFID BASED SMART ATTENDANCE SYSTEM
is the bona fide work of
Mr./Miss B. JASWANTH Regd. no 18B91A0223
of final year B.E. along with his batch mates submitted in partial
fulfilment of the requirements for the award of Degree in Bachelor of
Engineering in Electrical and Electronics Engineering during the
academic year 2021-2022.
This is to verify that we had examined the project report and hereby
required for its acceptance in a partial fulfilment for the award of degree of
Our most sincere and graceful acknowledgement is due to this sanctum, SAGI
In the first place. We would like to convey our heartfelt gratitude to Dr. B.R.K.
Varma, Professor, Department of EEE, who offered this project to us. We owe him a
great debt of gratitude for his insightful discussions, capable direction, and unwavering
support throughout the project, without whom this project would not have been a success.
We would like to convey our heartfelt gratitude to Dr. B.R.K. Varma, Head of
The Department of EEE, S.R.K.R. Engineering College, Bhimavaram, for his constant
my degree.
We also thank other teaching and non-teaching staff for their assistance and help
We are grateful to my family for being a part of my vision and teaching me the
-Project associates
18B91A0212- A. Murali Krishna
18B91A0219- B. Chihinitha
18B91A0223- B. Jaswanth
18B91A0266- G. Bhavya Deepika
18B91A0209- A. Subrahmanya Aditya
18B91A0245- D. Sai Pavan
DECLARATION
This project titled “RFID BASED SMART ATTENDANCE SYSTEM” has been
carried out by me in the partial fulfilment of the requirements for the award of the degree
Bhimavaram.
I hereby declare that this thesis has not been submitted to any other university/institute
A. MURALIKRISHNA 18B91A0212
B. CHIHINITHA 18B91A0219
B. JASWANTH 18B91A0223
G. BHAVYA DEEPIKA 18B91A0266
A. SUBRAHMANYA ADITYA 18B91A0209
D. SAI PAVAN 18B91A0245
Table of Contents
Contents Page No
List of Tables iv
List of Abbreviations iv
Abstract v
CHAPTER 1: INTRODUCTION
1.1 Introduction 6
1.2 Literature Survey 7
1.3 Overview of project 8
1.4 Block Diagram 9
1.5 Description 9
CHAPTER 2: HARDWARE REQURIMENTS
2.1.1 Radio frequency identification 10
i
CHAPTER 3: SOFTWARE REQUIREMENTS
3.1.1 Arduino IDE 31
3.2.1 Testing the Arduino RFID library 35
3.2.2 Info dump test from RFID tag 37
3.2.3 Customizing RFID tags in Arduino 39
3.2.4 Writing data to RFID tags 40
CHAPTER 4: METHODOLOGY AND IMPLEMENTATION
4.1.1 Interfacing NODEMCU and RFID 44
4.1.2 Interfacing LED and BUZZER with circuit 46
4.2.1 Code for entering name in card 47
4.2.2 APP Script code in Google sheets 49
4.2.3 Code for Attendance 50
CHAPTER 5: RESULTS AND CONCLUSION
5.1 Entering name in the card 55
5.2 Recording Attendance 55
5.3 Conclusion 56
5.4 Future Scope 57
REFERENCES 58
ii
LIST OF FIGURES
Figures Titles
iii
LIST OF TABLES
Tables Title
LIST OF ABBREVIATIONS
iv
ABSTRACT
With this monitoring system, if there are students who are not present can
be immediately discovered and can be taken immediate action and the learning
process can run smoothly.
v
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION
Page | 6
the middle-ware for processing. Tags at varying frequencies are interrogated by
the reader. The reader is further connected to the computer for processing the data
this can be done via a USB connector or any wireless connection. This type of
simple system where scanning of the tag towards the reader makes the work quite
easier and improves the rate of error. Also, the long procedure of attendance is
cut short to a single move/step. The smart attendance management system
removes the traditional way of registering the attendance. It also provides a
secure, error-free method of attendance management. The administrators can be
at ease by employing such a smart attendance system. The system is best suited
for managing attendance of employees. It can also be used to record attendance
for students at their hostels.
Page | 8
1.4 BLOCK DIAGRAM
RFID READER
Operating Voltage:
3.3V
NODE MCU
Input Voltage ESP8566
LED
(5V) (5V-10V)
Operating
voltage: 3.3V
BUZZER
1.5 DESCRIPTION
Page | 9
CHAPTER 2
HADWARE REQUIREMENTS
Unlike barcodes, RFID does not require a direct line of sight between the
reader and the tag and it can operate effectively in hostile environments where
the tag may be contaminated with dirt and grease.
These features make RFID an ideal choice for many applications including
manufacturing, warehousing, distribution, maintenance and repair.
The transponder is in the RFID tag itself. The read range for RFID tags
varies based on factors including the type of tag, type of reader, RFID frequency
and interference in the surrounding environment or from other RFID tags and
readers. Tags that have a stronger power source also have a longer read range.
Page | 10
Fig 2.1.1: RFID-RC522 Pin Diagram
-a scanning antenna
-a transmitter
-a receiver
-a transponder
• Antenna:
In short, RFID Antennas take energy from an RFID reader and transmit
it in the form of RF waves to RFID tags in the vicinity. If RFID Readers
are the “brains” of an RFID system, RFID antennas are the arms because
they actually transmit RF waves to the tags.
Transmitter transmits the radio frequency waves out of the RFID, which
are received by the tags and gets active and sends a signal to the reader
again.
• Receiver:
The transmitted data from card is received by the RFID reader through the
receiver.
• Transponder:
Page | 12
2.1.2 WHAT ARE RFID TAGS AND SMART LABELS?
The read range for RFID tags varies based on factors including type of tag,
type of reader, RFID frequency, and interference in the surrounding environment
or from other RFID tags and readers. Active RFID tags have a longer read range
than passive RFID tags due to the stronger power source.
Smart labels are simple RFID tags. These labels have an RFID tag
embedded into an adhesive label and feature a barcode. They can also be used by
both RFID and barcode readers. Smart labels can be printed on-demand using
desktop printers, where RFID tags require more advanced equipment.
There are three main types of RFID systems: low frequency (LF), high frequency
(HF) and ultra-high frequency (UHF). Microwave RFID is also available.
Frequencies vary greatly by country and region.
Page | 13
• UHF RFID systems. These range from 300 MHz to 960 MHz, with the
typical frequency of 433 MHz and can generally be read from 25-plus feet
away.
• Microwave RFID systems. These run at 2.45 GHz and can be read from
30-plus feet away.
The frequency used will depend on the RFID application, with actual obtained
distances sometimes varying from what is expected. For example, when the U.S.
State Department announced it would issue electronic passports enabled with an
RFID chip, it said the chips would only be able to be read from approximately 4
inches away. However, the State Department soon received evidence that RFID
readers could skim the information from the RFID tags from much farther than 4
inches -- sometimes upward of 33 feet away.
If longer read ranges are needed, using tags with additional power can boost read
ranges to 300-plus feet.
RFID dates back to the 1940s; however, it was used more frequently in the 1970s.
For a long time, the high cost of the tags and readers prohibited widespread
commercial use. As hardware costs have decreased, RFID adoption has also
increased.
Page | 14
• customer service and loss control
• improved visibility and distribution in the supply chain
• access control in security situations
• shipping
• healthcare
• manufacturing
• retail sales
• tap-and-go credit card payments
Can identify individual objects without Direct line of sight required for
direct line of sight. scanning.
Can scan items from inches to feet away, Require closer proximity for
depending on type of tag and reader. scanning.
Read time is less than 100 milliseconds Read time is half a second or more per
per tag. tag.
• Reader collision. Reader collision, when a signal from one RFID reader
interferes with a second reader, can be prevented by using an anti-collision
protocol to make RFID tags take turns transmitting to their appropriate
reader.
• Tag collision. Tag collision occurs when too many tags confuse an RFID
reader by transmitting data at the same time. Choosing a reader that gathers
tag info one at a time will prevent this issue.
Page | 16
2.1.7 RFID SECURITY AND PRIVACY
A common RFID security or privacy concern is that RFID tag data can be
read by anyone with a compatible reader. Tags can often be read after an item
leaves a store or supply chain. They can also be read without a user's knowledge
using unauthorized readers, and if a tag has a unique serial number, it can be
associated to a consumer. While a privacy concern for individuals, in military or
medical settings this can be a national security concern or life-or-death matter.
Because RFID tags do not have a lot of compute power, they are unable to
accommodate encryption, such as might be used in a challenge-response
authentication system. One exception to this, however, is specific to RFID tags
used in passports -- basic access control (BAC). Here, the chip has sufficient
compute power to decode an encrypted token from the reader, thus proving the
validity of the reader.
The U.S. State Department, which adopted the BAC system in 2007, has
added an anti-skimming material to electronic passports to mitigate the threat of
undetected attempts to steal users' personal information.
Page | 17
2.1.8 NEXT-GENERATION RFID USE
1. A unique ID
2. Automatic recognition
Tags are attached to items and transmit the stored ID to readers. The
readers may be positioned at fixed points such as ‘goods out’ or ‘goods in’ or at
specific locations within a chemical processing plant, As each item passes by, the
reader will automatically scan the ID. Alternatively the readers can be built into
tables or mobile phones, enabling the tags to be scanned wherever the entity
happens to be.
Passive RFID tags – the most common type – are activated by the reader’s
power source so they do not require batteries. This means that tags can be very
small – tiny enough for them to be embedded in miniature devices.
Page | 18
They also have a very long life and some can survive outdoors in all
conditions for ten years and beyond. Typically, passive tags are used for items
that need to be read within a range from 1mm up to about 10m.
For longer distances or more specialist applications, active tags with their
own power source may be used. Even so, these can remain active for up to five
years depending on use and environmental conditions.
Unlike bar codes, with RFID the object being scanned does not necessarily
have to be within the direct line of sight. Files in racks or items moving on a
conveyor belt, can be detected simply by positioning the reader correctly.
Similarly, one RFID reader can collect data from a large number of tags
simultaneously – unlike barcodes where each item has to be scanned separately.
This makes it possible to collect data en masse which can save a huge amount of
time. The contents of an entire pallet can be scanned as it leaves the warehouse,
or a stock check of the contents of a shelving rack can be carried out without
removing each item. Again, there are many factors to be considered when
selecting the correct RFID technology so take professional advice.
RFID tags can be more robust than barcodes or other print labels and can
be used even in the most demanding environments. There is a huge range of tag
Page | 19
types available designed for everything from underwater applications to
contaminated or hazardous environments, high-vibration areas or where there is
a risk of explosions (ATEX compliant). Contact one of our engineers for an initial
discussion to advise on the best way forward.
2.2.1 NODEMCU
Even though the concept of Internet of Things (IoT) has been there for
several years, it really took off once the DIY community started investing in it.
To aid low-cost and easy to implement IoT systems, you need both the supporting
hardware as well as good software. This is where Espressif Systems came into
picture with a bang. The ESP8266 SoC, released back in 2014, has been the go-
to chip for IoT related projects in the DIY community.
Several third-party manufacturers took the ESP8266 SoC and started developing
small modules and boards, that can be easily integrated into our existing hobbyist
setup consisting mainly of Arduino. One of the popular ESP8266 based module
is the ESP-01, developed by Ai-Thinker. This is a simple board with the ESP8266
SoC, a flash memory and few pins to connect to other devices like Arduino.
This is a great board to start with ESP8266 but there are a few limitations like the
pins are not breadboard friendly, only two GPIO pins, need for an USB to UART
converter module to program etc. So, what manufacturers started doing is instead
of using the vanilla version of the ESP8266 Module, which is the ESP-01, they
started using a slightly advanced version called the ESP-12E, which is also from
Ai-Thinker.
The good thing about ESP-12E is it has more GPIO Pins and the PCB comes with
castellated edges so that you can easily solder this board on to your own design.
Page | 20
Fig 2.2.1: ESP8266
The following image shows the pinout for NodeMCU board. A typical
NodeMCU board (if it is based on the original NodeMCU Devkit design) has 30
pins. In this, 8 pins are related to power and 2 are reserved. The remaining 20
pins are associated with pins of ESP-12E Module.
Page | 21
A brief description of the pins is given in the following table.
Alternate Default
Pin Description
Functions
ADC0 Analog Input ADC0
Reserved
Reserved
SDD3 SDIO Data 3 GPIO10 SDD3
SDD2 SDIO Data 2 GPIO9 SDD2
SDD1 SDIO Data 1 GPIO8 SDD1
SDDCMD SDIO CMD GPIO11 SDDCMD
SDD0 SDIO Data 0 GPIO7 SDD0
SDCLK SDIO CLK GPIO6 SDCLK
GND Ground
3.3V 3.3V Output
EN Chip Enable
(Active HIGH)
RST Reset (Active
LOW)
GND Ground
VIN 5V Input 3.3V
Regulator
3.3V 3.3V Output
GND Ground
TXD0 UART0 TXD GPIO1 TXD0
RXD0 USRTO RXD GPIO3 RXD0
GPIO15 GPIO15 HSPI_CS/RTS0 GPIO15
GPIO13 GPIO13 HSPI_MOSI/CTS0 GPIO13
GPIO12 GPIO12 HSPI_MISO GPIO12
GPIO14 GPIO14 HSPI_SCK GPIO14
GND Ground
3.3V 3.3V Output
GPIO2 GPIO2 UART1 TXD GPIO2
Flash Flash GPIO0
GPIO4 GPIO4 Software SDA GPIO4
(12C)
GPIO5 GPIO5 Software SCL GPIO5
(12C)
GPIO16 GPIO16 Wake (deep sleep) GPIO16
Table 2.2.1: NodeMCU Pin Description
Page | 22
2.2.3 ESP-12E MODULE
Page | 23
2.2.4 ESP-12E PINOUT
If you are interested in designing your own breakout board for ESP-12E
Module, then the following ESP-12E Pinout image will be very useful for you.
As you can see, there are 22 pins on the ESP-12E Module.
Page | 24
The following table describes the pins of ESP-12E Module.
PIN Function
RST Reset the Module
ADC0 ADC Pin with 10-bit resolution
EN Chip Enable Pin (active HIGH)
GPIO16 GPIO16 pin (wake pin from deep
sleep mode)
GPIO14 GPIO14 pin (HSPI_CLK)
GPIO12 GPIO12 pin (HSPI_MISO)
GPIO13 GPIO13 pin (HSPI_MOSI)
VCC 3.3V Power Supply (max 3.6V)
SDCMD SDIO CMD (GPIO11)
SDD0 SDIO Data 0 (GPIO7)
SDD2 SDIO Data 2 (GPIO9)
SDD3 SDIO Data 3 (GPIO10)
SDD1 SDIO Data 1 (GPIO8)
SCCLK SDIO CLK (GPIO6)
GND Ground Pin
GPIO15 GPIO15 pin (HSPI_CS)
GPIO2 GPIO2 pin (TXD1)
Flash Flash Pin (GPIO0)
GPIO4 GPIO4 pin (SDA – software I2C)
GPIO5 GPIO5 pin (SCL – software I2C)
RXD0 UART0 RXD pin (GPIO3)
TXD0 UART0 TXD (GPIO1)
Page | 25
Specifications:
Voltage: 3.3V
Wi-Fi Direct (P2P), soft-AP
Current consumption: 10uA~170mA
Flash memory attachable: 16MB max (512K normal)
Integrated TCP/IP protocol stack
Processor: Tensilica L106 32-bit
Processor speed: 80~160MHz
RAM: 32K + 80K
GPIOs: 17 (multiplexed with other functions)
Analog to Digital: 1 input with 1024 step resolution.
+19.5dBm output power in 802.11b
mode 802.11 support: b/g/n
Maximum concurrent TCP connections: 5
2.2.4 FEATURES
Page | 26
o 16 KiB ETS system-data RAM
• External QSPI flash: up to 16 MiB is supported (512 KB to 4 MB
typically included)
• IEEE 802.11 b/g/n Wi-Fi
o Integrated TR switch, balun, LNA, power
amplifier and matching network
o WEP or WPA/WPA2 authentication, or open networks
• 17 GPIO pins[6]
• Serial Peripheral Interface Bus (SPI)
• I²C (software implementation)[7]
• I²S interfaces with DMA (sharing pins with GPIO)
• UART on dedicated pins, plus a transmit-only UART can be enabled
on GPIO2
• 10-bit ADC (successive approximation ADC)
POWER
There are two ways to power the NodeMCU board. One is through the
micro-USB port and the other is through VIN pin. Note that ESP8266EX SoC is
compatible with only 3.3V. So, the NodeMCU board has 3.3V Regulator IC
(AMS1117 – 3.3).
If you have regulated 5V power, then you can apply this to the VIN pin. There
are three 3.3V pins, which are connected to the 3.3V output of the regulator.
Strictly speaking, this is related to the ESP8266EX SoC. Keeping that in mind,
let us see all the peripherals that are available on the NodeMCU.
Page | 27
GPIO
The ESP8266EX has 17 GPIO pins. But not all them available for the
user as some of these are used for their alternative functions (like UART, SDIO,
SPI etc.) in NodeMCU (ESP-12E Module). We will see the available GPIO Pins
on NodeMCU after looking at all the other peripherals.
SPI
There are two SPI Interfaces on ESP8266EX SoC (SPI and HSPI). Both
support Master and Slave Operations. Master mode clock can be configured to
80 MHz while slave mode clock is up to 20 MHz.
I2C
Hardware I2C is not available in ESP8266 but is can implemented through
software. GPIO4 and GPIO5 can be used as SDA and SCL as they do not have
any other alternative functions.
Page | 28
UART
ESP8266EX has two hardware UARTs (UART0 and UART1) with baud
rates up to 115200. In this, UART0 can be used for communication and it has
data flow control as well. UART1 has only TX pin (its RX pin is used by
SDD1) so, it can used for data logging.
• UART0 TX – GPIO3
• UART0 RX – GPIO1
• UART0 RTS – GPIO15
• UART0 CTS – GPIO13
• UART1 TX – GPIO2
• UART1 RX – GPIO8 (Not Available)
2.4 BUZZER
The buzzer is a sounding device that can convert audio signals into sound signals.
It is usually powered by DC voltage. It is widely used in alarms, computers,
printers and other electronic products as sound devices.
Page | 29
This system works on radio frequency identification that is RFID. Whenever
someone uses a card, whose information is registered in the memory of the
buzzer starts beeping.
Fig2.4: Buzzer
2.5 LEDs
LED stands for light emitting diode. LED lighting products produce light
up to 90% more efficiently than incandescent light bulbs. How do they work? An
electrical current pass through a microchip, which illuminates the tiny light
sources we call LEDs and the result is visible light.
Page | 30
CHAPTER 3
SOFTWARE REQUIRMENTS
• Arduino HYPERLINK:
"https://www.digikey.in/productdetail/en/arduino/A000073/1050-1041-
ND/3476357" Uno
• USB Cable
• Arduino IDE
• About 15 minutes
You can download the IDE from the official Arduino website. Since the Arduino
uses a USB to serial converter (which allow it to communicate with the host
computer), the Arduino board is compatible with most computers that have a
USB port. Of course, you will need the IDE first. Luckily, the Arduino designers
have released multiple versions of the IDE for different operating systems,
including Windows, Mac, and Linux. In this tutorial, we will use Window 10,
so ensure that you download the correct version of the IDE if you do not have
Windows 10.
Page | 31
Fig 3.1.1: Download the Arduino IDE
Once downloaded, install the IDE and ensure that you enable most (if not all)
of the options, INCLUDING the drivers.
In order to use Arduino IDE to program the NodeMCU, you have to introduce
it to the software at first.
To do this copy the following code and follow the steps below:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Step 2.1: Choose Preferences in the File menu and enter the copied code
in Additional Board Manager URLs part. Then press OK.
Page | 32
Step 2.2: Search the word ESP8266 in Boards>boards manager from Tools
menu. Then install ESP8266 boards. After complete installation, you will
see the INSTALLED label on ESP8266 boards.
After these two steps, you can see ESP8266 based boards such as NodeMCU
in your Arduino IDE boards list, and you can choose your desired board to
upload the code.
Next, you’ll need to connect the Arduino Uno board to the computer. This is
done via a USB B connection. Thanks to the wonderful world of USB, we do
not need to provide power to the
Windows can be a real pain sometimes with COM ports, as it can magically
change their numbers between connections. In other words, one day, your
Arduino may be on port 7 (as shown here), but then on other days, Windows
may shift it to a different port number. As I understand it, this happens when
you connect other COM ports to your system (which I do frequently).
So, if you can’t find your Arduino on the port that you usually use, just go to
your Device Manager and check what port it’s actually on and, if necessary,
update your driver.
Page | 34
Load the blink example.
With the example loaded, it’s time to verify and upload the code. The verify
stage checks the code for errors, then compiles the ready-for-uploading code to
the Arduino. The upload stage actually takes the binary data, which was created
from the code, and uploads it to the Arduino via the serial port.
To verify and compile the code, press the check mark button in the upper left
window.
The “Verify” button will compile the Arduino code.
If the compilation stage was successful, you should see the following message
in the output window at the bottom of the IDE. You might also see a similar
message—just it’s one that does not have words like “ERROR” and
“WARNING”.
This is a successful compilation.
With the code compiled, you must now upload it the Arduino Uno. To do this,
click the arrow next to the check mark.
The “Upload” button will program the Arduino with your code.
The Arduino IDE’s Library Manager has a widely used RFID library that
is compatible with the MFRC522 chip. The library, conveniently titled
MFRC522, can be downloaded directly from the library manager and the user
can get started right away with the many example scripts available to the
Arduino platform. Below is a short sequence that outlines the procedure for
downloading the MFRC522 library:
Page | 35
Install the MFRC522 library
Observe the Examples Available to the Selected Arduino Board (Uno in this
case)
The first checks we can do for verification of wiring, the Arduino library,
and the validity of the RFID tags is to upload the “Dump Info” code from the
examples list. Upon uploading, assuming the wiring is correct and there are no
errors, the user should place a tag within 4 inches of the MFRC522 scan area
(the wave-like drawing on the MFRC522 board) and look for a print out on the
Arduino serial port that looks similar to the following:
Info Dump from RFID Tag
Notice the terminology of sectors and blocks. These will be discussed
below.
We can see from the info dumpy that the tag we are using is a MIFARE 1KB
tag, which we can quantify by the multiplication of 64 blocks x 16 bytes per
block = 1024 = 1KB. This is a standard classic MIFARE tag, which are used in
low-security systems such as public transportation, schools and universities,
and employee office access.
"MIFARE Classic 1K-Mainstream contactless smart card IC for fast and easy
solution development." Rev. 3.2 — 23 May 2018, by NXP.
We can see from the info dumpy that the tag we are using is a MIFARE 1KB
tag, which we can quantify by the multiplication of 64 blocks x 16 bytes per
block = 1024 = 1KB. This is a standard classic MIFARE tag, which are used in
low-security systems such as public transportation, schools and universities,
and employee office access.
Page | 37
In order to identify the terms printed above, we have compiled an explanation
for each term based on the MIFARE document published by NXP:
UID - Unique Identifier. This is the 4-byte (32-bit) ID given to each PICC (tag).
Over 4.2 billion IDs are available with the 4-byte ID system. The UID is usually
stored in Sector 0, block 0 in the first four bytes.
Access Bits - These control the read/write permissions for each block
Using the table provided by NXP and the definitions above, we can identify a
few key parameters for our specific tag (from the Arduino printout above):
• UID - CE 5B F4 3C
• SAK - 08
• Key B - FF FF FF FF FF FF
In the next section, we will explore a few routines for altering th ese default
values and seeing just how far we can push the customization of these RFID
tags using the MFRC522 module.
3.2.3 Customizing RFID Tags in Arduino
We are going to attempt to change the Unique Identifier (UID) of each tag being
placed in front of the MFRC522 active area. The MFRC522 example code
‘ChangeUID’ allows us to do this by giving the user the power to change the
UID to a custom 4-byte address. We’re going to change the address of the tag
printed out in the previous section, to a completely random address of “F3 45
Page | 39
1B 0C” for testing. If we place the same tag in front of the MFRC522 scan area,
we get the following output, which we can compare with the previous output.
We can see that the only information that changed was the first five bytes of the
zeroth block of sector 0. The first four bytes have been changed to the desired
UID, while the fifth byte appears to be either random or specified by the write
action (we have not identified this byte designation in the library).
We tried several times to write new UIDs to our black tags, but we were unable.
This was expected, due to the specification of read-only, however, we figured
an attempt wouldn’t hurt!
Next, we’ll attempt to write specific data to each tag to see what
information we can store. Each sector (except sector 0) has three available
blocks for storing data (4-blocks per sector, minus 1 for keying). Thus, we can
store up to 48 bytes of data in each sector. This can lead to the storing of names,
dates, location information, product information - the possibilities are
expansive. We can start with the example in the Arduino MFRC522 library
called ‘rfid_write_personal_data’ which will ask the user to input a first and
last name for storing in the Electrically Erasable Programmable Read-Only
Memory (EERPROM), also known as the 16-sectors of data.
The user must input a name followed by the # symbol. For example:
Page | 40
• Smith#
• John#
The resulting inputs will be saved in memory and should output the following
if successful:
In our case, we inputted Smith# and John#, which should output John Smith as
the first and last name.
If we now upload the ‘RFID read personal data’ we can see how the personal
data is returned to us based on our inputs above:
We can see that block 1,2 and 4,5 have changed, which is where the example
code saved the personal data.
Page | 41
Fig 3.2.5: Data stored in card
Page | 42
The same can be done for the first name as well (contained in sectors 4), though
sector four contains carriage return and newline characters as the first two
bytes. These two characters are due to the setting on our serial monitor (Both
NL & CR). If we change the line setting to "No line ending” this disappears
and we just get “John” and “Smith” as outputs for sectors 1 and 4. Users can
also verify the hex to UTF-8 values by inserting the hex output to a hex
conversion website.
Page | 43
CHAPTER 4
The MFRC522 IC supports a wide variety of RFID Tags like MIFARE 1K,
MIFARE 4K, MIFARE Mini and other ISO / IEC 14443 protocol-based cards
and tags.
Page | 44
It operates at 13.46 MHz frequency and the operating range is up to 50 mm. The
MFRC522 IC supports three types of serial communication with the host
(Microcontroller like Arduino). They are:
• SPI
• UART
• I2C
The RC522 RFID Reader kit consists of the RC522 RFID Reader Module,
RFID card, RFID Key Fob and couple of male headers to solder. Both the RFID
Tags i.e., RFID Card and RDIF key fob in the kit are compatible with MIFARE
1K tags (they both have 1 KB of memory).
The RC522 RFID Reader Module consists of the MFRC522 IC, a 27.12 MHz
Crystal Oscillator, an Antenna embedded on the PCB and supporting passive
components to emit 13.56 MHz electromagnetic field.
Page | 45
4.1.2 INTERFACING LED AND BUZZER WITH CIRCUIT
The LED and BUZZER are added to the system in the circuit diagram
above. Buzzer and LED will glow when the card is presented to the RFID reader,
indicating that attendance has been recorded and uploaded to google sheets.
Page | 46
4.2 PROJECT CODE
4.2.1 CODE FOR ENTERING NAME IN CARD
#include <SPI.h> //include the SPI bus library
#include <MFRC522.h> //include the RFID reader library
//this is the block number we will write into and then read.
int block=4;
byte blockcontent[64] = {"XXXXXXX"}; //an array with 16 bytes to be written into one of the 64
card blocks is defined
//byte blockcontent[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //all zeros. This can be used to delete a
block.
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card (in case you wonder what PCD means: proximity
coupling device)
Serial.println("Scan your Tag");
// Prepare the security key for the read and write functions.
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF; //keyByte is defined in the "MIFARE_Key" 'struct' definition in the .h file
of the library
}
}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
Page | 47
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.println("card selected");
Page | 48
//status = mfrc522.MIFARE_Write(9, value1Block, 16);
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_Write() failed: ");
Serial.println(MFRC522::GetStatusCodeName(MFRC522::StatusCode()));
return 4;//return "4" as error message
}
Serial.println("block was written");
}
if (status != MFRC522::STATUS_OK) {
Serial.print("PCD_Authenticate() failed (read): ");
Serial.println(MFRC522::GetStatusCodeName(MFRC522::StatusCode()));
return 3;//return "3" as error message
}
//reading a block
byte buffersize = 18;//we need to define a variable with the read buffer size, since the MIFARE_Read
method below needs a pointer to the variable that contains the size...
status = mfrc522.MIFARE_Read(blockNumber, arrayAddress, &buffersize);//&buffersize is a pointer
to the buffersize variable; MIFARE_Read requires a pointer instead of just a number
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_read() failed: ");
Serial.println(MFRC522::GetStatusCodeName(MFRC522::StatusCode()));
return 4;//return "4" as error message
}
Serial.println("block was read");
}
var ss = SpreadsheetApp.openById('1njbfVkR7AV6h1H8SXsayICg3-ATvuSv5buTnBiI4q9w');
var sheet = ss.getSheetByName('Sheet1');
var timezone = "Asia/Kolkata"
//.........................................................................................
function doGet(e){
Logger.log( JSON.stringify(e) );
Page | 49
//----------------------------------------------------------------------------------
//write_google_sheet() function in esp32 sketch, is send data to this code block
//----------------------------------------------------------------------------------
//get gps data from ESP32
if (e.parameter == 'undefined') {
return ContentService.createTextOutput("Received data is undefined");
}
//----------------------------------------------------------------------------------
var Curr_Date = new Date();
var Curr_Time = Utilities.formatDate(Curr_Date, timezone, 'HH:mm:ss');
var name = stripQuotes(e.parameters.name);
//Logger.log('name=' + name);
//----------------------------------------------------------------------------------
var nextRow = sheet.getLastRow() + 1;
sheet.getRange("A" + nextRow).setValue(Curr_Date);
sheet.getRange("B" + nextRow).setValue(Curr_Time);
sheet.getRange("C" + nextRow).setValue(name);
//-------------------------------------
//returns response back to ESP32
return ContentService.createTextOutput("Card holder name is stored in column C");
//----------------------------------------------------------------------------------
}
//......................................................................................
function stripQuotes( value ) {
return value.toString().replace(/^["']|['"]$/g, "");
}
Page | 50
//GPIO 4 --> D2
#define RST_PIN D3
#define SS_PIN D4
#define BUZZER D2
#define LED D1
//-----------------------------------------
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
MFRC522::StatusCode status;
//-----------------------------------------
/* Be aware of Sector Trailer Blocks */
int blockNum = 4;
/* Create another array to read data from Block */
/* Legthn of buffer should be 2 Bytes more than the size of Block (16 Bytes) */
byte bufferLen = 64;
byte readBlockData[64];
/**********************************
* setup() function
**********************************/
void setup()
{
/* Initialize serial communications with the PC */
Serial.begin(9600);
//--------------------------------------------------
//WiFi Connectivity
Serial.println();
Serial.print("Connecting to WIFI");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED){
Serial.print(".");
delay(20);
}
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println();
/* Set BUZZER, LED as OUTPUT */
pinMode(BUZZER, OUTPUT);
pinMode(LED, OUTPUT);
/* Initialize SPI bus */
SPI.begin();
//--------------------------------------------------
}
/**********************************
* loop() function
**********************************/
void loop()
Page | 51
{
//------------------------------------------------------------------------
/* Initialize MFRC522 Module */
mfrc522.PCD_Init();
/* Look for new cards */
/* Reset the loop if no new card is present on RC522 Reader */
if ( ! mfrc522.PICC_IsNewCardPresent()) {return;}
/* Select one of the cards */
if ( ! mfrc522.PICC_ReadCardSerial()) {return;}
/* Read data from the same block */
Serial.println();
Serial.println(F("Reading last data from RFID..."));
//------------------------------------------------------------------------
String fullURL = "", temp;
for (byte i = 0; i < blocks_len; i++) {
ReadDataFromBlock(blocks[i], readBlockData);
if(i == 0){
temp = String((char*)readBlockData);
temp.trim();
temp.trim();
//fullURL += "&data" + String(i) + "=" + temp;
fullURL += temp;
}
}
fullURL.trim();
fullURL = web_app_url+ fullURL;
fullURL.trim();
Serial.println(fullURL);
//------------------------------------------------------------------------
digitalWrite(BUZZER, HIGH);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
delay(200);
digitalWrite(BUZZER, HIGH);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(BUZZER, LOW);
digitalWrite(LED, LOW);
delay(3000);
Page | 52
//.................................................................................
if (WiFi.status() == WL_CONNECTED) {
//-------------------------------------------------------------------------------
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
//-------------------------------------------------------------------------------
client->setInsecure();
//-------------------------------------------------------------------------------
HTTPClient https;
Serial.print(F("[HTTPS] begin...\n"));
//.................................................................................
if (https.begin(*client, (String)fullURL)){
//-----------------------------------------------------------------
Serial.print(F("[HTTPS] GET...\n"));
// start connection and send HTTP header
int httpCode = https.GET();
//-----------------------------------------------------------------
// httpCode will be negative on error
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTPS] GET... code: %d\n", httpCode);
// file found at server
}
//-----------------------------------------------------------------
else
{Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());}
//-----------------------------------------------------------------
https.end();
delay(10);
}
//.............................................................................................
else {
Serial.printf("[HTTPS} Unable to connect\n");
}
}
}
/* ReadDataFromBlock() function
**********************************/
void ReadDataFromBlock(int blockNum, byte readBlockData[])
{
/* Prepare the ksy for authentication */
/* All keys are set to FFFFFFFFFFFFh at chip delivery from the factory */
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
/* Authenticating the desired data block for Read access using Key A */
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum,
&key, &(mfrc522.uid));
//----------------------------------------------------------------------------
Page | 53
if (status != MFRC522::STATUS_OK){
Serial.print("Authentication failed for Read: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
//----------------------------------------------------------------------------
else {
Serial.println("Authentication success");
}
//----------------------------------------------------------------------------
/* Reading data from the Block */
status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen);
if (status != MFRC522::STATUS_OK) {
Serial.print("Reading failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
//----------------------------------------------------------------------------
else {
readBlockData[16] = ' ';
readBlockData[17] = ' ';
Serial.println("Block was read successfully");
}
}
Page | 54
CHAPTER 5
To get register with your name, one should enter their name in the card. To
enter their name in the card on should dump the code mentioned in chapter 7 into
the NODEMCU.
When the code is dumped into the NODEMCU, now show the tag that is
to be registered to the RFID reader, then the name mentioned in the code will be
uploaded in the card. Output will be displayed in the serial monitor.
To register for attendance, one must scan their card against the RFID
reader. Once scanned, the recorded data, i.e., name, is sent to an excel sheet along
with the date and time.
Page | 55
Fig 5.2: Excel sheet display
→ The output when the registered card is scanned is shown in the red-
coloured box in the excel sheet.
→ The output when the unregistered card is scanned is shown in the green-
coloured box in the excel sheet.
5.3 CONCLUSION
Through the proposed IoT based smart attendance system using RFID the
existing manual system of registering the attendance can be transformed into an
efficient and error-free attendance management system. By employing this
system information can be conveyed without a hitch. The proposed system will
Page | 56
be of great help in schools, colleges and any organizations to monitor their
students or employees. Although there are different methods of managing the
student’s or employee’s attendance, the proposed system is easy to handle and
very convenient for any organization. The proposed system is time-saving, user-
friendly and reliable to use.
A hex key pad keypad can be interfaced to micro controller board by which
user can enter his password then only the lock can be opened. This ensures even
if someone has card then also without the password, he can't get access.
Every good engineering design innovation has limitation. The passive RFID
based lecture attendance monitoring system is not without limitation as a data
collection technology with accurate and timely data entry. Hence, the limitation
of this design would be improved upon in future by considering the following
salient recommendations:
Page | 57
REFERENCES
[2]. Zhang Yuru, Chen Delong and Tan Liping, The Research and Application of
College Student Attendance System based on RFID Technology International
Journal of Control and Automation Vol. 6, No. 2, April, 2013.
[3]. Sumita Nainan, Romin Parekh and Tanvi Shah, RFID Technology Based
Attendance Management System IJCSI International Journal of Computer
Science Issues, Vol. 10, Issue 1, No 1, January 2013.
[4]. Ankita Agrawal and Ashish Bansal, Online Attendance Management System
Using RFID with Object Counter International Journal of Information and
Computation Technology, ISSN 0974-2239 Volume 3, ©International Research
Publications House, Number 3 (2013), pp. 131-138.
Page | 58