This article presents how to design and implement smart door locks in smart homes based on AIoT approach. The construction of IoT architecture allows remote monitoring and control of door locks via web server. Besides, the use of suitable Artificial Intelligence (AI) algorithms in the Modular Audio Recognition Framework (MARF) library to authenticate speakers and keywords will make the door opening/closing automatically. Evaluation results through experimental models show that the system is easy to implement, operates with high accuracy (82.5%) and can be widely deployed in practice.
The Internet of Things (IoT) is a system that allows devices to be connected, monitored and controlled remotely over the Internet. In recent years, IoT technology has made a strong development step and is applied in many different fields such as smart home, telemedicine, environment, industry, agriculture, transportation, etc. [1].
Smart home is one of the important applications of IoT technology for the purpose of integrating home automation solutions. The IoT architecture allows objects and devices in the home to be connected to the Internet so that users can monitor and control them remotely. Therefore, IoT-based smart home solutions have become very popular [2].
To improve service quality, smart home problems need to be learned from different practical activities. This can be done by applying AI algorithms. Smart homes use artificial intelligence to analyze information and read the homeowner's habits so that they can offer appropriate utilities to meet user needs. This is a trend that major technology companies in the world are investing in. Therefore, AIoT (A combination of IoT and AI) has been creating a lot of research momentum in the world [2,3].
There are many small problems that need to be implemented when building a smart home such as lighting management, power supply management, water and gas supply management, etc. In this article, we focus on a problem of monitoring and control smart door lock. Basically, a smart door lock is a keyless lock compared to traditional door locks. Opening/closing the door can be done through digital communication via Bluetooth, Wi-Fi or through identification procedures such as RFID, fingerprint, image, voice [4-6].
Because there is no need for a traditional key, the voice recognition AI algorithm will allow the smart door lock to recognize the owner standing in front of the door to automatically unlock. With a suitable IoT architecture (via web server) users can also remotely unlock doors or grant access to family members, friends and guests when they are not at home [7-10].
Therefore, in the following content, in Section 2, we propose an IoT architecture to monitor and control the operating status of the door lock through the web server. In Section 3, we propose to use suitable AI algorithms in the MARF library to identify speakers to improve the security of automatic door locks. Section 4 will present how to build an experimental model (both hardware and software) to verify the performance of the system. Section 5 outlines some of the results that have been achieved. The last part is some conclusions and directions for further research.
IoT Architecture for Smart Door Lock
Within the scope of this article, we aim to build an IoT architecture that allows remote monitoring and control of door locks via web sever.
The architecture of the system as shown in Figure 1 includes a central control block which is connected to the speech recognition block, web browser block, display block, unlock/close relay block, speaker.
Using AI Algorithms in Building Smart Door Locks
As depicted in Figure 2, the speaker recognition process is divided into steps such as input data acquisition, data preprocessing, feature extraction and classification [11]. Each step in the process is performed using a variety of methods.
In the data acquisition step, the audio signal can be collected in Wav, MP3, MP4 file format. This signal will be passed through a data preprocessor which uses some signal filters to remove noise or unnecessary signals.
The process of extracting the amplitude and frequency features of the signal will be performed in the feature extraction step. These features will be used to classify between different signals. From there, a model file is created containing layers of information specific to each original audio signal.
The data obtained during the training process is sent to the classification stage to create the recognition model. At the test stage, the input data will be compared with the database in the trained model to authenticate the speaker.
To make it easier to implement later, we use the MARF audio processing library [11]. This is a library containing speech/audio processing algorithms written in Java language and synthesized into modules that make it easy to use for the development of new algorithms. MARF can act as a library in addition to applications or can be used as a source for research and development. The MARF library contains a full range of speech recognition and processing methods, including input signal processing methods, feature extraction methods and classification methods described in Table 1.
We also collected audio data sets for training and evaluation. The dataset was taken from 4 people, each with 15 samples (8 samples for training and 7 samples for testing) according to the criteria as recommended in Serguri et al. [11] as follows:
By "trial and error" method (which in turn combines the methods of preprocessing, feature extraction and classification), we have trained and tested the above sample set. As a result, we found the set of methods with the highest accuracy (89.3%) as Table 2.

Figure 1: Architecture of the Smart Door Lock System

Figure 2: Some Data Processing Methods in Speaker Recognition
Table 1: Speech Processing Methods in the MARF Library
| Method | Parameter | Meaning |
| Pre-processing | Raw | No preprocessing |
| Norm | Use just normalization, no filtering | |
| Low | Use low-pass filter | |
| High | Use high-pass filter | |
| Boost | Use high-frequency-boost preprocessor | |
| Feature extraction | LPC | Use LPC |
| FFT | Use FFT | |
| minmax | Use Min/Max Amplitudes | |
| randfe | Use random feature extraction | |
| aggr | Use aggregated FFT+LPC feature extraction | |
| Classification | nn | Use Neural Network |
| cheb | Use Chebyshev Distance | |
| eucl | Use Euclidean Distance | |
| mink | Use Minkowski Distance | |
| diff | Use Diff-Distance | |
| randcl | Use random classification |
Table 2: Evaluation Results of the Methods for the Test Sample
| Method | Correct samples | Wrong samples | Precise rate | Method | Correct samples | Wrong samples | Precise rate |
-endp-lpc-cheb | 24 | 4 | 85,7 | -norm-fft-mah | 24 | 4 | 85,7 |
-raw-aggr-eucl | 24 | 4 | 85,7 | -norm-fft-eucl | 24 | 4 | 85,7 |
-norm-aggr-diff | 24 | 4 | 85,7 | -norm-aggr-eucl | 24 | 4 | 85,7 |
-norm-aggr-cheb | 24 | 4 | 85,7 | -low-aggr-diff | 21 | 7 | 75,0 |
-raw-aggr-mah | 24 | 4 | 85,7 | -norm-aggr-mah | 24 | 4 | 85,7 |
-raw-fft-mah | 24 | 4 | 85,7 | -raw-fft-cheb | 22 | 6 | 78,6 |
-raw-fft-eucl | 24 | 4 | 85,7 | -raw-aggr-mink | 25 | 3 | 89,3 |
-norm-fft-diff | 24 | 4 | 85,7 | -norm-aggr-mink | 24 | 4 | 85,7 |
-norm-fft-cheb | 24 | 4 | 85,7 | -low-fft-cheb | 22 | 6 | 78,6 |
-raw-aggr-cheb | 22 | 6 | 78,6 | -raw-lpc-mink | 23 | 5 | 82,1 |
-endp-lpc-mah | 22 | 6 | 78,6 | -raw-lpc-diff | 23 | 5 | 82,1 |
-endp-lpc-eucl | 22 | 6 | 78,6 | -raw-lpc-eucl | 23 | 5 | 82,1 |
-raw-fft-mink | 25 | 6 | 89,3 | -raw-lpc-mah | 23 | 5 | 82,1 |
-norm-fft-mah | 24 | 4 | 85,7 | -raw-lpc-cheb | 23 | 5 | 82,1 |
-norm-fft-eucl | 24 | 4 | 85,7 | -low-aggr-eucl | 23 | 5 | 82,1 |
Building Experimental Models
Hardware Construction: To evaluate the actual efficiency of the algorithms that have been selected in the MARF library, we proceed to build an experimental model as described in Figure 3. Including:
Central Control Module: We use the Raspberry Pi 3 microcontroller which is a tiny computer running the Linux operating system depicted in Figure 4
Omnidirectional Microphone: Omnidirectional microphone using USB connection for Raspberry Pi with 360-degree reception angle. Frequency range from 80 Hz to 10 Khz, compatible with all Raspberry Pi series, receiving distance up to 3 m (Figure 5)
I2C Interface LCD Module: We use a 16×2 alphanumeric LCD module with 2 display rows and each row allows up to 16 characters to be displayed. Attached to the LCD is an I2C communication module that allows connecting to the Raspberry Pi in a simpler way than normal GPIO communication (Figure 6)
Relay: This block functions as an electronic switch to control the opening/closing of the lock. The block is connected between the central processing unit and the electronic lock (Figure 7)
Push Button: We use two push button presses to initiate speaker authentication or add speakers to the database
Building System Software
The algorithm flowchart describing the operation of the system is shown in Figure 8, the system requires at least two voices to be added to the previous database to perform model training.
The system operates in two phases, the network training phase and the authentication phase.
In the network training phases, the user's audio data is collected, preprocessed, feature extraction and classified according to the methods described above to create an identity model.

Figure 3: Hardware Wiring Diagram of Smart Door Lock System

Figure 4: Raspberry Pi 3 Model B+

Figure 5: USB Connection Omnidirectional Microphone
During authentication, after initialization. If button 1 is pressed, the system will receive and check the obtained data. If the content of the data matches the pre-installed keywords, the system will transfer the data to voice authentication. If the keyword does not match, the system will report an error and go back to the initialization process. During voice authentication, the data will be checked and compared with the trained data, if the distance Minkowski is greater than the allowed threshold (1.1), the system will return to the initialization process. If the comparison result is lower than the threshold, it means that the correct speaker has been identified, then the system will output data to the LCD and control the relay. If button 2 is pressed, the system will switch to adding users to database. In addition, you can turn on, off and check the status of the remote door through the webserver as soon as the system starts up.
Based on the proposed operating principle, in order to be more convenient in the implementation process, we divide the main program into a number of subroutines written in Python language. These programs include:

Figure 6: I2C Interface LCD Module

Figure 7: Relay Module
Model Training Program: This program is intended to put files that are already in the database for training. The output of this program will create a model file and a speaker database file. These files are used to compare with the data during later speaker authentication
Model Test Program: First, the program will perform audio data acquisition. Then, on the one hand, the program will convert speech into text for testing with pre-set keywords, on the other hand, put the voice into a trained model to authenticate the speaker, thereby serving as the basis for make the decision to close/unlock the door
Monitoring and Control Program via Web Server: We use Cloud4pi application to make it easy to design remote control interfaces via wifi connection with Raspberry Pi microcontroller

Figure 8: Algorithm Flowchart of the System

Figure 9: Experimental Model
Some Results Obtained
Figure 9 depicts the completed experimental model. When the system is working, the LCD screen will show the status of the speaker recognition system. Using push buttons, you can add new speakers to the system or check user authentication via voice. In addition, we can also close, open the door and monitor the status of the door through the web interface on the Cloud4pi application.
When the user wants to open the door, the user presses the button 2 (green), the system will record then confirm the key and voice. If both the key word and the speaker are correct, the door control signal will be sent to the relay to open the door. At this time, the LCD screen will announce the successful opening of the door and the signal LED will light up.
If you want to add new people to the database, the user presses button 2 (red), then continues to press button 1 (green). The system will record, save the voice to the database, run the model training program with the new database.
To evaluate the performance of the module, we conducted a test with performance test on the experimental model with 4 people who were sampled while building the network training model (presented in section 3). Each person does the test 10 times. The correct result is 33/40 samples, reaching the rate of 82.5%.
From the obtained results, we can see that the system has basically met the set requirements. The advantage of the system is that the security is increased by combining both keyword recognition and speech recognition. In addition, the use of tools in the MARF library and Cloud4pi application makes the deployment simple, easy to add users to the database as well as monitor and control the door remotely via the web server.
On the downside, through testing, we found that the accuracy of the system is quite dependent on the environment. This is because during training, the samples are obtained under better conditions than when conducted in the real world. Besides, the new system only evaluates on 4 users with a small number of samples.
AioT technology (with a combination of IoT architecture for monitoring, remote control and AI algorithms to increase intelligence) is an inevitable trend to build practical intelligent electronic systems.
With the two goals of both ensuring security and being easy to apply in practice, in this article, we have presented a way to implement both hardware and software for the smart door lock problem based on AIoT technology.
Using the Cloud4pi application on the Raspberry Pi microcontroller allows to easily create an IoT architecture to monitor and control the status of the door lock remotely. In addition, the use of AI tools in the MARF library allows to implement two layers of security on the key (combination of speaker authentication and keyword recognition).
Experiments show that the system meets the set requirements and can be applied in practice. However, the system can be further improved by building a separate application for monitoring and remote control instead of Cloud4pi and using Deep learning tools instead of machine learning algorithms in the MARF library. This will also be the next development direction in this research.
Mocrii, Dragos et al. “IoT-Based Smart Homes: A Review of System Architecture, Software, Communications, Privacy and Security.” Internet of Things, vol. 1-2, 2018, pp. 81-98. https://doi.org/10.1016/j.iot.2018.08.009.
Stolojescu-Crisan, Cristina et al. “An IoT-Based Smart Home Automation System.” Sensors, vol. 21, 2021. https:// doi.org/10.3390/s21113784.
Guo, Xiao et al. “Review on the Application of Artificial Intelligence in Smart Homes.” Smart Cities, vol. 2, 2019, pp. 402-420. https://doi.org/10.3390/smartcities2030025.
Sung, Tien-Wen et al. “Artificial Intelligence of Things (AIoT) Technologies and Applications.” Wireless Communications and Mobile Computing, 2021, pp. 1-2. https://doi.org/10.1155/2021/9781271.
Aiswarya, I.P. “A Survey on Smart Door Lock Security Methodologies Implemented Using Various Wireless Access Technologies.” International Research Journal of Modernization in Engineering Technology and Science, vol. 2, no. 9, September 2020, pp. 1814-1819.
Shetty, Shrajna et al. “Review Paper on Door Lock Security Systems.” 2020, pp. 1-4. https://doi.org/10.1109/ICCDW 45521.2020.9318636.
Oduroye, Ayorinde et al. “Voice Recognition Door Access Control System.” 2019, pp. 1-12. https://doi.org/10.9790/ 0661-2105010112.
Islam, Mohammad. IoT-Based Home Automation System with Voice Recognition. 2018. https://doi.org/10.13140/ RG.2.2.33878.91205.
Hanifa, Rafizah Mohd et al. “A Review on Speaker Recognition: Technology and Challenges.” Computers & Electrical Engineering, vol. 90, 2021. https://doi.org/10. 1016/j.compeleceng.2021.107005.
Samuel, Falohun et al. “Design and Construction of Speech Controlled Door.” Asian Journal of Research in Computer Science, 2021, pp. 28-40. https://doi.org/10.9734/ajrcos/ 2021/v11i130254.
Mokhov, Serguei et al. “The Modular Audio Recognition Framework (MARF) and Its Applications: Scientific and Software Engineering Notes.” 2009. https://doi.org/10. 1145/1370256.1370262.