DEVELOPMENT OF AN IoT-BASED RFID SHUTTLE PAYMENT AND MONITORING SYSTEM USING FIREBASE REALTIME DATABASE WITH ESP32

Real-Time Fare Collection, Balance Monitoring, and Secure Notification for Shuttle Services Using RFID Technology

Category: IoT, Embedded Systems, Shuttle Payment System, Smart Transportation Solutions
Tools & Technologies: ESP32 Development Board, RC522 RFID Reader, RFID Card Tags (13.56MHz), 4x4 Matrix Keypad, LCD2004 with I2C Interface, LED Indicators, Buzzer with Driver Module, 18650 Li-Ion Batteries, Battery Holder, Type-C Charging Port, Charging Module, Boost Converter (XL6019), Connecting Wires, Jumper Wires, Veroboard, DIL Connectors, Soldering Lead, Heat Shrink Tubing, Switch, Resistors, Firebase Realtime Database for Cloud Storage and Notifications, Arduino IDE for Programming.

Status: Completed


Introduction

In response to the demand for secure, contactless payment in campus shuttle services, this project integrates RFID technology, an ESP32 microcontroller, and Firebase Realtime Database to provide instant fare processing, live balance tracking, and reliable user authentication. A 4×4 matrix keypad and I2C-driven LCD offer an intuitive local interface, complemented by Wi-Fi connectivity for cloud updates and email alerts. Built-in buzzer and LED indicators deliver clear transaction and system status feedback. This solution addresses the growing need for efficient payment systems in university shuttle networks and similar settings, leveraging RFID, real-time data management, and robust IoT connectivity. Designed with user convenience in mind, it transitions from traditional manual fare collection to smart transportation, effectively eradicating manual processes and significantly boosting operational efficiency.

System Overview System Overview Detailed Overview


Aim and Objectives

Aim:
To develop an IoT-based RFID shuttle payment and monitoring system that enables secure, real-time fare collection and balance management for university shuttle services.

Objectives:
The objectives of the project are outlined below:

  1. Implement RFID-based authentication for secure fare payment.
  2. Enable real-time balance updates and monitoring using Firebase Realtime Database.
  3. Provide user-friendly interfaces via LCD and keypad for seamless interaction.
  4. Use buzzer and LED indicators for immediate transaction feedback.
  5. Integrate email notifications for transaction confirmations.
  6. Validate the system's performance in real-world shuttle service scenarios.

Features & Deliverables

  • RFID-Based Payment: Secure fare collection using RFID card tags (13.56MHz) for contactless transactions.
  • Real-Time Balance Monitoring: Updates and displays user balance on an LCD2004 after each transaction.
  • Cloud Integration: Uses Firebase Realtime Database for storing and retrieving user data, ensuring real-time synchronization.
  • Notification System: Sends email notifications via Mailjet API to users after successful transactions.
  • User-Friendly Interface: Features a 4x4 matrix keypad for input and an LCD for displaying transaction details.
  • Portability: Powered by 18650 Li-Ion batteries, making the system portable for shuttle environments.

List of Libraries Used and Custom Code Implementations

  • FirebaseESP32 Library: (#include <FirebaseESP32.h>) For connecting and managing data with Firebase Realtime Database.
  • LiquidCrystal_I2C Library: (#include <LiquidCrystal_I2C.h>) For managing the I2C-based LCD2004 display.
  • MFRC522 Library: (#include <MFRC522.h>) For interfacing with the RC522 RFID reader to scan RFID cards.
  • Keypad Library: (#include <Keypad.h>) For handling inputs from the 4x4 matrix keypad.
  • SPI Library: (#include <SPI.h>) For communication between the ESP32 and RC522 RFID reader.
  • HTTPClient Library: (#include <HTTPClient.h>) For sending email notifications via the Mailjet API.
  • Custom Code for Transaction Processing: Handles payment logic, balance deduction, and Firebase updates after RFID card scanning.
  • Custom Code for Email Notifications: Implements base64 encoding and HTTP POST requests to send transaction details via email.

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 5 RC522 RFID (SS) Slave Select pin for RFID communication.
GPIO 0 RC522 RFID (RST) Reset pin for RFID module.
GPIO 27 Buzzer Outputs sound for transaction feedback.
GPIO 12 Red LED Indicates failed transactions or errors.
GPIO 4 Blue LED Indicates successful transactions.
GPIO 13 WiFi LED Shows WiFi connectivity status.
GPIO 32, 33, 25, 26 Keypad Rows Row pins for the 4x4 matrix keypad.
GPIO 17, 16, 2, 15 Keypad Columns Column pins for the 4x4 matrix keypad.
GPIO 21 (SDA) LCD I2C SDA Serial data for LCD2004
GPIO 22 (SCL) LCD I2C SCL Serial clock for LCD2004

This layout ensures efficient utilization of GPIO pins for seamless system operation.


Process / Methodology

Hardware Implementation

Components Used: ESP32 Development Board, RC522 RFID Reader, RFID Card Tags (13.56MHz), 4x4 Matrix Keypad, LCD2004 with I2C Interface, LED Indicators, Buzzer with Driver Module, 18650 Li-Ion Batteries, Battery Holder, Type-C Charging Port, Charging Module, Boost Converter (XL6019), Connecting Wires, Jumper Wires, Veroboard, DIL Connectors, Soldering Lead, Heat Shrink Tubing, Switch, Resistors.

Functions of the Components Used
  • ESP32 Development Board: Serves as the central microcontroller, managing RFID scanning, keypad input, LCD display, and Firebase communication.
  • RC522 RFID Reader: Scans RFID card tags for user authentication and payment initiation.
  • RFID Card Tags (13.56MHz): Stores unique identifiers (UID) for user authentication.
  • 4x4 Matrix Keypad: Allows users to input payment amounts and select modes (payment or card info).
  • LCD2004 with I2C Interface: Displays transaction details, balance, and system status.
  • LED Indicators: Provide visual feedback (blue for success, red for failure, WiFi status).
  • Buzzer with Driver Module: Provides audible feedback for card scans and transactions.
  • 18650 Li-Ion Batteries: Power the system, ensuring portability.
  • Battery Holder and Type-C Charging Port: Houses batteries and enables recharging.
  • Charging Module and Boost Converter (XL6019): Manages battery charging and stabilizes voltage for the system.
Integration Process
  • The RC522 RFID reader and keypad are interfaced with the ESP32 using designated GPIO pins for reliable data capture.
  • The LCD2004 is connected via I2C to display real-time transaction information and user prompts.
  • LED indicators and the buzzer are connected to provide visual and audible feedback during operations.
  • The 18650 batteries are housed in a holder, with a charging module and boost converter ensuring stable power supply.
  • The system is assembled on a veroboard, with DIL connectors and jumper wires ensuring secure connections, and heat shrink tubing for insulation.

Hardware Assembly Veroboard, LCD, and 4x4 Matrix Keypad Veroboad LCD and Matrix Keypad 18650 Li-Ion Batteries with Battery Holder, and RC522 RFID Reader with RFID Card Tags (13.56MHz) Veroboad LCD and Matrix Keypad The Complete Power Supply Section, and the Buzzer Veroboad LCD and Matrix Keypad

Software Implementation

  • Programmed using Arduino IDE with C/C++ for the ESP32.
  • Integrated Firebase Realtime Database for real-time data storage and retrieval of user balances and transaction details.
  • Developed algorithms for RFID card scanning, payment processing, and balance updates, with feedback displayed on the LCD.
  • Implemented email notifications using the Mailjet API to send transaction confirmations to users.

Software Workflow

  • Scan RFID tag → validate against Firebase user record.
  • Prompt for PIN on mismatch or low balance.
  • Deduct fare, update balance in Firebase Realtime Database.
  • Trigger email notification on low balance or unauthorized access via HTTPClient.
  • Log transaction details under user node in database.

Software Workflow Diagram Software Workflow Full Workflow


Challenges & Solutions

  • Challenge: Debounce & False Reads.
    Solution: Added software delays and hardware pull-ups to prevent spurious scans.
  • Challenge: Ensuring stable WiFi connectivity for Firebase updates.
    Solution: Implemented a WiFi reconnection mechanism and LED indicator to monitor connection status.
  • Challenge: Managing power consumption for prolonged operation.
    Solution: Utilized 18650 Li-Ion batteries with a charging module and boost converter for efficient power management.
  • Challenge: Securing Firebase database access.
    Solution: Configured Firebase with anonymous sign-in and set appropriate buffer sizes to prevent connection issues.
  • Challenge: Handling user input errors via the keypad.
    Solution: Added clear (C) and cancel (D) options on the keypad to reset or abort transactions.

Results & Impact

  • Secure Payments: Successfully processed contactless payments using RFID cards, with immediate balance updates in Firebase.
  • Real-Time Monitoring: Displayed user balance and transaction details on the LCD2004, with data synced to Firebase in real time.
  • Notification System: Sent email notifications to users after successful transactions, enhancing transparency.
  • User-Friendly Interface: Provided intuitive interaction via keypad and LCD, with clear feedback through LEDs and buzzer.
  • Portability and Reliability: Operated reliably in a shuttle environment, powered by rechargeable batteries for extended use.

Firebase Database Structure and Results Firebase Realtime Database Overview

/Driver
  Driver Email: "[email protected]"
  Driver Name: "Damilare Lekan Adekeye"
/Student
  /studentA
    Account Balance
      Current Balance: 1700
      Initial Balance: 1850
      Last Updated Vehicle Cost: 150
    Email: "[email protected]"
    HashKey: "MK-001"
    Matric Number: "20MK8329K4"
    Name: "Okoro Kelly Efedhoma"
    UID: "83 66 78 29"
  /studentB
    Account Balance
      Current Balance: 1550
      Initial Balance: 1700
      Last Updated Vehicle Cost: 150
    Email: "[email protected]"
    HashKey: "MK-002"
    Matric Number: "20MK798748"
    Name: "Okoro Kelly"
    UID: "C3 DE 52 0A"
  /studentC
    Account Balance
      Current Balance: 650
      Initial Balance: 800
      Last Updated Vehicle Cost: 150
    Email: "[email protected]"
    HashKey: "MK-003"
    Matric Number: "20MK098GH3"
    Name: "Damilare L. Adekeye"
    UID: "83 CD 6E 07"
  /studentD
    Account Balance
      Current Balance: 1710
      Initial Balance: 1850
      Last Updated Vehicle Cost: 140
    Email: "[email protected]"
    HashKey: "MK-004"
    Matric Number: "20MK098GH4"
    Name: "yemi"
    UID: "E3 79 DA 0A"
                

These Are The Pictorial Results For Payment Initiation
Start Up Display Start Up
Connection to WiFi Display Connection to WiFi
WiFi Connected Display WiFi Connected Interfact
Homepage Homepage
Input Price Section Card B Input Price
Scan to pay, After # Button is Pressed B Payment
Card Detected Card B Detected
Transaction in Progress Card B Txn in Progress
Payment Successful Section Card B Payment Successful
Email Sent Successfully Email Sent Successfully

The Next Pictorial Results Are For The Card Information Check
Check Card information by pressing A Check Card informationr
Scan card to fetch Information Scan card to fetch Information
Card Detected for Information Check Card Detected for Information Check
Card Information Delivered Card Information Delivered
Firebase Result Result Firebase
Result Email Screenshot for Deewansonic Engineering Result Deewansonic Engr.
Result Email Screenshot for Damilare L. Adekeye Result Damilare L. Adekeye
Result Email Screenshot for Yemi Result Yemi
Result Email Screenshot for Okoro Result Okoro
Mailjet Mailjet
Mailjet Dashboard Showing the Number of Email Sent Mailjet Dashboard

Note: More test result cases for Unregistered cards, and a more detailed visual representation, including a comprehensive video demonstrating the testing process for all Cards, is available here.


What I Learned

  • Integration of RFID technology with IoT for secure payment systems.
  • Real-time data management using Firebase Realtime Database.
  • Practical hardware-software integration for embedded systems.
  • Implementation of email notifications using external APIs.

Demonstration & Access

Circuit Diagram Circuit Diagram

Code Snippet Code Snippet


Future Enhancements

  1. Add support for mobile app integration for balance top-up and transaction history.
  2. Implement advanced fraud detection mechanisms using machine learning.
  3. Enhance power efficiency with solar charging capabilities.

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