Smart Lockers
Project Summary
In light of rapid technological developments, smart systems have become an essential part of various fields. Technologies such as the Internet of Things (IoT), Artificial Intelligence (AI), and wireless communication have contributed to enhancing security and efficiency in numerous applications. Among these technologies, Radio Frequency Identification (RFID) systems stand out, offering advanced solutions for data management and identity verification with ease and accuracy. Furthermore, wireless communication using modules like the NRF24L01 contributes to fast and secure data transfer between different devices, facilitating the development of integrated systems that operate efficiently and reliably.
In this context, the project aims to secure boxes using a smart system based on RFID technologies and wireless communication. Identity data is read for each box via RFID readers connected to an Arduino. This data is then transmitted via an NRF24L01 module to a main unit based on a Raspberry Pi to process the information and verify access rights. This allows for the implementation of security measures such as unlocking, sending alerts, and logging opening and closing times.
The system consists of a sub-unit comprising three boxes and three RC522 RFID readers connected to an Arduino UNO, along with an NRF24L01 transmitter module, a UPS power unit, and connecting wires. Meanwhile, the main unit consists of a Raspberry Pi 4 device and an NRF24L01 module. The system operates by registering student data in a database and sending identifiers to the sub-unit to assign each box to a specific student according to their unique identifier.
Introduction
The system consists of an integrated group of electronic units working in harmony to achieve a specific function. At the heart of this system is an ATmega328P microcontroller operating at 5 volts, which is responsible for controlling data flow and interacting with other components. The system also includes a powerful central processing unit based on an ARM processor operating at 3.3 volts, which handles central processing tasks and stores data in an SQLite3 database.
To interact with the physical world, RFID readers are used to read smart card IDs. These readers rely on standard communication protocols such as SPI or I2C to communicate with the microcontroller. To enable wireless communication and data transfer between different units, NRF24L01 modules operating at a frequency of 2.4GHz are used.
Due to the difference in operating voltages between some components (5 volts and 3.3 volts), voltage level converters are used to ensure electrical compatibility. The electrical voltage required to operate the components is regulated and stabilized using voltage regulators and various capacitors to ensure stable operation and reduce noise. Finally, the system is supplied with power through an external power supply, along with a UPS system to ensure continued operation during power outages. Circuit breakers and electrical filters are also used to protect the system from any overloads or electrical disturbances.
In general, this system represents an integrated architecture combining microcontroller control, central processing, wireless communication, and interaction with smart cards to achieve a comprehensive function.
Connecting the MRFC522 Reader
Connecting the MRFC522 Reader
[Labels on Image: Arduino Uno | Card Reader]
The Reader:
- The (Orange) line: Unit or device selection line.
- The (Blue) line: Clock line.
- The (Green) line: sck line.
- The (Purple) line: mosi line for transferring data from the reader to the Arduino.
- The (Black) line: Grounding line.
- The (Pink) line: reset line to reactivate the reader when needed.
- The (Red) line: Power line (5v).
The Capacitor 10uF:
- The (Red) line: Power line (5v).
- The (Black) line: Grounding line.
Connecting Arduino With NRF24L01
Connecting Arduino with NRF24L01
[Labels on Diagram: Arduino Uno | Transmission Unit]
NRF24L01:
- The (red) line: Power line with port (5v).
- The (Blue) line: sck line with port 13.
- The (Black) line: Grounding line with gnd port.
- The (White) line: ce line with port 7.
- The (Green) line: csn line with port 8.
- The (Yellow) line: miso line with port 12.
- The (Pink) line: mosi line with port 11.
The Capacitor 10uF:
- The (Red) line: Power line (5v).
- The (Black) line: Grounding line.
Wires
Using Twisted Pair Cat 6 cable wires to connect SPI protocol terminals, especially to extend distance or provide greater durability for connections, as the twisted wire design helps reduce electromagnetic interference.
- The orange color: Used to connect the sda line in the reader and the power line in the NRF24L01.
- The orange-white color: To connect the reset line in the reader, and for the grounding line in the NRF24L01.
- The blue-white color: To connect the miso line in the reader as well as in the NRF24L01.
- The green-white color: To connect the mosi line in the reader as well as in the NRF24L01.
- The green color: To connect the sck line in the reader as well as in the NRF24L01.
- The brown color: To connect the power line for all readers.
- The blue color: For each reader, a wire to connect the port giving the command to the lock from the Arduino.
- The brown-white color: To connect grounding for all readers.
Connecting Raspberry With NRF24L01
[Labels on Diagram: Raspberry Device | Transmission Unit]
- The (Red) line: Common power source line with the Raspberry, the transmission unit, and the capacitor.
- The (Black) line: Common grounding line with the Raspberry, the transmission unit, and the capacitor.
- The (Yellow) line: ce line connected with port gpio25.
- The (Orange) line: csn line connected with port gpio8.
- The (Green) line: mosi line connected with port gpio10.
- The (Blue) line: miso line connected with port gpio9.
- The (Pink) line: sck line connected with port gpio11.
Configuring the Reader With Arduino
Reader Initialization
These tools are used to solder wires and components with the Arduino as well as the Raspberry. After the connection process to the Arduino, the stage of uploading the code to the Arduino begins using the Arduino IDE program.
- Soldering iron
- Flux (soldering aid material)
- Connecting wires
- Pliers or Tweezers
- Solder wire
Configuring the Reader with Arduino
Using Arduino IDE software to upload the code to the Arduino.
[Code Comments Translation]:
- Line 1: Include SPI library to communicate with the reader.
- Line 2: Include MFRC522 library specific to the RFID reader.
- Line 3: Define the port number connected to SS on the reader.
- Line 4: Define the port number connected to RST on the reader.
- Line 5: Create a reader object using the defined ports.
- Line 7: Start serial communication at 9600 baud rate.
- Line 8: Initialize SPI protocol.
- Line 9: Initialize RFID reader.
Reader Initialization
The code initializes the RFID reader using the MFRC522 library via the SPI protocol. It includes defining the SS and RST ports to establish a connection with the reader. In the setup function, serial communication is initialized, SPI is configured, and the reader is initialized. There is no execution inside the loop
Initializing NRF24L01 Transmission Unit
Initializing NRF24L01 Transmission Unit
Transmission unit code (Initialization Model)
[Code Comments Translation]:
- Line 1: Include SPI library to communicate with the transmission unit.
- Line 2: Include nRF24L01 library to define the wireless unit.
- Line 3: Include RF24 library to control the unit.
- Line 4: Define the port number connected to CE in the unit.
- Line 5: Define the port number connected to CSN in the unit.
- Line 6: Create a unit object using the defined ports.
- Line 8: Start serial communication at 9600 baud rate.
- Line 9: Initialize SPI protocol.
- Line 10: Initialize the transmission unit.
- Line 11: Set the transmission channel address.
- Line 12: Set transmission power level.
- Line 13: Set data transfer rate.
- Line 14: Set the unit to transmission mode (stop listening).
Initializing NRF24L01 transmission unit
The code initializes the NRF24L01 frequency band unit (RF module) to work with Arduino via the SPI protocol.
It includes several steps involving the inclusion of SPI and RF24 libraries necessary to communicate with the transmission unit.
Defining the ports specific to the connection with the unit, setting up serial communication at a speed of 9600 baud, and initializing the SPI protocol to enable communication with the RF module.
Opening a transmission channel with a specific address set to ensure data is sent correctly, adjusting power settings and transfer speed to a low level, and setting the unit to transmission mode only without listening.
Arduino Commands
The most important commands used in the project to interact with the hardware.
- EEPROM.get(COUNT_ADDR, count);
- This function reads the data stored in the specific location in EEPROM and stores it in the variable count in the program.
- radio.write(SEND DATA);
- The function sends the stored data to another device via the NRF24L01 using the specified address, and the data size is as defined. The reading function is radio.read().
- radio.stopListening();
- radio.startListening();
- NRF24L01 commands to open listening and close listening. radio.startListening prepares the device to receive data from another device. radio.stopListening stops listening to enable transmission.
- Serial.println("error!");
- Displays the text "error!" in the serial monitor with a new line added after printing.
- mfrc522.PICC_ReadCardSerial();
- If a new card is found, this function reads the serial number (UID) of the card.
Summary Paragraph:
The hardware used in the project and its connection with software commands involves dealing with a group of various electronic components that cooperate together to achieve the determined tasks. These components include the RFID reader, the NRF24L01 transmission unit, and the EEPROM unit, in addition to the Arduino itself.
System Interfaces : Login Interface (Raspberry)
System Interfaces
Login Interface (Raspberry)
The login interface is simple and straightforward, as it requires the user to enter a username and password. Upon successful verification, the user is redirected to the main application, and if the data is incorrect, an alert appears to the user.
Main Interface (Raspberry)
Main Interface (Raspberry)
The main interface of the application includes a window containing several elements that help the user manage data related to the security system. When opening the application, a window appears containing a data table displaying information related to individuals such as RFID, Name, Gender, Stage, Box Number, Locker ID, Status, and Time. The tkinter library is used to create the graphical interface.
In the upper part of the window, there is a vertical and horizontal scroll bar to enable scrolling in the table when there is a lot of data. Below the table, there is a set of inputs such as RFID, Name, Gender, Stage, Box Number, Locker ID, and Status, which the user can modify to add or update records.
There are several buttons below the data inputs, such as Display Data, Advanced Search, Add Record, Edit Records, Delete Records, and Export Data to an Excel file. When any of these buttons are selected, the corresponding functions are executed, such as displaying data in the table or opening an advanced search window.
The interface contains a mechanism for adding, modifying, and deleting records from the database using SQLite, with alert messages displayed to the user upon the success or failure of operations. The interface was designed to be easy to use and allow for effective data management within a graphical environment.
Main Interface (Web)
The interface relates to a security system using RFID technology, where the user is enabled to add, modify, delete, and search for user data such as RFID, Name, Gender, Academic Stage, Box Number, and Lock Number. Data is stored in an SQLite database using Python and Flask.
Basic Functions:
- Add new user: Via a pop-up window.
- Edit Data: Via a page to modify user details.
- Delete Users: Via a delete button next to every user.
- Search: Using RFID.
The interface uses Bootstrap to make it responsive and beautiful, and displays alert messages upon success or errors.
Box Reservation Interface
In the student card recognition processes, a specific box must be assigned to the student, and thus the system does not recognize the locations of the boxes physically nor does it know the box numbers present in the system. A unique identification number was used for each card reader in the boxes, and this number is the same as the box number. The interface sends three commands via the transmission unit to the Arduino:
- list command: Requests the Arduino to display the registered readers represented by their specific number.
- add:rfid/reader number command: Sets the identifier and the reader number for transmission.
- del:rfid command: To delete the identifier from the reader.
* At the beginning of system initialization, reader numbers are saved in the Arduino memory using (EEPROM).
Unknown Cards Interface
The interface displays a list of unregistered identifiers that were read by the system but are not present in the database, allowing them to be reviewed before making a decision to add or ignore them. It also provides the ability to delete identifiers, which helps maintain the accuracy and integrity of the recorded data.
Identifier Display Device (Desktop)
Creating a desktop application using VisualBasic.NET to interact with Arduino via Serial communication, allowing RFID identifiers to be read and displayed in the graphical user interface.
- Connecting to Arduino: Data is received from the Arduino device via the Serial Port and parsed within the application.
- Displaying Identifiers: The read identifier is displayed directly inside a TextBox, with a sound notification and an alert to the user when a new identifier is received.
- Handling Data: The application provides the ability to easily copy the identifier to the clipboard for use in other applications.
- This device consists of an Arduino Nano design with a card reader.
Connecting the identifier display device matches the connection with Arduino Uno
Login Interface (Desktop)
This interface represents the login screen for the application, requiring the user to enter login information in the two designated fields (username and password), then click the "Login" (تسجيل) button to access.
Identifier Display Interface (Desktop)
The identifier display interface in the project receives data from Arduino via the serial port (Serial Port), where RFID identifiers are fetched and automatically displayed inside a TextBox.
- When a new identifier is received, the user is notified visually and audibly, with the ability to easily copy the identifier to the clipboard. This interface aims to provide a fast and accurate method for displaying recorded identifiers without the need for manual entry.
- "Student Info" Button: When clicking this button, a list of students registered in the system is displayed, where their data is fetched from the SQLite database. This list can be used to search for a specific student or browse all data along with their photo.
- "Register" Button: When clicking this button, a new entry form opens allowing the user to add a new student to the database. The form includes fields such as Name, University ID, RFID identifier, Stage, and Registration Status, with a button to save data to ensure it is stored correctly inside the database.
Student Information Interface (Desktop)
Student Information Interface (Desktop)
- The student information interface is a window that allows the user to view the data of students registered in the system. Data is fetched from an SQLite database and displayed in a formatted table for easy reading and searching.
Key Features of the Interface:
- Display all students: Upon opening the interface, all student data is automatically loaded from the database.
- Search Capability: The RFID identifier number can be entered to search.
- This interface helps supervisors manage student data efficiently and quickly, improving the user experience.
- Deletion Capability: By selecting any cell/row.
[Buttons translated from the Interface Image]:
- Add Student (اضافة طالب)
- Delete (حذف)
- Reload (اعادة تحميل)
- Search (بحث)
- Main Menu (القائمة الرئيسية)
Registration Interface (Desktop)
Registration Interface (Desktop)
The "Add New Student" interface allows the user to enter data for a new student and register it into the database. It contains text fields for entering the student's name, identifier number, box number, and academic stage.
- Validation: The system verifies that no field is left empty and prevents the duplication of the identifier number to ensure that duplicate data is not entered.
- Image Handling: It provides the ability to add a photo for each student and display it.
- Saving Data: When the Save button is clicked, the data is saved in the database, and a confirmation message is shown to the user.
- Objective: The goal of this interface is to facilitate the management of new students and register them quickly and accurately while ensuring data integrity and non-duplication.
[Labels Translated from Interface]:
- Card ID (معرف البطاقة)
- Name (الاسم)
- Gender (الجنس)
- Stage (المرحلة)
- Locker Number (رقم اللوكر)
- Box Number (رقم الصندوق)
- Add Image (اضف صوره)
- Student Info (معلومات الطلاب)
- Save (حفظ)
- Main Menu (القائمة الرئيسية)
References
References
- https://microcontrollerslab.com/rc522-rfid-reader-pinout-arduino-interfacing-examples-features/
- https://www.circuitbasics.com/basics-of-the-spi-communication-protocol/
- https://en.wikipedia.org/wiki/Raspberry_Pi
- What is Arduino? | Arduino Documentation
- Serial Data and Debug UART – Connect Tech
- In-Depth: How nRF24L01 Wireless Module Works & Interface with Arduino
Results
Results
In the conclusion of this project, an integrated system for smart locker management was successfully designed and developed using the Arduino board as a peripheral control unit and the Raspberry Pi as a central processing unit. The system proved its effectiveness in achieving the main objectives of the project, represented in providing a secure and reliable method for users (students) to access their assigned lockers using RFID technology, with central recording and control of all operations.
The practical application process demonstrated the success of integrating various components such as RFID (MFRC522) readers, NRF24L01 wireless communication modules, and electronic locks, and programming them to interact correctly and systematically via the SPI protocol. User interfaces (desktop and web) were also successfully developed to allow easy management of users and boxes and monitoring of the system status, in addition to recording unknown cards to increase security.
Challenges related to distances, signal interference, and power distribution for several components operating on the SPI protocol were effectively addressed through the use of appropriate cables and thoughtful power distribution, ensuring system stability and reliability.
In general, this project offers a practical and applicable solution to the traditional locker management problem, demonstrating the feasibility of using Internet of Things (IoT) technologies and open-source hardware such as Arduino and Raspberry Pi in developing smart, secure, and cost-effective systems that can be easily implemented in educational institutions and other places requiring secure access management for users.