Smart Electrical Devices Control with Intrusion Detection Alert

The consumption of electrical energy always increases every year where one of the causes is lifestyle. A bad lifestyle such as forgetting to turn off the unused electronic devices when they are leaving home is one of the factors for increasing consumption of electrical energy which results in waste. This can occur because the device control system is still done manually. One solution to solve this problem is to implement a remote device control system. Several studies have developed a remote-control system but it is not equipped with features that can determine the condition of the device in normal or damaged conditions, so it is difficult to identify the success of the control. In this paper, an Internet of Things-based electronic device control system has been designed and built which is equipped with a device condition monitoring feature. Light, temperature, thermal and electric current sensors are embedded in the system to determine the condition of the device. The control test on the system was successful with an average response time of 3.32 seconds and the accuracy of sensor readings above 89%. With the implementation of this system, users can easily monitor and control electronic devices anywhere and anytime so that the opportunities for efficient and effective use of electrical energy can be further increased.


Introduction
A sufficient electricity supply is one of the most vital energy sources required to support various daily live activities of the current modern society. For the last several decades, the consumption of electrical energy has continuously increased every year throughout the world. The situation is quite similar of what happened in Indonesia for three consecutive years from 2017 to 2019, the amount of electrical energy consumption increased by 60 Watt Hours per capita [1]. There are numerous reasons that can lead to the increasing of the electrical energy consumption profile. The significant factors influenced the energy consumption were the highly consumptive and inappropriate lifestyles [2]. An inappropriate lifestyle appeared in terms of the electrical energy use such as forgetting to turn electronic devices off when they are not in use. The conventional technique applied to manage the actual operation of the most common electronics devices, to be turned ON and OFF status, are maintained through a manual control system. It means that users are physically activating or deactivating the devices through the direct contact with the power button of the particular device.
The application of the Internet of Things (IoT) as a solution to problems in various aspects of life has been implemented [3]- [10] and this can be a solution to the problem of using excessive electrical energy by building a remote electronic device control system. The system allows users to control electrical devices, real time, even though they are far locating from the device.
Several studies have been carried out for constructing a remote electronic device control system. For instance, an attractive remote control system had been studied by Alrikabi et al. [11] on designing the intended control system using the GSM communication protocol. Control commands are transmitted via SMS service to activate and deactivate the specified electronic devices such as refrigerators, air conditioners, celling fans, lighting, and water coolers. Meanwhile, D. Indra et al. [12] built a system for controlling electrical devices using a Raspberry Pi 2 via Wi-Fi communication. The testing results exhibited that the maximum distance to control the system using a laptop is 30 meters and using a smartphone is 20 meters. Furthermore, Eslam Al-Hassan [13] developed a controlled smart power socket to connect and disconnect the electric current to the stock contact via Zigbee communication. Another interesting research outcome was found in T. H. Nasution et al. [14]. A typical communication system for controlling electronic devices through relays using SIM 900 as GSM communication via SMS and Arduino as a microcontroller was successfully assembled. The operated remote monitoring and controlling system altered the relays activation and deactivation in parallel.
The electronic device control system can be equipped with a device condition monitoring feature with the aim of ensuring that the controlled electronic device is in normal condition and there are no obstacles in its operation. These might guarantee the control tasks could run properly. The studies that have been described previously only focus on designing and building the traditional control system. In this paper, an IoT-based electronic device control system has been designed and tested. Monitoring and control can be done remotely and in real time using an interface application installed on a smartphone. The system built is equipped with a device condition monitoring featured by placing light, temperature, thermal and current sensors. It is expected that by utilizing the implemented system, users can monitor and control electronic devices easily and can find out the condition of the device remotely in real time. The proposed technology enables the opportunity for utilizing the electrical energy management could be performed more effective and efficient.
The paper is structured as follows. Section 1 describes the background and related research activities. Section 2 discusses the research method. Section 3 explains in more detailed regarding the practical testing results of the proposed IoT-based electronic device control system and analyzes the experimental results recorded and Section 4 concludes the results obtained from this research.

Method
This section describes the design of the IoT-based electronic device control system architecture, the hardware and software used, as well as how the system is built. This section also describes the testing method applied in this study.

2.1
An architecture of the IoT-based electronic device control system The construction of this system uses four sensors that function to monitor the working conditions of the electronic devices operated. The first sensor is the light sensor. A light sensor is used to detect the light in the room and determine the condition of the room whether the lights in normal conditions or not. The temperature sensor is used to determine the room temperature value when the air conditioning (AC) is active and determine whether the AC is running normally or not. Furthermore, the thermal sensor is placed on the electrical socket to determine the temperature of the socket under normal conditions or in a state of excessive heat. The last one is a current sensor. It is placed on the cable to determine the value of the current being channeled on electronic devices. All the four sensors are connected to the microcontroller as input data where the data is forwarded to a web server via the Internet to be processed and forwarded to the user through an application installed on a smartphone. Users can control the active and inactive status of electronic devices connected to the microcontroller via the Internet. When the control command is received, the microcontroller will send instructions to the relay to connect or disconnect the current according to the instructions received from the microcontroller. Users can directly monitor information from sensors and control status provided and find out anomalies of electronic devices that are registered early. For example, when the status of the lamp control is active while the light sensor data informs that no light is detected so that users can conclude that there is damage to the lamp used. The architectural design of the system that has been built can be seen in Figure 1.

2.2
Hardware schematic configuration The hardware circuit designed is divided into 3 parts, where each part consists of a microcontroller. For more technical details see Figure 2. The system design uses two Wemos D1 Mini [15] as the main controller which is connected to each PZEM-004T module [16] as a current measuring sensor. One ESP32 [17] as the main controller to control three sensors, namely LDR [18] as a light sensor to measure light levels in the room, LM35 [19] as a heat measuring sensor placed in the electrical socket and DHT22 [20] as a sensor that measures room temperature. Relay 4 channel module [21] is connected to the ESP32 which is used to connect and disconnect the current on electrical panels, air conditioners, lights and electrical sockets that are not connected to electronic devices.

Software
The program listing was compiled using the Arduino Integrated Development Environment (IDE) [22] and then uploaded to the ESP32 and Wemos Mini D1. On the web server side, Firebase [23] is used to process data that has been received from the controller to be forwarded to the user and vice versa. Mobile application development on this system uses MIT App Inventor [24]. To facilitate the circuit design on the controller system, Diptrace [25] is used as an easy-to-use circuit design application.

Flowchart of the system
The microcontroller will always be on standby to read the value from the sensor and send it to the web server for processing. After the data is processed, the web server sends the data to the user's smartphone application to find out the status of the registered electronic device. The user sends instructions through the application which will be forwarded to the system controller, which then the system controller will give instructions to the relay to connect or disconnect the current according to the command data from the user application. The way the system works is done repeatedly until the system is disabled. For more details regarding the work flow of the system that has been built, see Figure 3.

Testing method
The system was implemented and tested in one housing unit with a data transfer speed of 72 Mbps. The test consists of three parts, namely the first part tests the control function, the second part tests the accuracy of the sensor readings, and the third part tests the response time value when controlling tasks executed. Explanation of the test model is explained in the points below: a) Control: Control testing is carried out by means of the user running the application installed on the smartphone and the user being away from home to provide instructions for activating and deactivating each test 10 times with a pause of each test for one minute. b) Sensor: Testing the accuracy of temperature sensor readings, light sensors, thermal sensors and current sensors was carried out 20 times reading data with a time lag of one minute for each reading. The reading results will be compared with measurement devices that have been commercialized to determine how much accuracy the sensor is using with the following accuracy calculation formula: (1) where the error rate formula used is

Result and discussion
After explaining the research method used, this section describes the results and technical discussions of the system performance. This section is divided into two subsections, namely (1) the results of the system prototype operation. This includes the hardware and software comprehensive examinations and (2) the results of the system testing that has been carried out.

Prototype system
The IoT-based electronic device control system prototype is built into two parts. The first part can be seen in Figure 4 which places the Wemos Mini D1 and ESP32 in one place. The Wemos Mini D1 is connected to four sensors while the PZEM-004T and ESP32 are connected to a 4 Channel Relay with the Sensors placed separately on the second side. Fig. 4. A typical IoT-based electronic device control system prototype Figure 5 illustrates the second part of the system which consists of an LDR sensor placed on the wall of the room and LM35 sensor placed on the branch of the cable which is also placed together with the Helex UX-389 sensor to compare the measurement results against the cable temperature. The DHT 22 sensor is placed under the air conditioner as well as the Helex UX-389 sensor to find out the comparison of room temperature measurements against the two sensors used. The application view depicted in Figure 6 has been constructed into two parts, namely the top view and the bottom view. The top section displays the status of connected household electronic devices. In AC, it consists of temperature value, current value, and switch condition. In the lamp there are parameters for the status of the lamp condition, the current value, and the condition of the switch, while on the stock contact there are parameters for the value of thermal, current and switch conditions. The system also monitors the electrical panel which consists of two parameter values, namely the current value and the condition of the switch. The condition of the switch in the application display is given the initials SW Condition. If the SW condition is one, the switch is on and if it is zero, the switch is off.

Testing results
Based on the test method described in section two, the test results are divided into five parts, the first is that the application successfully controls the lights and air conditioner through an application that has been installed on the smartphone 10 times, each in the off to on status and the on to off status. The results of the first part of the test can be seen in Table 1. The second part is shown in Table 2 where the test results show that the LDR sensor readings successfully detect the light conditions in the room, the DHT22 sensor successfully reads the temperature value in the room, the LM35 sensor successfully reads the thermal value from the cable and the PZEM-004T sensor successfully reads the current value from the electronic device connected to the number of tests of each sensor as much as 20 times. The third part of the results of the accuracy of the DHT22 sensor readings which was tested for 20 minutes by comparing the readings of the HELES UX389 [26], it was found that the DHT22 got an accuracy value of 95.78% and with the same model the test was carried out on the LM35 sensor with an accuracy value of 89.70%. The graph comparing the readings of the DHT22 sensor and the LM35 sensor with the HELES UX389 can be seen in Figure 7.
The fourth part, in Figure 8, describes the results of testing the accuracy of reading the PZEM-004T sensor in detecting the current compared to a commercial VIP3803 flow meter for 20 minutes. The result is that the accuracy value of the PZEM-004T sensor is 91.39%.
In addition to testing the sensor accuracy, the fifth part of the system is also tested in terms of response time. The test was carried out 20 times controlling with two different electronic devices, namely on socket 1 to connect and disconnect the current on the lamp with an average response time value of 2.8 seconds and for socket 2 on AC with an average response time value of 3.85 seconds. In the eighth test in socket 2, the longest response time was 8 seconds, and the fastest response time was 1 second for both sockets. The graph of the response time test results can be seen in Figure 9.

Conclusion and future work
An internet of things-based electronic device control system which fully equipped with the device operational condition monitoring Apps has been successfully constructed. The tests of control mechanism and sensor readings were executed for 20 times. The accuracies of all sensors installed are above 89% and the average response times are approximately 3.32 seconds. The proposed IoT monitoring and controlling system is equipped with interface application software. This can be installed on smartphones with the Android operating system to control and to monitor the condition of electronic devices and provide notifications to users if the device is damaged. Thus, it can be easier for users to manage electrical energy consumption and to perform regular maintenance of the electronic devices, effectively and efficiently. In the future, the control system can be developed into an automation system for controlling electronic devices with the aim of minimizing user negligence in controlling.