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

 Sunday, May 9 2021 Breaking News IoT Based Bidirectional Visitor Counter using ESP8266 & Blynk         

HOME ARDUINO PROJECTS ELECTRONICS CIRCUITS IOT PROJECTS MICRO CONTROLLERS       Search for 

 Home / IoT Projects / IoT Based RFID Attendance System using ESP32

ESP32 IoT Projects 

IoT Based RFID Attendance


System using ESP32
Alsan Parajuli   • June 10, 2020  15  23  11 minutes read

Follow Us 

431 89
 Fans  Followers

1,600 455
 Subscribers  Followers

Popular Recent

In this project, I will tell you how to build a Portable IoT based RFID Attendance System using ESP32,
0.96” OLED Display & MF-RC522 Module. RFID Attendance Systems are commonly used to mark the
IoT Fall Detector Using
presence of students or staff in schools and offices. MPU6050 & ESP8266
 April 2, 2021

Pulse Oximeter using


Table Of Contents
Arduino & MAX30100
How IoT based RFID Attendance System Works?
 34 mins ago
Features of RFID Attendance Website
Functions Provided to users and Admin IoT based Fire Detector &
Components Required Automatic Extinguisher
Hardware Components using NodeMCU
 September 8, 2020
Software Components
Technology Used in RFID attendance System with ESP32 RFID Based Attendance
Network Topology: IoT Based RFID Attendance System using ESP32 System Using NodeMCU
with PHP Web App
Interfacing RFID RC522 & 0.96″ OLED Display to ESP32 Module
 April 23, 2020
How to run a server for this project?
Intruder Security Alarm
Deploying RFID Attendance Web App
using Vibration Sensor
Setting Up Arduino IDE for ESP32  3 weeks ago
Selecting Port and Board
Library Files for IoT Based RFID Attendance System Dual Axis Solar Tracker
Program/Sketch Code Arduino Project Using LDR
Final Code: IoT Based RFID Attendance System using ESP32 & Servo Motors
 March 8, 2020
Conclusion
Share & Spread Knowledge: IoT Based Patient Health
Monitoring System Using
ESP8266/ESP32 Web
This project has a wide area in the modern era of schools, colleges, business organizations, offices where Server
accurate attendance data is required. The RFID attendance system makes the process much easier and  June 25, 2020

more reliable. But before getting started, let’s learn How RFID Attendance System works? Program Digispark
Attiny85 with Arduino IDE

How IoT based RFID Attendance System Works?


 3 weeks ago

The ESP32 Wi-Fi Module will collect the RFID CARD/keychain UID  from the multiple users and sends it over
the internet to a website. The Enrollment of RFID CARD is done on the server using any MF-RC522 RFID
Module that is available on the market. The verification of the Card/keychain will be done on the webserver,
while Card UID is transmitted over the WiFi.
Recent Posts 

IoT Based Bidirectional Visitor


Bidirectional Visitor Counter &
Counter using Automatic Light
ESP8266 & Blynk Control using
 4 days ago Arduino
 2 weeks ago

The website used in this project is developed using PHP, CSS, and Javascript, it has a database to record
Card UID. By logging in to the web server, we can collect personal records of each attendee as well as all Arduino Intruder Intruder Security
Security Alert Alarm using
attendance records, including incoming and outgoing times. These data can also be downloaded and
System Vibration Sensor
exported to an excel sheet.  3 weeks ago  3 weeks ago

Features of RFID Attendance Website


Safe Login System

Admin Panel
Program Digispark Interface BME680
User Entry Log Attiny85 with Environmental
User Management System Arduino IDE Sensor with Arduino
 3 weeks ago  April 8, 2021
Multiple Device Management System

Filter log data by date, On-time, time-out, and department

Export those filtered data to Excel.

Note: Generally, administrators play an important role in the management of


this system.

Functions Provided to users and Admin Categories 

Now, talking about the features of the RFID based Attendance system using ESP32. The home page
displays the admin login page. Until you login to the system, you will not be able to browse other available  Arduino Projects 38

options. So the system is safe. In general, the design of the RFID presence system project is quite simple. So  IoT Projects 36
the user does not find any difficulties in registering his/her Attendance. The user must swipe his/her card or
 ESP8266 29
keychain to enroll in attendance, including entry time. The main tasks assigned to the administrator are as
 Articles 10
follows:
 Micro controllers 5

You can watch the following video tutorial for detailed information, or you can  ESP32 3
read the article written here.
 Raspberry Pi Projects 1

 Electronics Circuits 1

Admin Login/Logout System 

Forgot Password for admin

Edit and Update admin profile

Manage Users

View users

Add New User

Edit and update the existing users

Remove Users

From the admin panel, administrators can add new users, update and remove users using the user
management system. Additionally, the administrator can view all attendance records.

Manage Device

Add new device

Update existing device

Delete device

Update New token to the device

Change the device mode (Enrollment mode: to register new users to the system, Attendance Mode:
To record attendance of registered users)

In fact, from device section administrators can add a new device, update, and remove too. To add a new
device you need to enter the device name and its depart. Additionally, you can update the device token
from the device UID section.

View user log

From the User Log menu, you can navigate to all user log data. You can also see their arrival and departure
times. It also filters your logs to filter user, date, arrival time, timeout, and various sections. So you can export
that data to Excel.

Components Required
Following are the Hardware and Software components required for making IoT Based RFID Attendance
System Using ESP32.

Hardware Components

COMPONENTS
S.N DESCRIPTION QUANTITY
NAME

1 ESP32 Board ESP32 ESP-32S Development Board 1 https://amzn.to/3sfU0or

2 0.96 Inch OLED 0.96 Inch OLED Module 128x64 1 https://amzn.to/3pGssa7


Display SSD1306 Driver I2C Serial Self-
Luminous Display Board

3 RFID Module RFID-RC522 Module 1 https://amzn.to/3pOPpb4

4 Jumper Wires Male to Male Jumper Wires 10 https://amzn.to/2JWSR44

5 Breadboard Solderless Breadboard MIni 1 https://amzn.to/3n33uRT

Software Components
Arduino IDE

XAMPP server

PHP Source Code

RFID-RC522 Library

NodeMcu ESP8266 Library and Board Manager

Technology Used in RFID attendance System with


ESP32
Here we are listing all the major required software components for this project to develop the user interface.

1. Embedded C: All the hardware interface coding has been done in embedded C Language.

2. PHP: All the Logics and web interface is written in PHP Language.

3. MYSQL: For database, MYSQL Database is used.

4. Apache 2: To run the web interface over the Apache 2 server.

5. Javascript and CSS: To Style web Interface with animation and validate the form.

Network Topology: IoT Based RFID Attendance


System using ESP32
This is a simple network topology designed to run this project through a local network. Project devices and
computer servers are connected to the same network via Wi-Fi.

Now its time to interface all the components together to build the project.

Interfacing RFID RC522 & 0.96″ OLED Display to ESP32


Module
Using the table and circuit diagram provided below you can easily assemble your circuit.

ESP32 RFID MFRC522 / RC522

GPIO 4 SDA/SS

GPIO 18 SCK

GPIO 17 MOSI

GPIO 16 MISO

GND GND

GPIO 5 RST

Vcc/3.3v 3.3V

ESP32 0.96″OLED Display

GPIO 22 SCL

GPIO 21 SDA

GND GND

Vcc 3.3V/Vin for 5V

Assemble Circuit using this table

Circuit Diagram: IoT based RFID Attendance System using ESP32 and OLED Display

How to run a server for this project?


In fact, we can use this PHP web application on hosting servers as well. However, you need a public IP from
your broadband connection to send data to the hosting server.

Anyway, we are using the XAMPP server. It can be used on both Windows and Linux. Generally, Ubuntu
users can use LAMP which is better than XAMPP. But, I am using Windows so I am going to use the XAMPP
server. So you can download XAMPP server from this link

Deploying RFID Attendance Web App


Start your Mysql and Apache from XAMPP Control Panel.

Download the PHP web app and the Arduino IDE Program code.

Extract the file.

Copy the rfidattendance folder (Main Project folder).

Paste the folder in C:\>xampp/htdocs/ folder.

Now let’s connect the database to the RFID attendance system.

Open the browser and go to the URL “http://localhost/phpmyadmin/”

Then click on the database tab.

Create a database name “rfidattendance” and then click on the import tab.

Click on the browse file and then choose the “rfidattendance.sql” file located inside the rfidattendance
folder.

Click on Go.

After creating a database, open a browser and go to the URL “http://localhost/rfidattenddance/”. Now, the
admin login panel will be displayed.

Admin Panel Login System

Enter the admin email and password to enter the system.

The default admin credentials is: email= admin@gmail.com, and password= 123.

Setting Up Arduino IDE for ESP32


We need to add the esp32 board to our Arduino IDE. Open up your IDE then go to “File -> Preferences” or
simply hit “Ctrl + comma”.

Paste https://dl.espressif.com/dl/package_esp32_index.json in additional board manager URLs. 

Go to “Tools -> Board -> Boards Manager” search and install ESP32.

Selecting Port and Board


Go to Tools -> Port and select the COM Port of your ESP32. If you are not sure what port your ESP32 is
plugged in, go to Device Manager -> Ports (COM & LPT).

Now select Your ESP32 Board by clicking Tools -> Board. Scroll down until you find it.

Library Files for IoT Based RFID Attendance System


You have to install the following library files to your Arduino IDE Libraries folder:

RFID Library

Adafruit GFX

Adafruit SSD1306

Program/Sketch Code
The source code for the Portable IoT Based RFID Attendance System using ESP32 is here. In this source
code, you need to do some modifications like your WiFi Network credentials, Device token from the
website, and PC IP Address.

Include ESP32, RFID, Adafruit GFX, and Adafruit SSD1306 Library header files.

#include <WiFi.h>
#include <HTTPClient.h>
#include <time.h>
//RFID-----------------------------
#include <SPI.h>
#include <MFRC522.h>
//OLED-----------------------------
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Defining Pin of all the components that are interfaced to ESP32 board.

#define SS_PIN 4 // SCK-GPIO 18, MOSI-GPIO 17, MISO-GPIO 16, Vcc-3.3v, GND -GND,
#define RST_PIN 5
// Declaration for SSD1306 display connected using software I2C pins are(22 SCL, 21 SDA)
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 0 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Create MFRC522 instance.

MFRC522 mfrc522(SS_PIN, RST_PIN);

Set these to your desired credentials. Your WiFi SSID Name, Password, and Device Token.

const char *ssid = "SSID";


const char *password = "Password";
const char* device_token = "Device Token";

Replace “x” your timezone.

int timezone = x * 3600;


int time_dst = 0;

Your computer IP or the server domain.

String URL = "http://YourComputerIP/rfidattendance/getdata.php";

Initiate SPI bus and MFRC522 card

SPI.begin();
mfrc522.PCD_Init();

check if there’s a connection to Wi-Fi or not.

if(!WiFi.isConnected())

Retry to connect to Wi-Fi

connectToWiFi();

look for new card

if ( ! mfrc522.PICC_IsNewCardPresent()) {

go to start of loop if there is no card present

if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;

Select one of the cards. If read card serial(0) returns 1, the UID struct contains the ID of the read card.

if ( ! mfrc522.PICC_ReadCardSerial()) {
return;

Send the Card UID to the website.

void SendCardID( String Card_uid ){


Serial.println("Sending the Card ID");
if(WiFi.isConnected()){
HTTPClient http; //Declare object of class HTTPClient
//GET Data
getData = "?card_uid=" + String(Card_uid) + "&device_token=" + String(device_token); // Add
the Card ID to the GET array in order to send it
//GET methode
Link = URL + getData;
http.begin(Link); //initiate HTTP request //Specify content-type header

int httpCode = http.GET(); //Send the request


String payload = http.getString(); //Get the response payload

// Serial.println(Link); //Print HTTP return code


Serial.println(httpCode); //Print HTTP return code
Serial.println(Card_uid); //Print Card ID
Serial.println(payload); //Print request response payload

if (httpCode == 200) {
if (payload.substring(0, 5) == "login") {
String user_name = payload.substring(5);
// Serial.println(user_name);

}
else if (payload.substring(0, 6) == "logout") {
String user_name = payload.substring(6);
// Serial.println(user_name);

}
else if (payload == "succesful") {

}
else if (payload == "available") {

}
delay(100);
http.end(); //Close connection
}
}
}

connect to the WiFi

void connectToWiFi(){
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected");

Serial.print("IP address: ");


Serial.println(WiFi.localIP()); //IP address assigned to your ESP

delay(1000);
}

Print the IP address assigned to your ESP32

Serial.print("IP address: ");


Serial.println(WiFi.localIP());

Final Code: IoT Based RFID Attendance System using


ESP32
Also Read:

ESP8266 Plot Sensor readings to Webserver in Real-Time Chart

RFID Based Attendance System Using NodeMCU with PHP Web App

IoT based Silent Intruder Alarm using Arduino

IoT Based RFID Smart Door Lock System Using NodeMCU ESp8266

/* -----------------------------------------------------------------------------
- Project: RFID attendance system using ESP32
- Author: https://www.youtube.com/ElectronicsTechHaIs
- Date: 6/03/2020
-----------------------------------------------------------------------------
This code was created by Electronics Tech channel for
the RFID attendance project with ESP32.
---------------------------------------------------------------------------*/
//*******************************libraries********************************
//ESP32----------------------------
#include <WiFi.h>
#include <HTTPClient.h>
#include <time.h>
//RFID-----------------------------
#include <SPI.h>
#include <MFRC522.h>
//OLED-----------------------------
#include <Wire.h>
#include <Adafruit_GFX.h> //https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_SSD1306.h> //https://github.com/adafruit/Adafruit_SSD1306
//************************************************************************
#define SS_PIN 4 // SCK-GPIO 18, MOSI-GPIO 17, MISO-GPIO 16, Vcc-3.3v, GND -GND,
#define RST_PIN 5
// Declaration for SSD1306 display connected using software I2C pins are(22 SCL, 21 SDA)
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 0 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//************************************************************************
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
//************************************************************************
/* Set these to your desired credentials. */
const char *ssid = "SSID";
const char *password = "Password";
const char* device_token = "Device Token";
//************************************************************************
int timezone = x * 3600; //Replace "x" your timezone.
int time_dst = 0;
String getData, Link;
String OldCardID = "";
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
String URL = "http://YourComputerIP/rfidattendance/getdata.php"; //computer IP or the server
domain
//*************************Biometric Icons*********************************
#define Wifi_start_width 54
#define Wifi_start_height 49
const uint8_t PROGMEM Wifi_start_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x1f,0xf0,0x00,0x00,0x00
,0x00,0x03,0xff,0xff,0x80,0x00,0x00
,0x00,0x1f,0xf0,0x1f,0xf0,0x00,0x00
,0x00,0x7e,0x00,0x00,0xfc,0x00,0x00
,0x01,0xf0,0x00,0x00,0x1f,0x00,0x00
,0x03,0xc0,0x00,0x00,0x07,0xc0,0x00
,0x0f,0x00,0x00,0x00,0x01,0xe0,0x00
,0x1c,0x00,0x00,0x00,0x00,0x70,0x00
,0x38,0x00,0x07,0xc0,0x00,0x38,0x00
,0x70,0x00,0xff,0xfe,0x00,0x1e,0x00
,0xe0,0x03,0xfc,0x7f,0xc0,0x0e,0x00
,0x00,0x1f,0x80,0x03,0xf0,0x00,0x00
,0x00,0x3c,0x00,0x00,0x78,0x00,0x00
,0x00,0xf0,0x00,0x00,0x1c,0x00,0x00
,0x01,0xe0,0x00,0x00,0x0c,0x00,0x00
,0x03,0x80,0x00,0x00,0x00,0x00,0x00
,0x03,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x3f,0xf8,0x07,0x1e,0x00
,0x00,0x00,0xff,0xfe,0x1f,0xbf,0x80
,0x00,0x03,0xe0,0x04,0x7f,0xff,0xc0
,0x00,0x07,0x80,0x00,0xff,0xff,0xe0
,0x00,0x0e,0x00,0x00,0xff,0xff,0xe0
,0x00,0x0c,0x00,0x00,0x7f,0xff,0xc0
,0x00,0x00,0x00,0x00,0xfe,0x07,0xe0
,0x00,0x00,0x00,0x03,0xf8,0x03,0xf8
,0x00,0x00,0x07,0xe7,0xf9,0xf1,0xfc
,0x00,0x00,0x1f,0xe7,0xf1,0xf9,0xfc
,0x00,0x00,0x1f,0xe7,0xf3,0xf9,0xfc
,0x00,0x00,0x3f,0xe7,0xf3,0xf9,0xfc
,0x00,0x00,0x3f,0xe7,0xf1,0xf1,0xfc
,0x00,0x00,0x3f,0xe3,0xf8,0xe3,0xfc
,0x00,0x00,0x3f,0xf3,0xfc,0x07,0xf8
,0x00,0x00,0x1f,0xf0,0x7f,0x0f,0xc0
,0x00,0x00,0x0f,0xe0,0x7f,0xff,0xe0
,0x00,0x00,0x07,0xc0,0xff,0xff,0xe0
,0x00,0x00,0x00,0x00,0x7f,0xff,0xe0
,0x00,0x00,0x00,0x00,0x3f,0xff,0x80
,0x00,0x00,0x00,0x00,0x1f,0xbf,0x00
,0x00,0x00,0x00,0x00,0x03,0x18,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define Wifi_connected_width 63
#define Wifi_connected_height 49
const uint8_t PROGMEM Wifi_connected_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x03,0xff,0xff,0x80,0x00,0x00
,0x00,0x00,0x3f,0xff,0xff,0xf8,0x00,0x00
,0x00,0x01,0xff,0xff,0xff,0xff,0x00,0x00
,0x00,0x0f,0xff,0xff,0xff,0xff,0xe0,0x00
,0x00,0x3f,0xff,0xc0,0x07,0xff,0xf8,0x00
,0x00,0xff,0xf8,0x00,0x00,0x3f,0xfe,0x00
,0x03,0xff,0x80,0x00,0x00,0x03,0xff,0x80
,0x07,0xfe,0x00,0x00,0x00,0x00,0xff,0xc0
,0x1f,0xf8,0x00,0x00,0x00,0x00,0x3f,0xf0
,0x3f,0xe0,0x01,0xff,0xff,0x00,0x0f,0xf8
,0x7f,0x80,0x0f,0xff,0xff,0xe0,0x03,0xfc
,0xff,0x00,0x7f,0xff,0xff,0xfc,0x01,0xfe
,0xfc,0x01,0xff,0xff,0xff,0xff,0x00,0x7e
,0x78,0x07,0xff,0xc0,0x07,0xff,0xc0,0x3c
,0x00,0x0f,0xfc,0x00,0x00,0x7f,0xe0,0x00
,0x00,0x1f,0xf0,0x00,0x00,0x1f,0xf0,0x00
,0x00,0x3f,0xc0,0x00,0x00,0x07,0xf8,0x00
,0x00,0x7f,0x00,0x01,0x00,0x01,0xfc,0x00
,0x00,0x7e,0x00,0x7f,0xfc,0x00,0xfc,0x00
,0x00,0x3c,0x03,0xff,0xff,0x80,0x78,0x00
,0x00,0x00,0x07,0xff,0xff,0xc0,0x00,0x00
,0x00,0x00,0x1f,0xff,0xff,0xf0,0x00,0x00
,0x00,0x00,0x3f,0xf0,0x1f,0xf8,0x00,0x00
,0x00,0x00,0x3f,0x80,0x03,0xf8,0x00,0x00
,0x00,0x00,0x3f,0x00,0x01,0xf8,0x00,0x00
,0x00,0x00,0x1c,0x00,0x00,0x70,0x00,0x00
,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x0f,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xf0,0x00,0x00,0x00
,0x00,0x00,0x00,0x3f,0xf8,0x00,0x00,0x00
,0x00,0x00,0x00,0x3f,0xf8,0x00,0x00,0x00
,0x00,0x00,0x00,0x3f,0xf8,0x00,0x00,0x00
,0x00,0x00,0x00,0x3f,0xf8,0x00,0x00,0x00
,0x00,0x00,0x00,0x1f,0xf0,0x00,0x00,0x00
,0x00,0x00,0x00,0x0f,0xe0,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
//************************************************************************
void setup() {
delay(1000);
Serial.begin(115200);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
//-----------initiate OLED display-------------
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// you can delet these three lines if you don't want to get the Adfruit logo appear
display.display();
delay(2000); // Pause for 2 seconds
display.clearDisplay();
//---------------------------------------------
connectToWiFi();
//---------------------------------------------
configTime(timezone, time_dst, "pool.ntp.org","time.nist.gov");
}
//************************************************************************
void loop() {
//check if there's a connection to Wi-Fi or not
if(!WiFi.isConnected()){
connectToWiFi(); //Retry to connect to Wi-Fi
}
//---------------------------------------------
if (millis() - previousMillis1 >= 1000) {
previousMillis1 = millis();
display.clearDisplay();

time_t now = time(nullptr);


struct tm* p_tm = localtime(&now);
display.setTextSize(1); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(10,0);
Serial.println(p_tm);
display.setTextSize(4); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0,21);
if ((p_tm->tm_hour)<10) {display.print("0");display.print(p_tm->tm_hour);}
else display.print(p_tm->tm_hour);
display.print(":");
if ((p_tm->tm_min)<10) {display.print("0");display.println(p_tm->tm_min);}
else display.println(p_tm->tm_min);
display.display();
}
//---------------------------------------------
if (millis() - previousMillis2 >= 15000) {
previousMillis2 = millis();
OldCardID="";
}
delay(50);
//---------------------------------------------
//look for new card
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;//got to start of loop if there is no card present
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;//if read card serial(0) returns 1, the uid struct contians the ID of the read card.
}
String CardID ="";
for (byte i = 0; i < mfrc522.uid.size; i++) {
CardID += mfrc522.uid.uidByte[i];
}
//---------------------------------------------
if( CardID == OldCardID ){
return;
}
else{
OldCardID = CardID;
}
//---------------------------------------------
// Serial.println(CardID);
SendCardID(CardID);
delay(1000);
display.clearDisplay();
}
//************send the Card UID to the website*************
void SendCardID( String Card_uid ){
Serial.println("Sending the Card ID");
if(WiFi.isConnected()){
HTTPClient http; //Declare object of class HTTPClient
//GET Data
getData = "?card_uid=" + String(Card_uid) + "&device_token=" + String(device_token); // Add
the Card ID to the GET array in order to send it
//GET methode
Link = URL + getData;
http.begin(Link); //initiate HTTP request //Specify content-type header

int httpCode = http.GET(); //Send the request


String payload = http.getString(); //Get the response payload

// Serial.println(Link); //Print HTTP return code


Serial.println(httpCode); //Print HTTP return code
Serial.println(Card_uid); //Print Card ID
Serial.println(payload); //Print request response payload

if (httpCode == 200) {
if (payload.substring(0, 5) == "login") {
String user_name = payload.substring(5);
// Serial.println(user_name);

display.clearDisplay();
display.setTextSize(2); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(15,0); // Start at top-left corner
display.print(F("Welcome"));
display.setCursor(0,20);
display.print(user_name);
display.display();
}
else if (payload.substring(0, 6) == "logout") {
String user_name = payload.substring(6);
// Serial.println(user_name);

display.clearDisplay();
display.setTextSize(2); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(10,0); // Start at top-left corner
display.print(F("Good Bye"));
display.setCursor(0,20);
display.print(user_name);
display.display();
}
else if (payload == "succesful") {
display.clearDisplay();
display.setTextSize(2); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(5,0); // Start at top-left corner
display.print(F("New Card"));
display.display();
}
else if (payload == "available") {
display.clearDisplay();
display.setTextSize(2); // Normal 2:2 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(5,0); // Start at top-left corner
display.print(F("Free Card"));
display.display();
}
delay(100);
http.end(); //Close connection
}
}
}
//********************connect to the WiFi******************
void connectToWiFi(){
WiFi.mode(WIFI_OFF); //Prevents reconnection issue (taking too long to connect)
delay(1000);
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.print(F("Connecting to \n"));
display.setCursor(0, 50);
display.setTextSize(2);
display.print(ssid);
display.drawBitmap( 73, 10, Wifi_start_bits, Wifi_start_width, Wifi_start_height, WHITE);
display.display();

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected");

display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(8, 0); // Start at top-left corner
display.print(F("Connected \n"));
display.drawBitmap( 33, 15, Wifi_connected_bits, Wifi_connected_width,
Wifi_connected_height, WHITE);
display.display();

Serial.print("IP address: ");


Serial.println(WiFi.localIP()); //IP address assigned to your ESP

delay(1000);
}
//=======================================================================

Thank You so much Electronics Tech Channel for this awesome Project.

Download RFIDATTENDANCE V2.0

Conclusion
Finally, we have completed the IoT Based RFID Attendance System Using ESP32 with a Website and
Database. I hope you found this project useful! Drop a comment below if you have any doubts or queries. l
will try my best to answer your questions.

Also Read:

Home Automation with MIT App Inventor and ESP8266

IoT Based LED Control using Google Firebase & ESP8266

IoT Based Flood Monitoring System Using NodeMCU & Thingspeak

How can IoT help within the COVID-19 crisis

Electronic Voting Machine Using Arduino & LCD Display

Home Automation with ESP8266 Web Server & Relay Module Control Appliances from Local Network

Share & Spread Knowledge:

 Twitter  Facebook  LinkedIn  Pinterest 172  Telegram  WhatsApp

#IoT based Attendance system #IoT based RFID Attendance with ESP32

#IoT based RFID Attendance with ESP8266 #RFID Attendance system

Alsan Parajuli
I am a WordPress enthusiast, a hardworking and highly positive person. I always believes in practicality
rather than theoretical knowledge. With my curiosity and fast learning skills, I managed to learn
everything on my own. I love coding, editing, writing and rummaging around Internet. I am passionate
about IoT Projects, Digital marketing, website designing, and reviewing. Moreover, I had been
contributing to WordPress Biratnagar as an active member since 2018.

      

Read Next

ESP8266

March 25, 2021

Portable Wi-Fi Repeater using ESP8266


NodeMCU

4 days ago April 2, 2021 March 25, 2021 February 24, 2021
IoT Based Bidire… IoT Fall Detector… Portable Wi-Fi R… BMP280 Based I…

Related Articles

ESP8266 & BME280 IoT DHT11 Temperature and LoRa Based Wireless Weather
Weather Station Humidity Monitor with Station using Arduino & ESP32
 February 7, 2021 NodeMCU on ThingSpeak  December 20, 2020
 January 19, 2021

15 Comments

Pingback: Capacitive Soil Moisture Sensor with OLED Display & Arduino-IoT Projects

Pingback: BME280 Based Mini Weather Station using ESP8266/ESP32

Pingback: IoT Based Patient Health Monitoring System Using ESP8266/ESP32

Pingback: BME680 Environment Monitoring System using ESP8266

Pingback: Fire Security System using Arduino & Flame Sensor | The IOT Projects

Pingback: IoT based Fire Detector & Automatic Extinguisher using NodeMCU

Chinpuy
September 21, 2020 at 8:33 pm

Hello how do i change time in and out acording to my country time zone ?

Reply

articnl
October 20, 2020 at 1:47 am

replace x with a numer . like 1 is = +1 hour

Reply

Pingback: LoRa Based Wireless Weather Station using Arduino & ESP32

Madhavi
December 21, 2020 at 8:59 pm

Great work! But can we use MQTT protocol instead of http in this project. If yes then can you please explain
in brief as how to use it.

Reply

sudhakar
January 19, 2021 at 8:58 am

can i do this using esp8266

Reply

Alsan Parajuli
January 19, 2021 at 5:44 pm

Yes you can do

Reply

bella
March 1, 2021 at 3:39 pm

Hi Alsan the password is not 123. I change it in db with MD5 field but doesn.t work. Whot can I do? thanks

Reply

jack
April 27, 2021 at 12:09 pm

if I want to add a mlx90614 sensor to the database, how do I do it? Help me

Reply

George
May 8, 2021 at 6:19 am

Hi Alsan,

After successfully getting a WEMOS d1 mini running with NodeMCU_RFIDv2.0.INO with your help.
I now want to run my ESP32-WROOM with ESP32_RFID.INO.

I see in serial port:


Connecting to Ziggo6480948
…..
Connected
IP address: 192.168.178.117
Thu Jan 1 02:00:07 1970
Sat May 8 02:17:22 2021
Sat May 8 02:17:23 2021
Sat May 8 02:17:24 2021
Sat May 8 02:17:25 2021
Sat May 8 02:17:26 2021

And date and time keeps running ….


I have no response when I hold a card in front of the RFID RC522 Module.

I use same IP adres as with NodeMCU_RFIDv2.0.INO so connection doesn’t seems the problem.

Do you have any idea why that is?

Reply

Leave a Reply

“The IoT Projects” is a hub of electronics Categories Social


projects. The website is built and Run by
passionate enthusiasts, hard-working, and
highly positive persons. We always believe in  Arduino Projects 38
   
Most Viewed Posts practicality rather than theoretical knowledge.  IoT Projects 36
So we share various electronics IoT ” Internet
Of Things” projects from beginner’s level to  ESP8266 29
Subscribe to us
IoT Fall Detector the advanced.
 Articles 10
Using MPU6050 &
ESP8266  Micro controllers 5 Enter your email address to subscribe to this
Last Modified Posts
 April 2, 2021 blog and receive notifications of new posts by
 ESP32 3
email.
Pulse Oximeter
using Arduino &  Raspberry Pi Projects 1 Email Address
MAX30100  Electronics Circuits 1 Subscribe
 34 mins ago

IoT based Fire


Detector &
Automatic
Extinguisher using
NodeMCU
 September 8, 2020

RFID Based
Attendance System
Using NodeMCU
with PHP Web App
 April 23, 2020

Intruder Security
Alarm using
Vibration Sensor
 3 weeks ago

Dual Axis Solar


Tracker Arduino
Project Using LDR &
Servo Motors
 March 8, 2020

© Copyright 2021, All Rights Reserved  |  The IoT Projects     Privacy Policy Disclaimer DMCA Advertise With us

You might also like