Skip to content

+49 1626571232

info@openelab.io

🚀 Free Shipping from 50€ in EU / 80€ Worldwide

Learn

M5Stack RFID-based Smart Access Control System

As we enter the era of intelligence, cloud-based intelligent communication devices have become very popular in our lives. This article will use M5Stack's UiFlow development interface (Blocky) to complete the access control system with cloud-based record function, including four kinds of authentication locks (mobile phone remote unlocking, RFID card, keystroke passwords, fingerprint identification), and through the MQTT protocol to transmit the access control records are transmitted via MQTT protocol.

 

Hardware Configuration

 
The access control system utilises the M5Stack Faces modular package. The FACES package comprises a control core (M5Stack Core) and a range of input devices, including a calculator, QWERTY keyboard and other input devices. In this instance, we are using the calculator keyboard module for keystrokes. It is important to note that the Faces module should be replaced with care, ensuring that both sides of the module are held to unplug in order to avoid damaging the pins. It is important to exercise caution when replacing the Faces module to prevent damage to the pins.
 
The next step is to set up three unit modules. Please note that the M5Stack RFID module uses the communication interface I2C and can be accessed from the left side of the Core Port-A. The M5Stack fingerprint recognition module uses the communication interface UART and can be accessed from the Core Port. Please note that the Core's GPIO can be flipped to the back of the Core, where you will find a hint of the corresponding interface PIN. The GPIO module on the back of the Core will also have a hint of the corresponding interface PIN. The GPIO interface at the rear of the Core (GND, 5V, R2(16), T2(17)) and the M5Stack Relay Module are controlled by I/O and connected to Core port-B (GND, 5V, DA(26), AD(36)).

 

 

Once the wiring configuration of the three Unit modules is complete, a circuit should be created to connect the relay module (as shown) in order to control the solenoid lock. This time, the solenoid lock operating voltage of DC 12V should be used. Please note that the M5Stack Relay Module supports up to DC 30V 3A power input.

 

 

Once the relay circuit hardware has been configured, the writing program will utilise the official M5Stack development interface, Uiflow. Given the current UiFlow offline host version's slow update, it is recommended that, if the wireless Wifi speed is sufficient, the remote write Blocky be used. The subsequent step will be to introduce the Wifi wireless method of writing programs for M5Stack. The following section will present the process of writing programs to M5Stack Core via Wifi.

 

UiFlow Setting

 
Update the firmware
Before connecting, you must download the official burner (M5Burner) to update the firmware version to the latest. After connecting the cable, the burner will show the COM port number, select the latest CORE UiFlow firmware version and press Burn to finish burning.
 

 
Establish connection
After updating the firmware, switch the Core to 'Internet Mode', select 'Wi-Fi via AP', and then enter the online page, you will see the Earth symbol blinking.
 

 
To connect to the laptop's WiFi, enter the SSID name in the search field. Please note that the name of each Core is not the same. In this example, the name is M5-FB50. Once connected, open the browser and enter the following address in the search field: [192.168.4.1]. This will take you to the online settings page. Enter the SSID and password you want to connect to.
 
Once a successful connection has been established, the browser will display the following image. The WiFi and online icon, located in the upper left corner of the Core display, will appear in green, and the API key used for remote connection will be visible at the bottom. This configuration enables Core to access the SSID and password, and then utilise the network mode to establish a direct connection to the Internet. In the event that multiple APs have been employed, the option to select from a list can be accessed via Setup > Server. Should you have utilised multiple APs, you may also access them via Setup > Server.
Next, open your computer's browser, reconnect to the Internet, go to the Uiflow web version, fill in the API KEY, select the type of Core and press 'OK'.
 
 
The status bar at the bottom will show the API KEY of the currently connected device, and display 'Connected', which indicates that the remote connection is successful and you can start writing programs with Blocky blocks.

 
Step1 Setting up Blocky

 
Prior to commencing the Blocky writing process, it is necessary to import the specific Unit module library that is to be utilised on this occasion. To do so, click on the plus sign located at the bottom left of the screen. Thereafter, select Port B for the Relay module, Port C for the Fingerprint module, and Port A for the RFID module. It is important to confirm the selected module by pressing the OK button located at the bottom right of the screen.
 
 
After importing the module, it will be shown in the left display panel, open the Unit menu to confirm if the module is imported correctly.
 
 
Step 2 Write subroutines for common use in access control system
 
After importing the module, in order to avoid the program is too long, first of all write several subroutines which will be used repeatedly in the access control system.

1.System default state (STAY) :

After executing any program, it will return to this default program state. The display function of keystroke and AC clear function are built here, find the initial value of AC button (intial value) to give the definition when pressing the button.Uiflow use to the function column: build function, judgment logic function, keyboard input function, UI component, relay reset.

 

2.UNLOCK: The action when the identity is confirmed correctly by RFID, fingerprint recognition, password input, remote control, and to ensure the safety of the relay operation, the relay will be automatically turned off 3 seconds after it is turned on.Uiflow uses the following function columns: build function, buzzer, judgment logic function, UI component, relay turn on and reset.

 

 

3.LOCK: The action when the identity is confirmed correctly by RFID, fingerprint recognition, password input, remote control, etc. Uiflow uses the following functions: Build function, Buzzer, Judgment Logic function, UI component.

 

 

Step3 Setting up network connection and MQTT function.
 
The objective of this experiment is to set up a network and connection that will enable the transmission of data from each door opening to a temporary cloud storage area via the MQTT protocol. The setup will be done using WiFi. MQTT is a messaging protocol based on the 'publish/subscribe' mechanism, which is analogous to the video posting and subscribing mechanism of social media or YouTube.
 
In MQTT, the sender of messages is analogous to a YouTube channel or an Instagram account. Once a movie has been released or an Instagram post has been made, it is not sent directly to subscribers. Instead, it is handed over to a server or third party (broker), which coordinates and manages the release and subscription issues. Each source of content (e.g., a movie or an article) is assigned a unique topic name (e.g., the title of the movie or article), and the proxy is a server software. The entity that transmits the topic to the server is the publisher, and the entity that receives the topic from the server is the subscriber.
 
Firstly, please set up the WiFi connection function of the Access Control Core. To do this, open the Advanced menu of Uiflow, select 'Connect to Wi-Fi SSID' and enter the password in Network. You will then be prompted to enter the name and password of the access point at the location where you intend to set up the access control system. Please select 'Connect to Wi-Fi SSID' and enter the name and password of the access point (AP) that can be connected to the location where you want to set up the access control system.
 
To confirm whether the WiFi is online or not, add a judgment logic function and the screen UI scroll component. When the WiFi is online, it will show green, and when it is offline, it will show red. This completes the network online setting. Uiflow uses the following function columns: The following functions have been included: Judgment Logic, WiFi Setting, and UI Component.
 

 
The MQTT Broker used by the access control system is a free broker provided by HiveMQ to all users.Open your browser and go to Public Broker to check the Host and TCP Port of the Broker.
 
Next, open the Advanced menu of UiFlow, use the MQTT host to set and enable MQTT function, fill in the TCP port and server of the broker, and set a user name for the client, after the setting is completed, Core will enable MQTT service under Wifi connection.Uiflow uses the following functions.

 

 

To set up a cell phone to receive/send MQTT messages, search for IoT MQTT Panel in GOOGLE PLAY or Apple app store and download it to open it. IOT MQTT Panel is a lightweight and easy to use MQTT tool with many Ui templates already set up, and the paid version provides real-time notifications on the cell phone to pop up notifications when new messages are received. notifications when new messages are received.

 

 
After opening the App, first according to the previously set CORE broker TCP Port and server (BrokerWeb) in order to fill in the Client also set a user's name, here remember to add a function Dashboard otherwise it can not be created!

 

 
After the creation of a good Dashboard and then build the UI function module (Add panel), we have to build a total of two attributes of the function module, one is the record of access control triggered by the Text Log, and one is the remote control of the Switch switch.
 

 
Step4 Access Control Log
 
Create an access control record function, when the access control system triggered to confirm the identity of the function to send the confirmation results to this record, the principle of work is to create a Topic (I set here as M5Stack_Log), to provide the access control system Core to send a message to this Topic. function module settings: adjust the number of messages displayed and the font size, the timestamp, the cell phone real-time notification function ( Enable notification) must be paid to use. Enable notification) must be paid to use, after the setting is completed, press SAVE to complete the creation.
 

 
Step5.Access Control Function--Remote Unlocking
 
Remote Switching : The working principle is to set a Topic on the cell phone, according to the UI switch status (ON/OFF) on the cell phone to send a msg (I take it as unlock/lock), the Core on the door lock will read the msg by subscribing to the Topic on the cell phone, and then it can control the door lock switch.
Below the hook function column, you can put the bottom of the Show received timestamp and Show sent timestamp hook up to record the time point, cell phone real-time notification function (Enable notification) must be paid to use, set up after the completion of the SAVE that is to complete the creation.

 

 
Please ensure that Uiflow is enabled, that the remote control function is configured, and that the access control CORE subscription broker's Topic (Lock_Action) is set up. When the cell phone is activated, the unlocking subroutine (UNLOCK) should be executed to open the door lock and the access control record transmitted to the cell phone's Topic (M5Stack_Log) with the name Remote_OPEN. Please note that the name must be entered correctly, as an incorrect case will result in failure to receive and transmit the message. The message name is 'Remote_OPEN'. Please note that the name must be entered correctly, as an incorrect topic will result in the message not being received or transmitted. Uiflow uses the following function columns: The MQTT function, judgment logic function, text import subroutine and other functions are available for use.

 

 
Remote control results in a successful solenoid valve actuation and is displayed on the Core screen. The logging module on the cell phone displays data with a time stamp.

 

 
Step6 Access Control Function--RFID
 
To set up the RFID access control function, first add a Main loop under the current MQTT setting function, as the main program to trigger the judgment, and add the function to trigger the function when there is an RFID card close to the function.Uiflow uses the function columns: MAIN function creation, judgment logic function, RFID function library.
 

 
Create RFID judgment function (RFID_decision), RFID subroutine (RFID_OK), and RFID subroutine (RFID_Denied). The judgment function (RFID_decision) is used as the execution subroutine (RFID_OK) plus the system subroutine (UNLOCK) when RFID is correct, or the execution subroutine (RFID_Denied) plus the system subroutine (LOCK) when RFID is incorrect.
 
Remember to add MQTT push function in the two RFID subroutines after completion, no matter correct or error will push the message to the Topic (M5Stack_Log), RFID UID can be obtained through the Uiflow RFID function.Uiflow use to the function column : build RFID subroutine function, judgment logic function, RFID function library, UI components, MQTT functions, text, import subroutine functions.
 

 
Successful RFID recognition of the solenoid valve will act once and display the correct card on the Core, and the card that senses an error will display the error.
The logging module on the cell phone displays the correct and incorrect (with time stamps) information.
 

 
Step6 Access Control Function--Keystroke Password Entry
 
To set the keystroke password function, add a keystroke function trigger function under the main program (Main) loop, which is triggered when the number of digits entered into the keypad is greater than or equal to 7. Uiflow uses the following function columns: Function, Judgement Logic Function, Text, Keypad Module Function.
 
The following functions and subroutines should be created: Password_decision, RFID_OK, and RFID_Denied. The Password_decision subroutine is used as an executable subroutine (Type_OK) plus a system subroutine (UNLOCK) when the password is entered correctly, or as an executable subroutine (Type_Denied) plus a system subroutine (LOCK) when the password is entered incorrectly.
 
Once you have completed the password input subroutines, please add the MQTT push function to both, regardless of whether the password was entered correctly or incorrectly. The message will then be pushed to the Topic (M5Stack_Log). Uiflow uses the following function columns: The following functions are to be created: Password Input Subroutine, Judgment Logic, Keyboard Module, UI Component, MQTT, Text, and Import Subroutine.

 

The solenoid valve acts once and displays correctly on the Core if the password is entered correctly, and displays incorrectly if the password is entered incorrectly.
The logging module on the cell phone displays the data of correct and incorrect passwords (with time stamps).

 

 

Conclusion

 
This real-life access control system employs a range of technologies, including RFID, fingerprint recognition, keystroke and other modules, to rapidly develop robust hardware solutions. It utilises MQTT communication protocols to remotely unlock door locks and generate access control records. Due to the advanced functionality of Blocky, features such as AI face recognition are not currently available on UiFlow. However, we will be introducing advanced YOLO detection functions after image streaming in the near future.

 

Prev Post
Next Post

Leave a comment

All blog comments are checked prior to publishing

Someone recently bought a

Thanks for subscribing!

This email has been registered!

Shop the look

Choose Options

Edit Option
Back In Stock Notification
this is just a warning
Login
Shopping Cart
0 items
RuffRuff App RuffRuff App by Tsun