NFC-Based Access Control System

Restricted and Secure Door Entry Solutions Using Raspberry Pi Pico W

Category: IoT, Embedded Systems, Secure Access Control
Tools & Technologies: Raspberry Pi Pico W, NFC PN532 Module (I2C mode), LCD1602 Display (I2C mode), Firebase Real-Time Database, CircuitPython, Adafruit CircuitPython Libraries, NFC Tool Mobile Application, Thonny (IDE), Fritzing (for circuit diagram), Python (programming language)

Status: Completed


Introduction

In a world where security is paramount, I developed an NFC-Based Access Control System that provides secure and flexible door entry solutions. This system leverages Near Field Communication (NFC) technology, combined with cloud-based data storage via Firebase, to offer a reliable and scalable solution for restricted access control. It is designed to handle varying scenarios with NFC tags/cards, ensuring efficient user authentication and enhanced security.

System Overview System Overview System Overview


Aim and Objectives

Aim:
To design and implement a scalable NFC-based door access control system that ensures secure and flexible user authentication.

Objectives:
The objectives of the project are outlined below:

  • Authenticate users via NFC tags/cards and match hash keys with Firebase Real-Time Database.
  • Display user-specific messages on an LCD for successful or denied access.
  • Provide a scalable and secure solution adaptable for small- or large-scale applications.
  • Integrate real-time database functionality for efficient user data management.

Features & Deliverables

  • Secure Authentication: Hash key verification with Firebase for authorized users.
  • Detailed Feedback: LCD display provides user-specific messages for access granted, denied, or card errors.
  • Multi-Scenario Handling: Supports writable and non-writable cards with distinct feedback for each case.
  • Compact Design: Custom-cut acrylic casing and cable ties ensure durability and portability.
  • Real-Time Database Integration: Firebase stores user information, including full names and hash keys.
  • Customizable Mobile Application: NFC Tool app writes hash keys into tags/cards.

List of Libraries Used

  • Adafruit CircuitPython PN532: (from adafruit_pn532.i2c import PN532_I2C) For NFC communication.
  • Adafruit Bus Device & Adafruit CircuitPython LCD: (from lcd.lcd import LCD) & (from lcd.i2c_pcf8574_interface import I2CPCF8574Interface) For controlling the 1602 LCD in I2C mode.
  • Adafruit CircuitPython Firebase and WiFi/Internet Connectivity: (import adafruit_requests), (import wifi), (import socketpool), & (import ssl) For real-time Firebase database operations.
  • Servo Motor PWM: (import pwmio) For controlling the servo motor for door opening/closing.
  • GPIO Pins: (import digitalio) For controlling the Raspberry Pi's input and output pins.
  • Time: (import time) For delay handling and time-based operations.
  • Adafruit CircuitPython Board: (import board), (import busio), & (import binascii) For delay handling and time-based operations.
  • These libraries were essential for seamless integration and functionality across all system components.
    You can explore the library files to view and download them directly. Alternatively, you can check out the complete collection of CircuitPython libraries in the Adafruit CircuitPython Bundle.


Pinout Diagram & GPIO Pin Usage

Below is the pinout diagram of the Raspberry Pi Pico W. Please refer to this when recreating or developing, along with the GPIO pins used in the project.

Pinout Diagram: Raspberry-Pi-Pico-W-Pinout

GPIO Pins Used:

GPIO Pin Component Description
GPIO 2 Green LED (Registered Indicator) Indicates access granted.
GPIO 3 Red LED (Unregistered Indicator) Indicates access denied.
GPIO 6 Blue LED (WIFI Indicator) Indicates Wi-Fi connection.
GPIO 15 Servo Motor PWM Controls door opening and closing.
GPIO 22 Buzzer Beeps once for access denied and only once to alert us when the Raspberry Pi is connected to Wi-Fi.
GPIO 4 PN532 NFC Module SDA, &
LCD1602 SDA
I2C communication for LCD & NFC.
GPIO 5 PN532 NFC Module SCL, &
LCD1602 SCL
I2C communication for LCD & NFC.

This layout highlights the organized and optimized usage of the GPIO pins for seamless functionality.


Process / Methodology

Hardware Implementation

Components Used: Raspberry Pi Pico W, NFC PN532 Module, LCD1602, Li-Ion 18650 batteries, boost converter, charging module, LED indicators, and buzzer.

  • Assembled on a veroboard with cable ties for stability and neatness.
  • Integrated a power management system with a display for battery status and Type-C charging support.

Hardware Assembly LEDs, PN532, & Servo LED_NFC-PN532_Servo Veroboard, Power, Indicator, Buzzer, DIL Female Connector, & RaspberryPiPicoW LED_NFC-PN532_Servo Power Supply Section Hardware Assembly System Internal View Hardware Assembly Complete System's Internal View Hardware Assembly Casing Hand Sketch Design Hardware Assembly LCD1602 Dimension Hardware Assembly Acrylic Dimensioning for Cutting Hardware Assembly Acrylic Coupled Hardware Assembly Acrylic Coupled, & Tags Hardware Assembly System Internal View Assembled with Acrylic Casing Hardware Assembly Hardware Assembly System Overview System Overview

Software Development

  • Programmed in CircuitPython with Adafruit CircuitPython libraries for NFC and LCD control using Thonny IDE.
  • Connected the system to Firebase for hash key verification.
  • Configured unique card responses based on writable/non-writable status and database records.

Software Workflow Thonny IDE Software Workflow
Firebase Real-Time Database Software Workflow

Testing Scenarios

Tested with six (6) NFC cards and one (1) NFC key to validate different authentication outcomes. Simulated large-scale integration scenarios with scalable database entries and servo motors.


Testing & Responses

  • Authorized Cards (Card A & B): Matches hash keys in the database, displays "Welcome" and full name, opens the servo door for 4 seconds, then closes.
  • Unauthorized Cards (Card D & E): Displays "Access Denied" followed by "Record Mismatch" and "in our database."
  • Empty Card (Card C): Displays "Access Denied," followed by "No Data in Card" and "Please Register."
  • Non-Writable Card (Card F & Key): Displays "Access Denied" followed by "NFC Card Error" and "Not Writable."

Testing Outcomes user found, Registered LED ON, door (servo) is about to open Testing Outcomes Door (servo) opened. [NB: the door closes after 4 secs] Testing Outcomes

user found, Registered LED ON, door (servo) is about to open Testing Outcomes Door (servo) opened. [NB: the door closes after 4 secs] Testing Outcomes

Access Denied, Unregistered LED ON, door (servo) remains Closed Testing Outcomes No Data in Card Testing Outcomes

Access Denied, Unregistered LED ON, door (servo) remains Closed Testing Outcomes Record Mismatch in Our Database Testing Outcomes

Access Denied, Unregistered LED ON, door (servo) remains Closed Testing Outcomes Record Mismatch in Our Database Testing Outcomes

Access Denied, Unregistered LED ON, door (servo) remains Closed Testing Outcomes NFC Card Error! Card is not Writable Testing Outcomes

Access Denied, Unregistered LED ON, door (servo) remains Closed Testing Outcomes NFC Card Error! Card is not Writable Testing Outcomes


Challenges & Solutions

  • Challenge: Ensuring secure and reliable NFC communication.
    Solution: Used NFC PN532 in I2C mode for stable data transmission and implemented hash key encryption.
  • Challenge: Maintaining power efficiency for portability.
    Solution: Integrated a Li-Ion battery system with a boost converter and a charging module with display.
  • Challenge: Multi-scenario testing with diverse cards.
    Solution: Programmed detailed feedback messages and validated all scenarios extensively.

Challenges & Solution Challenge: Incorrect Password Entry Final Results Solution: Correct Password Entry Final Results


Results & Impact

  • Access Control Efficiency: Successfully authenticated and managed multiple NFC cards with precise outcomes.
  • User-Friendly Design: Compact casing, clear feedback on LCD, and intuitive mobile app for writing hash keys.
  • Scalability: Demonstrated adaptability for large-scale integration with additional cards and servo motors.
  • Energy Management: Optimized battery usage with clear power status indication.

Final Results NFC Tool MobileApp writes hash keys into tags/cards Andriod_NFC_tool Thonny IDE's Shell Result for Opened Door (it wait for 4 secs before it get closed) Final Results Thonny IDE's Shell Result for Closed Door Final Results Firebase Real-Time Database Integration firebase interface

(Note: Visual representations of the door in both open and closed states, along with the corresponding data displayed on the screen, are available in the Testing and Responses section)


What I Learned

  • Practical application of NFC technology in secure access systems.
  • Integration of cloud-based databases for real-time data management.
  • Advanced CircuitPython programming for IoT applications.
  • Designing and assembling compact, user-friendly embedded systems.

Demonstation / Access

Circuit Diagram Circuit Diagram

Code Snippet code snippet


Future Enhancements

  • Add Bluetooth or Wi-Fi-based mobile app for real-time card management.
  • Expand to multi-door access control for corporate environments.
  • Enhance database analytics with user activity logs and notifications.
  • Integrate biometric authentication for multi-factor security.

My Design and Myself 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.