DESIGN AND IMPLEMENTATION OF AN IoT-BASED FINGERPRINT ATTENDANCE SYSTEM FOR EDUCATIONAL INSTITUTIONS

Secure, Real-Time Biometric Attendance Tracking with Encrypted Data Upload to Firebase for Educational Settings

Category: IoT, Embedded Systems, Biometric Systems, Secure Data Management
Tools & Technologies: ESP32 Development Board, AS608 Fingerprint Sensor, LiquidCrystal_I2C LCD (16x2), Push Buttons, LEDs, Buzzer, Veroboard, Jumper Wires, Resistors, Firebase Realtime Database, Arduino IDE, Python, Pyrebase4, Pycryptodome, Pandas, Tabulate, Openpyxl, AES Encryption, NTP Server, WiFi Module (ESP32), EEPROM

Status: Completed


Introduction

Addressing the inefficiencies of manual attendance systems in educational institutions, this project delivers an IoT-based fingerprint attendance system using the ESP32 microcontroller and AS608 fingerprint sensor. Integrated with Firebase Realtime Database, it ensures secure, real-time attendance tracking with AES-encrypted data uploads. A 16x2 LCD, push buttons, LEDs, and a buzzer provide an intuitive user interface, while WiFi connectivity enables cloud synchronization. The system supports fingerprint enrollment, deletion, and attendance marking (sign-in/sign-out) for up to 127 users, with data persisted in EEPROM. A Python script processes encrypted attendance records, generating CSV, HTML, and Excel reports. This solution enhances accuracy, security, and efficiency in attendance management, transitioning from paper-based methods to a robust biometric system. The project also aligns with secure real-time biometric data upload principles, emphasizing data integrity and privacy.

System Overview System Overview
Detailed Overview Detailed Overview


Aim and Objectives

Aim:
To design and implement an IoT-based fingerprint attendance system for educational institutions, enabling secure, real-time biometric data collection and management.

Objectives:
The objectives of the project are outlined below:

  1. Develop a fingerprint-based authentication system for accurate attendance tracking.
  2. Implement AES encryption for secure data transmission to Firebase Realtime Database.
  3. Provide a user-friendly interface using LCD and push buttons for enrollment and attendance operations.
  4. Enable real-time synchronization with Firebase for attendance data storage and retrieval.
  5. Persist user states (sign-in status, class, present time) in EEPROM for reliability.
  6. Process encrypted attendance data using Python to generate comprehensive reports (CSV, HTML, and Excel).
  7. Validate system performance in educational settings with multiple users.

Features & Deliverables

  • Fingerprint Authentication: Uses AS608 sensor for secure, contactless attendance marking (sign-in/sign-out).
  • Secure Data Handling: Implements AES-128 encryption with PKCS#7 padding for attendance data before Firebase upload.
  • Real-Time Cloud Integration: Stores attendance records in Firebase Realtime Database, synchronized via ESP32’s WiFi.
  • User Interface: Features a 16x2 LCD for status display, push buttons for navigation, LEDs for visual feedback, and a buzzer for audible alerts.
  • Data Persistence: Saves user states (sign-in status, class name, present time) in EEPROM for power-loss recovery.
  • Offline Support: Handles attendance operations locally when WiFi is unavailable, with EEPROM storage.
  • Backend Processing: Python script decrypts Firebase data, generating CSV files per class/date, plus HTML and Excel reports.
  • Time Synchronization: Uses NTP server for accurate timestamps in attendance records.

List of Libraries Used and Custom Code Implementations

  • ESP32 Libraries (C++):
    • Adafruit_Fingerprint: (#include <Adafruit_Fingerprint.h>) For interfacing with the AS608 fingerprint sensor.
    • FirebaseESP32: (#include <FirebaseESP32.h>) For Firebase Realtime Database connectivity.
    • LiquidCrystal_I2C: (#include <LiquidCrystal_I2C.h>) For controlling the 16x2 LCD display.
    • AESLib: (#include <AESLib.h>) For AES-128 encryption of attendance data.
    • base64: (#include <base64.h>) For encoding encrypted data to Base64.
    • EEPROM: (#include <EEPROM.h>) For storing user states persistently.
    • ArduinoJson: (#include <ArduinoJson.h>) For JSON serialization of attendance data.
    • WiFi: (#include <WiFi.h>) For ESP32 WiFi connectivity.
    • Custom Code: Manages fingerprint enrollment/deletion, attendance marking, AES encryption, and Firebase data structuring.
  • Python Libraries:
    • Pyrebase4: For accessing Firebase Realtime Database.
    • Pycryptodome: For AES decryption of attendance data.
    • Pandas: For data manipulation and CSV generation.
    • Tabulate: For console-based table display.
    • Openpyxl: For formatted Excel report generation.
    • Custom Script: Decrypts Firebase data, processes attendance records, and generates CSV, HTML, and Excel reports.
View ESP32 Main Code (main.ino)
                
// Excerpt from main.ino
void markAttendance(int fingerprintID) {
    id = fingerprintID;
    classNum = 0;
    lcd.clear();
    lcd.print("Enter Class 0-9:");
    lcd.setCursor(0, 1);
    lcd.print(classNum);
    bool classSelected = false;

    while (!classSelected) {
        if (digitalRead(forward) == 0) {
            digitalWrite(buzzer, HIGH);
            delay(100);
            digitalWrite(buzzer, LOW);
            classNum++;
            if (classNum > 9) classNum = 0;
            lcd.setCursor(0, 1);
            lcd.print("   ");
            lcd.setCursor(0, 1);
            lcd.print(classNum);
            delay(150);
        } else if (digitalRead(ok) == 0) {
            digitalWrite(buzzer, HIGH);
            delay(100);
            digitalWrite(buzzer, LOW);
            classSelected = true;
            delay(150);
        }
    }

    if (WiFi.status() == WL_CONNECTED && !fullDateTime.startsWith("0000")) {
        reconnectWiFi();
        String className = "EIE52" + String(classNum);
        userState[id] = std::make_tuple(true, className, currentTime);
        String matricNo = getMatricNo(id);
        String encrypted = encryptData(id, matricNo, className, currentDate, 1, currentTime, "");
        String path = "/attendance_records/" + className + "/" + currentDate + "/id_" + String(id);
        if (Firebase.ready()) {
            bool success = Firebase.setString(fbdo, path, encrypted);
            Serial.printf("Sending Attendance Data... %s\n", success ? "Success" : fbdo.errorReason().c_str());
        }
    }
}
                
            
View Python Processing Script (process_attendance_decryption.py)
                
# Excerpt from process_attendance_decryption.py
def decrypt_data(encrypted_b64, class_name, date, identifier):
    try:
        encrypted_data = base64.b64decode(encrypted_b64)
        cipher = AES.new(AES_KEY, AES.MODE_CBC, AES_IV)
        padded_data = cipher.decrypt(encrypted_data)
        plaintext = unpad(padded_data, AES.block_size)
        json_data = json.loads(plaintext.decode('utf-8'))
        print(f"Decrypted data for {class_name}/{date}/{identifier}: {json_data}")
        return json_data
    except Exception as e:
        print(f"Decryption error for {class_name}/{date}/{identifier}: {e}")
        return None

def fetch_and_process_attendance():
    attendance_records = db.child("attendance_records").get().val()
    for class_name in attendance_records:
        class_data = attendance_records[class_name]
        for date in class_data:
            date_data = class_data[date]
            csv_data = []
            if isinstance(date_data, dict):
                for id_key, record in date_data.items():
                    if id_key.startswith("id_"):
                        id_num = id_key.replace("id_", "")
                    else:
                        id_num = id_key
                    if isinstance(record, str):
                        encrypted_b64 = record
                        decrypted = decrypt_data(encrypted_b64, class_name, date, id_key)
                        if decrypted:
                            csv_data.append({
                                "id": decrypted["id"],
                                "matric_number": decrypted["matric_number"],
                                "course": decrypted["course"],
                                "date": decrypted["date"],
                                "present": decrypted["present"],
                                "present_time": decrypted["present_time"],
                                "absent_time": decrypted["absent_time"] if decrypted["absent_time"] else ""
                            })
            if csv_data:
                df = pd.DataFrame(csv_data)
                output_dir = f"attendance/{class_name}"
                os.makedirs(output_dir, exist_ok=True);
                csv_path = f"{output_dir}/{date}.csv"
                df.to_csv(csv_path, index=False)
                print(f"Generated CSV: {csv_path}")
                
            

Pinout Diagram & GPIO Pin Usage

The following is the pinout diagram for the ESP32 Development Board used in this project, along with the GPIO pins utilized.

Pinout Diagram: ESP32 Pinout

GPIO Pins Used:

GPIO Pin Component Description
GPIO 15 WiFi LED Indicates WiFi connectivity status.
GPIO 2 Validate LED Signals successful fingerprint recognition.
GPIO 4 Enroll LED Indicates enrollment mode activation.
GPIO 32 Buzzer Provides audible feedback for operations.
GPIO 13 Register Button Initiates fingerprint enrollment.
GPIO 27 Back Button Navigates back in menu.
GPIO 25 Delete Button Initiates fingerprint deletion.
GPIO 14 OK Button Confirms selections.
GPIO 12 Forward Button Increments ID/class selection.
GPIO 26 Reverse Button Decrements ID/class selection.
GPIO 16 (RXD2) Fingerprint Sensor RX Receives data from AS608 sensor.
GPIO 17 (TXD2) Fingerprint Sensor TX Transmits data to AS608 sensor.
GPIO 21 (SDA) LCD I2C SDA Serial data for LCD.
GPIO 22 (SCL) LCD I2C SCL Serial clock for LCD.

This pin configuration optimizes ESP32’s capabilities for real-time biometric operations.


Process / Methodology

Hardware Implementation

Components Used: ESP32 Development Board, AS608 Fingerprint Sensor, LiquidCrystal_I2C, Push Buttons, LEDs, Buzzer, Veroboard, Jumper Wires, Resistors.

Functions of the Components Used:
  • ESP32 Development Board: Central microcontroller for fingerprint processing, WiFi connectivity, and Firebase communication.
  • AS608 Fingerprint Sensor: Captures and authenticates fingerprint data for up to 127 users.
  • LiquidCrystal_I2C: Displays system status, user IDs, and operation prompts.
  • Push Buttons: Facilitate user inputs for enrollment, deletion, and navigation (Register, Back, Delete, OK, Forward, Reverse).
  • LEDs: Provide visual feedback for WiFi status, validation, and enrollment modes.
  • Buzzer: Emits audible alerts for user actions and system events.
  • Veroboard and Jumper Wires: Ensure secure and organized circuit connections.
  • Resistors: Regulate current for LEDs and button inputs.
Integration Process:
  • The AS608 Fingerprint Sensor was interfaced with the ESP32’s UART (Serial2) for reliable biometric data transfer.
  • The LCD was connected via I2C to minimize pin usage while displaying real-time information.
  • Push buttons were wired with pull-up resistors to ensure stable input signals for navigation and operation selection.
  • LEDs and the buzzer were connected to GPIO pins to provide immediate visual feedback and auditory feedback for the user actions.
  • The system was assembled on a veroboard with jumper wires for durability and secure connections.

Hardware Assembly Casing Fabrication Casing Fabrication
Batteries, Veroboard, Charging Module, and ESP32 Development Board Veroboard LCD and Buttons
Veroboard Soldered, Buzzer, DIL Connector, LEDs, LCD1602, Push Buttons, and Internal Circuitry containing AS608 Fingerprint Sensor, and Switch Veroboard LCD and Buttons
Front View of the Hardware Development (Complete Assembly) front view of the development

Software Implementation

  • Programmed the ESP32 in C++ using Arduino IDE, integrating libraries for fingerprint scanning, LCD display, and Firebase connectivity.
  • Developed algorithms for fingerprint enrollment, deletion, and attendance marking, with AES encryption for data security.
  • Implemented WiFi reconnection logic and NTP time synchronization for accurate timestamps.
  • Used EEPROM to store user states (sign-in status, class name, present time) for offline operation.
  • Developed a Python script to decrypt attendance data from Firebase and generate CSV, HTML, and Excel reports.

Software Workflow

  • Initialize system → connect to WiFi → sync time with NTP server.
  • Scan fingerprint → authenticate against stored templates → select class (EIE520–EIE529).
  • Mark attendance (sign-in or sign-out) → encrypt data → upload to Firebase under /attendance_records/<class_name>/<date>/<id>.
  • Persist state in EEPROM for reliability.
  • Python script retrieves encrypted data, decrypts it, and generates reports (CSV, HTML, Excel).

Software Workflow Diagram Software Workflow


Challenges & Solutions

  • Challenge: Fingerprint sensor misreads due to poor finger placement.
    Solution: Implemented LCD prompts for proper finger positioning and multiple scan attempts.
  • Challenge: WiFi disconnections disrupting Firebase uploads.
    Solution: Added a WiFi reconnection mechanism with timeout and LED indicator for network status.
  • Challenge: Ensuring data integrity during power loss.
    Solution: Used EEPROM to store user states, enabling system recovery.
  • Challenge: Handling variable-length data in AES encryption.
    Solution: Applied PKCS# padding to standardize data length for encryption.
  • Challenge: Processing mixed data structures in Firebase (list vs. dict).
    Solution: Python script handles both formats, ensuring compatibility with old and new data.

Results & Security

  • Accurate Authentication: Successfully authenticated up to 127 fingerprints for attendance marking.
  • Secure Data: AES-encrypted data ensured privacy during Firebase uploads.
  • Real-Time Tracking: Attendance records synced to Firebase in real-time, accessible via Python-generated reports.
  • User-Friendly: LCD, buttons, LEDs, and buzzer provided clear feedback for students and operators.
  • Offline Support: EEPROM storage enabled reliable operation during network outages.
  • Comprehensive Reporting: Generated CSV files per class/date, with styled HTML and Excel summaries.

Firebase Database Structure

/attendance_records/
  /EIE520/
    /2025-05-01/
      id_001: "base64_encrypted_data"
      id_002: "base64_encrypted_data"
    /2025-05-02/
      id_001: "base64_encrypted_data"
  /EIE521/
    /2025-05-01/
      id_003: "base64_encrypted_data"
/registered_student_records/
  /1/
    fingerprint_id: 1
    matric_number: "17CK022738"
    timestamp: "2025-05-25 10:00:00"
  /2/
    fingerprint_id: 2
    matric_number: "17CK022739"
    timestamp: "2025-05-25 10:07:43"   
                

Pictorial Results Startup Display Startup Display
WiFi Connecting WiFi Connecting
Fingerprint Scan Prompt to Mark Attendance Fingerprint Scan Prompt
Attendance Marked Attendance Marked
Enrollment Interface Enrollment Interface
Enrollment Interface Enrollment Interface
Enrollment Interface Enrollment Interface
Excel Report Sample Excel Report Sample
HTML Report Sample Excel Report Sample
Firebase Data View Firebase Data View
Firebase Data View (registered students) Firebase Data View
Firebase Data View (registered students) Firebase Data View
Firebase Data View (attendance records) Firebase Data View
Firebase Data View (attendance records) Firebase Data View


What I Learned

  • Biometric System Integration: Gained expertise in interfacing fingerprint sensors with microcontrollers for authentication.
  • Secure Data Handling: Mastered AES encryption and Base64 encoding for secure data transmission.
  • IoT and Cloud: Learned real-time data management with Firebase and WiFi-enabled devices.
  • Embedded Systems: Enhanced skills in hardware-software integration, including GPIO and I2C.
  • Data Processing: Developed Python scripts for data analysis and reporting, handling encrypted data.

Demonstration & Access

Circuit Diagram Circuit Diagram

Code Snippet Code Snippet


Future Enhancements

  1. Add mobile app support for remote attendance monitoring and student management.
  2. Implement facial recognition for multi-modal biometric verification.
  3. Enhance encryption with AES-256 for increased security.
  4. Integrate battery backup with power management for portability.

My Design and Myself Happy Me, and the Device I Built 🥳 Project Showcase

Thank You for Visiting My Portfolio

I sincerely appreciate you taking the time to explore my portfolio and learn about my work and expertise. It is my hope that these projects and insights have demonstrated my passion for innovation, my technical skills, and my dedication to delivering impactful solutions.

If you have any questions, require further information, or wish to discuss potential collaborations, I would be delighted to connect. Please feel free to reach out via the Contact section. Your feedback and inquiries are highly valued and will be addressed promptly.

Thank you once again for your interest in my work. I look forward to the opportunity to collaborate and contribute meaningfully to your projects or organization. Together, let us innovate and achieve excellence.

Best regards,
Damilare Lekan Adekeye