Build a Smart Access Control System with M5StickV and RFID
In this project, we'll create a smart access control system using ESP32, RFID units, and M5StickV. The system supports RFID card reading, QR code recognition, and “offline-cloud platform” interaction via MQTT. Key features include RFID read/write capabilities, MQTT-based data communication, and user interface interaction via M5GO Lite.
Project Objectives
-
Card Punching System: Implement the basic logic of a card punching system using ESP32 as the main control chip.
-
RFID Information Recognition: Use the RFID unit to read and recognize IC card information.
-
Offline-Cloud Interaction: Enable offline-cloud platform interaction for exercise information using MQTT.
-
QR Code Recognition: Utilize M5StickV for QR code recognition.
Implement Procedures
Setting Up the MQTT Server
1. Server Settings:- Server ID, Username, and Password: Set these main elements for the MQTT server.
- Port Number: Typically set to 1883.
- Server URL: Provide the platform's URL.
- Topic and Data Format: Ensure the topic format matches the platform's API parameters. Data is usually formatted in JSON.
- Subscription Details: Set the topic and data for subscribing. Ensure the themes for publishing and subscribing are different. Security should be managed by the broker. Subscription data will return Mid and Result values, which can be used to verify data integrity and upload success.
Module Configuration
M5StickV for QR Code Recognition
1. Camera and Image Parameters:-
Libraries: Use MicroPython's sensor and image libraries.
-
Image Format: Set to RGB565.
-
Resolution: Set to QQVGA (160x120).
-
Capture Image: Use the
img
library to capture the camera image.
-
Detection: Use
find_qrcode
to detect QR codes in the image. It returns parameters like parsed data and specifications. -
Decoding: Extract and use the decoded data for further processing.
RFID Configuration
RFID Card Structure:-
UID and BLOCKS: UID is a unique, read-only identifier. BLOCKS are readable and writable, where student data is stored.
-
Delay: Implement a delay to prevent multiple recognitions due to high RF processing frequency.
UART Communication
Overview:- Protocol: UART is a serial asynchronous transceiver protocol transmitting binary data bits.
- Signal Levels: High for '1' and low for '0'.
- TX (Transmit Data): Connect to the RX of the other device.
- RX (Receive Data): Connect to the TX of the other device.
- GND: Ensure a common ground between devices.
- M5Go Lite: TX (GPIO17) and RX (GPIO16).
- M5StickV: RX (GPIO35) and TX (GPIO34).
-
Library: Use MicroPython's
uart
library to set up the platform.
Functions
Main Functions
- M5GO Lite UI: Interactive interface with WiFi connection.
- RFID Read/Write: Read and write IC card information.
- MQTT Communication: Interact between the cloud platform and development board.
- QR Code Recognition: Use M5StickV to recognize and read QR codes.
- Punch Card System: Query and display punch card information.
Secondary Functions
- No Repeat Punching: Prevent repeat punching on the same day.
- QR Code Validation: Ensure only student information is uploaded.