Attendance management systems are crucial in various domains, such as workplaces, educational institutions, and events. Traditional systems require manual intervention, making them susceptible to errors and delays. This biometric-based system automates the attendance process using fingerprint verification, ensuring a secure, efficient, and accurate record of attendance. ESP32, a Wi-Fi-enabled microcontroller, connects the system to the internet, allowing remote attendance logging.
Components
-
- This is the main control board, responsible for handling the fingerprint sensor, managing Wi-Fi connections, and sending attendance data.
- It has GPIO pins for communication with sensors, displays, and other peripherals.
-
- Used for capturing and verifying fingerprints to identify authorized users.
- This sensor is highly secure as it recognizes unique biometric patterns for each person, ensuring that only authorized fingerprints are recorded.
-
- Provides visual feedback for the user, displaying messages like "Place Finger," attendance status, and Wi-Fi connection notifications.
- The display operates on I2C protocol, minimizing the number of connections to the ESP32.
-
- Produces a sound as feedback during fingerprint authentication.
- The buzzer sounds differently for successful and unsuccessful attempts, making it easy for users to understand the result without looking at the display.
Circuit Diagram and Connections
-
ESP32 to Fingerprint Sensor: The RX and TX pins on the fingerprint sensor connect to TX2 (GPIO17) and RX2 (GPIO16) on the ESP32, allowing serial communication between the two devices.
-
ESP32 to OLED Display: The I2C pins (SDA and SCL) of the OLED are connected to GPIO21 and GPIO22 of the ESP32. This allows two-wire communication with the display.
-
ESP32 to Buzzer: The buzzer connects to GPIO15 of the ESP32. It will buzz based on the feedback from fingerprint recognition
Explanation of Code
This project consist of 2 coding parts , 1st is registering the fingerprints in the fingerprint sensor, those registered fingerprints will be stored in the fingerprint sensor's internal memory with the help of enroll code from the example section of Arduino IDE. Then you have to write another code for the esp for monitoring the attendance.
For that you have to install Adafruit fingerprint sensor library from github.
In the enroll example code, you have to make some changes (as given in pictures below of before and after) to register your fingerprints.
Once yo've
1. Library Inclusions and Global Settings
#include <Adafruit_Fingerprint.h>
#include <WiFi.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
These libraries are essential for the various hardware components:
- Adafruit_Fingerprint: Manages the fingerprint sensor, providing methods for fingerprint recognition and data handling.
- WiFi: Handles ESP32’s Wi-Fi functionality for connecting to the internet.
- Adafruit_GFX and Adafruit_SSD1306: Control the OLED display, allowing text and graphic rendering.
- NTPClient and WiFiUdp: Libraries for retrieving the current time from NTP servers.
2. OLED Display and Fingerprint Sensor Configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
- SCREEN_WIDTH and SCREEN_HEIGHT specify the resolution of the OLED display.
-
OLED_RESET is set to
-1
because ESP32 does not use a reset pin with the display. - display: Instantiates the OLED with the settings above, which allows display functions to be called throughout the code.
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial2);
-
finger: Initializes the fingerprint sensor on the
Serial2
interface, setting up communication through this secondary serial channel of ESP32.
3. Wi-Fi and IFTTT Webhook Configuration
const char* password = "PASS";
String Event_Name = "fingerprint";
String Key = "Your_Webhooks_Key";
String resource = "/trigger/" + Event_Name + "/with/key/" + Key;
const char* server = "maker.ifttt.com";
Here:
- ssid and password: Wi-Fi network credentials for connecting ESP32 to the internet.
-
Event_Name and Key: Used to trigger the correct IFTTT Webhook event.
Event_Name
specifies the IFTTT event name, andKey
is the unique Webhook key.You can get yours from IFTTT website. -
resource: Builds the endpoint path for the IFTTT request, which is
/trigger/[Event_Name]/with/key/[Key]
. - server: Specifies IFTTT’s base server address.
NTPClient timeClient(ntpUDP, "pool.ntp.org", 19800, 60000); // 19800 sec offset for IST
-
WiFiUDP ntpUDP: Creates an instance of the UDP protocol used for NTP communications.
-
NTPClient timeClient(...): Initializes an NTP client using the created UDP instance. It connects to the "pool.ntp.org" server, uses a 19800 seconds offset to adjust for Indian Standard Time (IST), and checks the time every 60,000 milliseconds (60 seconds).
4. Global Variables and Buzzer Setup
String NAME;
String ID;
- BUZZER_PIN: Defines GPIO pin 15 for the buzzer.
- NAME: A string variable to store the name of the recognized user based on their fingerprint.
- ID: A string variable to store the ID corresponding to the recognized fingerprint. This allows tracking of which user’s attendance has been marked.
5. Setup Function
-
Serial.begin(115200) and Serial2.begin(57600): Initialize serial communication for ESP32’s main serial interface and secondary serial for the fingerprint sensor.
115200
and57600
are baud rates for data transfer speeds. - pinMode(BUZZER_PIN, OUTPUT): Configures the buzzer pin as an output to allow control.
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
-
display.begin(): Initializes the OLED display at I2C address
0x3C
. If the display fails to initialize, it prints an error and halts the system. - display.clearDisplay(): Clears the display to start with a blank screen.
connectWiFi();
- Calls connectWiFi() to connect ESP32 to the specified Wi-Fi network.
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Fingerprint sensor not found :(");
while (1) { delay(1); }
}
- finger.verifyPassword() checks if the ESP32 can communicate with the fingerprint sensor. If unsuccessful, it halts execution.
finger.getTemplateCount();
Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
- finger.getTemplateCount(): Retrieves and prints the number of fingerprint templates stored in the sensor’s memory.
6. Main Loop - Attendance Verification Process
void loop() {
timeClient.update(); // Update the time
String formattedTime = timeClient.getFormattedTime();
int id = getFingerprintIDez();
if (finger.confidence >= 60) {
Serial.print("Attendance Marked for "); Serial.println(NAME);
displayAttendance(NAME.c_str());
makeIFTTTRequest();
digitalWrite(BUZZER_PIN, HIGH); // Activate buzzer
delay(500); // Buzzer duration
digitalWrite(BUZZER_PIN, LOW); // Deactivate buzzer
}
}
delay(1000);
}
- Continuously checks for fingerprints.
- If a fingerprint is recognized, it marks attendance by printing the name and activating a buzzer.
- Calls the function to send the attendance data to IFTTT.
7. Fingerprint Scanning Functions
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;
p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK) {
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;
}
return -1;
}
- getImage(): Captures an image of the fingerprint.
- image2Tz(): Converts the image to a template.
- fingerFastSearch(): Searches for a match among stored fingerprints and returns the ID if found.