Design and Implementation of a Smart Home Security System Using Voice Command and Internet of Things

-A smart home security system consists of various sensors and recorders to automatically provide data on the conditions of a house. Home electronic equipment may be controlled from distant places using the internet of things technology and speech recognition. This research aims to develop a smart home security system by monitoring fire hazards and theft. It helps also control electronic equipment using voice commands that is useful especially for the disabled. The system design consists of hardware, software, and application design. Hardware design uses ESP8266, Arduino Mega 2560, MicroSD Card module, VC0706 serial camera, DHT22, magnetic door switch, PIR HC SR501, and Google Assistant device. Software design uses Arduino IDE for programming Arduino Mega and ESP8266. Applications used in the design are Adafruit.io, Thingspeak, and IFTTT (If This Then That). Voice commands control home electronic devices (lights), while fire and theft are monitored through the use of sensors and cameras. The system test shows that voice command can control lights on and off at an accuracy of 88%. Temperature and humidity sensors acquire data and send them to Thingspeak application for online fire monitoring. Sensors to detect intruders in the form of door switch and PIR work well and automatically activate cameras that capture objects to store in a MicroSD card.


Introduction
Smart home security systems that are widely implemented today have replaced the more traditional home security system. A security system has changed from wired to wireless to control all existing apparatus. Such a system provides benefits in the form of cost and energy saving and can increase the value of a home security system. Control and monitoring of smart home security can be done remotely using an Android device without even touching the apparatus. It certainly provides its benefits, especially for those with disabilities [1].
Smart home security systems are built by installing sensors and recording devices to monitor the condition of the house's security both in the event of fire and theft. Electronic gadgets and electrical equipment that is in the smart home can also be controlled remotely automatically, one of them with voice commands that allow users no need to touch the button again.
The smart home security system that has been developed is done with a face recognition system to open and lock the door of the house. Of course, this system will be useful to maintain the security of the house from the side of avoiding someone who is not entitled to access the house through an existing door, thus avoiding theft. A face recognition system is done by installing a webcam camera to capture images of someone's face that will be compared following the given template [2].
The system for opening and locking smart home doors can also be done with fingerprint recognition for anyone who will open the door. Although the use of fingerprint recognition for security systems is not limited to home security, this system is an alternative security system by recognizing someone's fingerprint-based on its compatibility with the existing template. This system is built with a fingerprint scanner that will allow someone to lock or open the door automatically which replaces the conventional door locking system [3].
The security of smart homes can also be monitored using surveillance cameras that watch the movements of an unwanted body. Motion sensors are installed to detect the movements of a person that will activate a camera to record objects that appear [4] [5]. The recorded data will provide information about the existence of an object. The camera performance will only be active if there is a movement of an object being staked, in other words, if no object is detected then the camera will not do the object recording.
Smart home security in the form of detection of fire is done by installing sensors and cameras that will detect the presence of fire while sending data information to its users. The sensor that is installed will detect the presence of fire and the camera will record the object that occurred and at the same time send a message about the fire. This system will also activate the alarm and the motor when there is a fire [6].
Smart home automation systems will also allow users to be able to control existing electrical and electronic equipment. Control of this smart home is done by utilizing several technologies such as voice recognition, gesture control, eye retinal motion, and others [7]. The voice commands given will be used to turn on and turn off the equipment automatically. Voice command recognition is built using a special hardware module that is integrated with the Arduino microcontroller device to process commands and controls. A home security system for smart homes that supports parents and people with disabilities was built with the introduction of voice commands to control electronic equipment and improve the home security system. This system was built to be able to recognize users through voice commands to control electronic equipment remotely using an android application to read voice commands. This system is also equipped with an ultrasonic sensor that will detect the presence of a moving object and send messages to its users [8].
This study aims to develop a smart home security system in the form of monitoring the occurrence of fires and theft as well as controlling electronic devices using voice commands that will benefit parents and people with disabilities. Voice command recognition uses a special Google Assistant device found on the Android smartphone application to replace and turn on the lights. Another system that is built is the detection of object movements using sensors that are installed to activate the camera that records the detected objects whose results are stored on a MicroSD card. The existence of fire is detected using a temperature and humidity sensor whose results are displayed on the LCD and sent to an IoT application in the form of Thingseak so that it can be monitored for an increase in temperature and humidity.

Literature Review
The basic idea of the system developed in this study is a smart home security that will be able to monitor the condition of home security from fire and theft, and can control the electronic devices in the smart home by using IoT-based remote voice commands. Previous research has been done to develop systems related to smart home and security, including research conducted by Saumya who conducted research on the Internet of Things for surveillance and fire alarms [9]. This research resulted in an integrated fire monitoring and alarm system with IoT which was implemented for industry and home. Temperature and gas sensors will detect the presence of fire and send the results using a GSM network. The smart security system built in this study is still limited to fires. Other research has been carried out to develop a forest fire detection and monitoring system using Zigbee and GPRS [10]. Sensors used to detect fires are temperature and humidity sensors. The network is built in the form of long distance communication via Zigbee and long distance communication via the GPRS network. The network used on this system is GPRS and has not used IoT.
Utilization of speech recognition technology is also used to support the development of smart home systems by exercising control of home appliances using voice commands. Chan Zen has conducted research to create a smart home system that is controlled by voice commands [11]. The system is built by utilizing the Telegram application, the Alexa Voice Service, and the Amazon Developer Console which is integrated with equipment control and home security. Home security referred to in this system is the existence of voice control can ensure to lock and open the door automatically. Control of household appliances can also be done by voice commands with iOS [12]. The voice command given will be matched with the voice template given, and if appropriate the voice command will be used to control the electronic device.
Sradha has conducted research for home security monitoring systems and home appliance automation using IoT [13]. Home security is done by monitoring using PIR sensors, gas sensors, temperature and humidity sensors. Added a camera to record the captured object. The system will give a signal if something is not desired and also with an alarm that sounds. Equipment automation is done remotely with the buttons provided on the Android application device. The developed system is not yet possible to automate devices with voice commands.

Method
This research focuses on developing smart home automation and security systems. The smart home security system is focused on monitoring fire and theft by installing sensors and cameras connected to the Arduino microcontroller, data storage unit, LCD viewer and IoT ESP8266 device. The sensors used in include DHT22 temperature and humidity sensors, magnetic door switch sensors, HC SR501 PIR motion sensors. The camera used to capture images is the VC0706 serial camera that is connected to the MicroSD card storage module. Data processing in the form of Arduino Mega 2560 microcontroller module which is connected to the input and output system.
Smart home automation in this study focuses on the use of voice recognition technology by giving voice commands. The difference between voice recognition and speech recognition lies in the subject that it analyzes. Speech recognition emphasizes the analysis of spoken text, while speech recognition requires analysis of the voice of the speaker and the spoken text becomes the second analysis to be used together [7]. Voice commands are recognized by using an Android smartphone device that is installed by Google Assistant which is then integrated with the IFTTT application, Adafruit.io and the IoT NodeMCU + ESP8266 device.
The system is designed and implemented into three parts namely the hardware part, the software part, and the application part. The hardware part consists of the DHT22 temperature and humidity sensor module, the HC SR501 PIR sensor module, the magnetic door switch, the Arduino Mega 2560 module, the ESP8266 module, the NodeMCU + ESP8266 module, the 16x2 + I2C LCD module, the VC0706 serial camera module, the relay module, the SD module card, mini buzzer, and power supply module. For software in the form of Arduino Integrated Development Environment (Arduino IDE). The application part consists of the IFTTT application, the Adafruit.io application, and the Thingspeak application.

a. Hardware section
The hardware part of the system consists of modules and components used for the design and implementation of a smart home security system with remote control based on voice commands and the internet of things. The overall system hardware design is shown in the block diagram in Figure 1. The system hardware part generally consists of three parts, namely the input part, the process part, and the output part. The input part consists of sensors mounted on the system, the process part is an Arduino microcontroller and the IoT module unit, and the output part is a viewer and relay.
The hardware input part of the smart home security system Smart home security systems have hardware that acts as a temperature and humidity sensor, motion sensor, and image capture sensor. DHT22 is a module used for temperature and humidity sensors of smart home security systems. Two DHT22 are used which have the same function but are only placed in different locations. Based on the specifications, DHT22 uses a 5VDC voltage, has a digital output signal, can measure temperatures from -40 to 80¬oC and humidity from 0 to 100% RH [14]. Both DHT22 one and two are directly connected to the Arduino 2560 data processor. The physical form of the DHT22 sensor is shown in Figure 2.
The motion sensors used in this system are magnetic door switches and PIR motion sensors. The magnetic door switch functions to connect and open the electricity when the door is closed and opened. This switch consists of two magnets that can be passed by voltages up to 100V at 500mA. The switch will close if the two magnets are attached and the switch will open if the two magnets are separated [15]. Physically the shape of the magnetic door switch looks like in Figure 3.
PIR motion sensor is used to detect the motion of an object by measuring the level of infrared radiation produced [16]. Humans who have body temperature will emit radiation in the form of infrared waves that cannot be captured by the eye, but can be captured by electronic devices namely PIR sensors. This principle used in smart home systems is to detect the presence of strangers who enter the house. One of the most widely used PIR sensors is the HC-SR501 PIR [17]. Physically the shape of the HC-SR501 PIR looks like in Figure 4. A serial camera is installed to capture the object after it has been detected by the sensor and then the results will be saved in Micro SD. The serial camera used is VC0706 which has the ability to image acquisition and processing applications. Communication interface for photos and data is done with UART on the serial port. This camera is specifically designed for surveillance so that the resolution is not high only to a maximum of 640x480 pixels and sensitive to infrared light [18]. The VC0706 camera is seen in Figure 5. The hardware process part of the smart home security system The processing part of this system uses two modules, Arduino Mega 2560 microcontroller and NodeMCU + ESP8266. Arduino Mega 2560 is used to process data from sensors and the results will be displayed on the LCD, Micro SD Card, and ESP8266 for communication with IoT. NodeMCU + ESP8266 is used to connect IoT in the form of data from voice commands to the relay module to turn lights on and off.
Arduino Mega 2560 is a microcontroller module based on ATMega 2560 which has 54 digital I / O pins, of which 15 pins can be used as PWM outputs, 16 pins can be used as analog inputs, and has 4 UART for serial communication. This Arduino is also supported by the presence of a 16 MHz crystal oscillator, USB connection, power supply jack, ICSP header, and reset button [19]. The arrangement of pins on the Arduino Mega 2560 is shown in Figure 6. The connections of each pin on the Arduino Mega 2560 with other hardware parts in this system are in accordance with Table 1.
NodeMCU + ESP8266 is a microcontroller that is equipped with a WiFi module ESP8266 so that it can communicate with the internet. NodeMCU has several features including GPIO, I2C, UART, ADC, PWM, and WiFi. NodeMCU also has a memory capacity of 4 MB and although it is small, it is sufficient for a small system implementation [20]. The arrangement of pins on NodeMCU + ESP8266 is shown in Figure 7    The connection of each pin on NodeMCU + ESP8266 with other hardware parts on this system is in accordance with Table 2.

The hardware output section of the smart home security system
The hardware output part of this system is used to display and store data from sensors installed on the system. The hardware used as the output of the system is I2C 16x2 LCD, SD Card Module, and Relay.
LCD as a data viewer that is widely used in microcontroller programming has many character sizes provided as needed. Generally LCDs have data pins, power supply controls and display contrast regulators [21].
One LCD that has a size of 16x2 (16 columns and 2 rows) is the M1632 LCD. This LCD hardware has 16 input pins, so it will require a lot of I / O pins when connected to the Arduino or NodeMCU data processing module. I2C is a solution to minimize the use of I / O pins on the LCD M1632 when it interfaces with the data processing module. One type of I2C is I2C LCM1602 which has 4 input pins and 16 output pins. If I2C is connected to a data processor it only requires 2 pins, namely SCL and SDA, while VCC and GND only need to be connected to the + 5V voltage source. I2C output just need to be connected with the LCD in accordance with the names of the pins listed. Figure 8 and Figure 9 are the 16x2 and I2C LCD displays.  MicroSD card adapter module or more easily called a microSD card module is a Micro SD card reader module, through the file system and SPI interface driver, MCU to complete the file system for reading and writing MicroSD cards [22]. This module is suitable for various applications that require data storage media, such as attendance systems, queuing systems, and other data logging application systems. Micro SD cards are memory cards that are generally sized 11 x 15mm, with various sizes of capacity used for data storage and reading data that is already in it. The physical form of the micro SD module is shown in Figure 10.
The relay functions as a switch that is controlled by electricity in this system to turn off and turn on the lights based on voice commands. The system uses a 2 channel relay module with currents up to 10A at a voltage of 250VAC or 30VDC [23]. Because the lights controlled in this system are only three, there is one relay that is not used. The control pin for this relay is from the NoeMCU + ESP8266 module. The 2 channel relay module used looks like in Figure 11.

b. Software section
The software used in making the C ++ program is the Arduino IDE which is a freeware that can be downloaded for free through the official Arduino website. This software is used to write programs on Arduino Mega 2560 hardware and NodeMCU + ESP8266.  The flow chart for designing software on smart home security using voice commands and internet of things is divided into two parts, namely the flow chart on Arduino Mega 2560 and the flow diagram on NodeMCU + ESP8266. As for each system performance flow chart looks like in Figure 12 and Figure 13.
Software design begins by designing a program for Arduino Mega 2560 devices that is used to process data coming from door switch sensors, PIR, DHT22. Data from the DHT22 sensor will be displayed on the LCD and Thingspeak server via IoT ESP8266 which is also installed on the Arduino Mega 2560. The program is designed when there are objects that are simultaneously detected by the PIR sensor and the magnetic door switch will instruct the camera to capture images and store them on the MicroSD module card.
The next software design is the design of the program on the NODEMCU + ESP8266 device which is an IoT device that will function to switch ON / OFF the three lights using voice commands received through the Google Assistant device. MQTT connections on NodeMCU + ESP8266 will be connected to the Adafruit io application.

c. Aplication section
There are three applications used in this system, namely IFTTT, Adafruit.io, and Thingspeak. IFTTT (If This Than That) is an applet that can be filled with certain inputs with the desired output. Input here is a voice command connected to the Adafruit io device to turn on and turn off the lights. The voice command design written on IFTTT to turn on and turn off the lights is shown in Figure 14. While all the voice commands used in this system to turn on the three lights are in accordance with Table 3. The second application is Adafruit Io which is used for communication with IoT hardware which contains commands to turn off and turn on lights in the hardware design. In this application, three switches are designed that can be controlled using voice commands connected to IFTTT. The design of the Adafruiot.io application for controlling three relays is shown in Figure 15. Note that Relay 1 is not used in the system.  The third application is Thingspeak in the form of a webserver that functions to display temperature and humidity data from two DHT22 sensors connected to Arduino Mega 2560 and ESP8266. The design of the temperature and humidity display system in the system is shown in Figure 16

Result and Discussion
The results of the study were based on an evaluation of the performance of the system implemented in the form of a prototype miniature smart home security system and control of the automation of smart home devices using voice commands. Various experiments were carried out to test the system both from sensor performance, the object captured by the camera stored on a MicroSD card, the sensor display on the LCD and the IoT Thingspeak application and the connection of the IoT ESP8266 module to the server. The implementation of the whole system is shown in Figure 17.
Voice command experiments are carried out by giving different speaker voices (male and female) with different voice commands based on variations of the speaker's mouth distance with a microphone that has an Android smartphone (Samsung J2 Prime) installed by Google Assistant. The experimental results are analyzed based on the responses generated by the resulting system performance. The voice command on Google Assistant starts with the initial command "Hi, Google" and after that is followed by the next voice command, for example the command to turn on light one, lamp two or lamp three.
The test is carried out to determine the system's functionality to be able to turn on and turn off each lamp based on the voice commands given by varying the distance between the speaker and the microphone on the smartphone. The voice commands tested follow the voice commands in Table 3. with two speaker voices (male and female) with a maximum microphone spacing of 50 cm with different volume. The test results will be known whether the voice commands with different speaker voices and different distances make the system continue to work well to turn on and turn off the lights. Table 4 is an example of the test results for the "On Lamp One" voice command on lamp 1. Table 4. shows that the voice commands given from both speaker 1 and speaker 2 with a maximum distance of 50 cm get a 90% success rate. This means that the system is able to respond well to the voice commands given from each speaker with a maximum distance of 50 cm from the speaker with a microphone.
The same test is carried out for other voice commands in accordance with Table 3 and the results are obtained based on the level of success of the system to respond to the voice commands given by each speaker with a maximum distance of 50 cm as in Table 5.   Based on Table 5. shows that the success rate of the system from speaker 1 is 92% and speaker 2 is 84% of the 18 voice commands spoken at a maximum distance of 50cm. The overall overall success of the system from testing voice commands is 88%, so the voice recognition system using Google Assistant which is implemented to turn off and turn on three lights can run very well.
The test results on the DHT22 sensor to measure the amount of temperature and humidity are done by observing the results of the temperature and humidity display in the Thingspeak application and also the results of the display directly on the LCD. The results of observations of temperature and humidity measurements displayed by Thingspeak from the two DHT22 sensors are shown in Figure 18.
In this study, the use of Thingspeak is only to observe the performance of the sensor to read the magnitude of the temperature and humidity, and does not give an indication of a fire. The temperature and humidity readings from the DHT22 sensor that appear on Thingspeak have shown that the system has worked to read data and display it online on the Thingspeak application.
The performance testing of the catches of the two VC0706 serial cameras is done by giving a trigger to the PIR sensor pair and the door switch. The camera will capture images if the door switch and PIR are active. The results of this object shooting will then be saved on the MicroSD card module. If one of the two sensors is inactive then the camera will not take an image and do not save the image. Table 6. shows the results of the test shots on camera 1 and camera 2.  Table 6. shows that from the system testing for capturing images of objects carried out by the VC0706 serial camera will only run if both the magnetic door switch sensor and the PIR are active. if one of the two sensors is inactive then the camera will not shoot the image. The test results show that the system has worked following the desired workflow.

Conclusion
We have implemented the system design to carry out monitoring and control of smart home security using voice commands and IoT. System implementation consists of hardware, software, and applications that work side by side to measure temperature and humidity. Measurement results are monitored online through Thingspeak. The system can also control lights on and off using online voice commands and Google Assistant. Finally, the system can take pictures of moving objects and store them into a MicroSD card. Accuracy testing using voice command shows a success rate of 88%, which means that the system is very suitable for controlling devices in a smart home security system.
Further works are needed to enhance the performance of the system because it has not been able to transmit camera shots online or give a warning in the case of temperature rise that may indicate a fire. Such improvement may be created by adding a device to send alarm data in an image or text format through e-mail or short messages.