Design and Build Wireless Relay with Electricity Monitoring Based on Internet of Things

Electrical energy is the power source needed to provide power to electronic devices. Switches are commonly used to control electronic devices, but the problem that occurs is that users forget to turn off their electronic devices, and vice versa. The next problem is that users can't monitor the electrical energy use of their electronic devices in realtime. The problems referred to in the previous statement can be overcome with an IoT system with a working principle like a switch, but inside the designed device has microcontrollers, actuators, sensors and other components. Users can control through main switch on the designed device, switch button and timer on Android application, realtime monitoring of the use of power, current and voltage of electronic devices is carried out through the Android application. The test results show that the Android application and tool design can control with a 100% success rate in each type of test, in the future adjustments of current monitoring need to be made so that the power monitoring results are better.


Introduction
Electrical energy is a resource needed to provide power to electronic devices, so electronic devices can't work if they're not get electrical energy. One of the ways used to turn off and turn on electronic devices is to use a switch. The problem that occurs when using a switch is forgetting to use it to turn off the electronic device, and vice versa so that electrical energy is not used efficiently and effectively. The next problem is that users cannot find out the use of electrical energy from their electronic devices in real time, where postpaid or prepaid electricity users can only see the numbers listed on the KWh Meter in their homes without being able to know the amount of power used by their electronic devices.
The problems referred to in the previous statement can be overcome by the existence of internet technology. IoT or internet of thing is a technology that is able to make a device JURNAL ILMIAH MERPATI VOL. 10 exchange data through the internet network, so the application of IoT is used to control and monitor electrical energy used by user electronic devices in real time. The working principle of the system built has similarities like a switch, but inside the designed device has microcontrollers, actuators, sensors and other components. Users able to control and monitor their electronic devices from anywhere through the Android application as long as the designed device and Android smartphone are connected to the internet. Researchers found research that has been done before, such as designing a system that can control and also displays the usage of electrical power carried out by Trisiani Dewi Hendrawati, designed to be used by users in an effort to make savings [1]. The difference lies in the use of the ESP32 DevKit v1 microcontroller board, 2-channel relay module and a ZMPT101B voltage sensor. Dolly Handarly previously designed a system that can monitor internet-based electrical energy designed to obtain information related to electrical energy measurements, including real power (W), voltage (V) and current (A) in realtime that can be accessed from the Internet Network at any time [2]. The difference lies in the use of the ESP32 DevKit v1 microcontroller board, 2-channel relay module and ACS712 current sensor. The Cayenne platform is used by Afandi Amir in the manufacture of a server system from the use of technology so that the switch can be controlled automatically and the power readings on the load are recorded and stored on a computer [3]. The difference lies in the use of the ESP32 DevKit v1 microcontroller board, ZMPT101B voltage sensor, ACS712 current sensor, 2-channel relay module and an Android smartphone.

Research Method / Proposed Method
This research has several stages of research starting from literature review, design of tool and systems, implementation and testing, conclusions and suggestions. A series of tool and system design processes from this research can be seen in the following explanations.

System Overview
System Overview is a discussion of the relationship of the designed device with supporting components outside the tool. The general description begins with the user's electronic devices connected directly to the designed device so that electronic device control and electrical power monitoring can be carried out, then the system is connected to the internet so that later controlling and monitoring data can be stored in Firebase Relatime Database and can also be displayed on the user's Android smartphone. Users can also control their electronic devices because the entire system gives and receives data to each other. System overview of this research can be seen at Figure 1.

Concatenation Analysis
Concatenation analysis is the determination of needs which is based from the results of the analysis of existing theories in the literature review used in research. All tools and materials listed in Table 1 are used to make only 1 designed device.

Block Diagram
Block diagram is the first step in tool design. The power from the AC power supply is connected first to a 2A glass tube fuse, then the electric power is divided into 3 lines to provide power to the designed device (SmartRelay), electronic devices A and B. The first line goes to the switch + 3 pin LED indicator which is used to disconnect, connect and the electric power indicator to the designed device, then the power from the AC power is converted first using an AC 220V to DC 5V converter in order to provide power to the designed device. The second line goes to the 3 pin hotel switch which functions as the main switch A (manual control) and continues to the 2 channel relay module (digital control), where these two components are used to disconnect / connect electrical power to electronic device A. Current sensor A ACS712 and voltage sensor A ZMPT101B are also connected on the second line so that the current (A) and voltage (V) data of electronic device A can be read and sent to the ESP32 DevKit v1. The switch + 3 pin LED indicator is used to disconnect, connect and AC voltage indicator is placed between the current sensor A and the voltage sensor A, then proceed to electronic device A. The third line goes to the 3 pin hotel switch which functions as the main switch B (manual control) and continues to the 2 channel relay module (digital control), where these two components are used to disconnect / connect electrical power to electronic device B. Current sensor B ACS712 and voltage sensor B ZMPT101B are also connected on the third line so that the current (A) and voltage (V) data of electronic device B can be read and sent to the ESP32 DevKit v1. The switch + 3 pin LED indicator is used to disconnect, connect and AC voltage indicator is placed between the current sensor B and the voltage sensor B, then proceed to electronic device B. ESP32 DevKit v1 used to process data sensor reading so it can be sent to Firebase Realtime Database via internet network. User can see the results of monitoring the current, voltage, power of electronic devices A and B through an Android smartphone. Users can also control their electronic devices manually using the main switch or digital control using an Android smartphone. Block diagram of this research can be seen at

Schematic Design
The schematic is the result of a more detailed translation of the block diagram that connects the components. Figure 3 explains that the AC mains supply first enters the designed device through the terminal block. The incoming AC electricity is used to provide power to the designed device and electronic devices A and B. The electronic devices can be connected to the designed device by connecting them through the terminal blocks of electronic devices A and B.

Hardware Design
Hardware design is the design stage of the container from the designed device so that later it can help protect all the components in it and add to the aesthetic value. The hardware design is in the form of a x6 project box and has 4 bolt holders to make it easier to install / remove the lid. The hardware design is made as concise as possible, but can accommodate all the components used. The researcher determines the size of this hardware design with a length of 18.5 cm, then a width of 11.5 cm and a height of 6 cm. The hardware design of this project can be seen at

Mockup Design
Mockup design is the creation of the initial design of the user interface in order to make it easier to read the information and control to the designed device. The user interface display is made simply by prioritizing the user's ergonomic value, which is basically divided into 5 displays that can be seen at Figure 5

Literature Study
Literature study contains several supporting theories. The researcher cites some of the literature needed in this research. Excerpts of the literature contained are obtained from books and scientific journals.

Power
Power is the amount of change in energy with time in quantity of voltage and current. Watts absorbed by load at any time is the product of the instantaneous voltage drop between the instantaneous current flowing in the load in amperes and the load in volts [4].

Active Power
Active power is the power that used to do actual energy. The unit of active power is called Watt. For example heat energy, light, mechanical and others. The active power can calculate using the equation of P = V. I. cos φ [4]. Active power can calculate with the equation of P = V. I in 1 phase electricity because cos φ in 1 phase electricity is 1.

Reactive Power
Reactive power is the amount of power required for the formation of a magnetic field. From the formation of a magnetic field, a magnetic field flux will be formed. The unit of reactive power is called Var. Reactive power can calculate with the equation of Q = V. I. sin φ [4].

Apparent Power
Apparent power is electrical power through a transmission or distribution conductor. This power is the result of multiplying the rms voltage and rms current in a network or the power which is the result of the sum can calculate with the equation of S = V. I [4].

Internet of Things
Internet of things (IoT) is a technology that uses the internet to control and communicate with various other devices. The purpose of IoT is to expand the benefits of continuously connected internet connectivity [5]. IoT has the main purpose of communicating with devices such as actuators, RFID and sensors through wireless communication such as NFC and Wi-Fi [6].

Android
Android is one of the operating systems on Linux-based mobile devices consisting of an operating system, middleware, and applications. Android is an open source platform making it easier for developers to create an application. Google Inc. buy Android Inc. and is a newcomer to software development for smartphones. Android applications can be developed using the Android Studio IDE, where the programming language used is JAVA or Kotlin. Android is a mobile operating system that is increasingly popular and in demand by the general public [5].

3.4.
Arduino IDE Arduino IDE is software that is used to develop programs, compile them into binary code and upload them to the memory contained in the Arduino. Arduino IDE can program Arduino-compatible modules such as sensors, displays, drives, and so on [7]. Arduino IDE is usually used to program the memory in the microcontroller, one of which is Arduino. Arduino is an open source electronic kit specially designed to make it easier for everyone to develop electronic devices that can interact with various sensors and controllers [8].

3.5.
ESP32 DevKit v1 ESP32 DevKit v1 is a wifi module and the tools are made by DOIT. The component of this system is an ESP32 microcontroller which supports bluetooth, ethernet and Wi-Fi in a single chip with low power [9].

Relay Module
The relay module is an electronic component such as a switch that is operated with an electric current. The relay module is used as an AC motor control with a DC control circuit with a different voltage source between the load voltage and the control circuit voltage. Relay modules are needed in electronic circuits as executors as well as interfaces between electronic control systems and loads with different power supply systems [10].

Current Sensor
Current sensor is a module that detects an electric current (AC or DC) in a wire, and produces a signal proportional to it. ACS712 current sensor is a current sensor by utilizing the Hall effect made by a company called Allegro. This sensor is a current sensor that has a good level of precision for measuring AC or DC currents, for current readings in the industrial, automotive, commercial world and also in communication systems. The way this sensor works is that the current that is read flows through the copper cable contained in it which produces a magnetic field that is captured by the Hall Effect IC and converted into a proportional voltage [11].

Voltage Sensor
The voltage sensor is a module that produces a voltage value (Volt) from a singlephase reading. Voltage sensor calibration is carried out to determine the value of a voltage, and one way is to use a voltage divider [2].

Fuse
A breaker fuse is an overcurrent device with the fused part that can open the circuit (fuse link) which is heated and melted directly by the passage of overcurrent in the event of an overload condition or a short circuit. The purpose of the fuse is to eliminate permanent interference by disconnecting the disturbed part of the line or equipment from the system. The fuse is designed to fuse within the specified time for a given fault current rating [12].

Firebase Realtime Database
The Firebase Realtime Database is a data store and syncs in realtime into every connected client app. The application receive automatically if there is the latest data update. The design of database is not used in addition to new data in each field. Every time there is a data change, the old data is updated with new data [13]. Firebase stores data in NoSQL and stores data in the form of paired keys. Firebase also allows developers to use the Firebase Cloud Messaging feature [14].

Result and Discussion
This section describes the implementation and testing of the system, as well as analyzing the test results obtained. Implementation is carried out on the hardware and software side, then proceeds to stages of control and monitor testing and analysis. The discussion in this section can be seen in the following explanations.

Hardware Implementation
Hardware implementation is a detailed view of the designed device and installation to electronic devices, and this section also describes the flow. Explanation of hardware implementation can be seen at Figure 6.

Software Implementation
Software implementation is the display of the Android application that is used to control and monitor electronic devices A and B. Control and monitoring activities are carried out in realtime. Explanation of software implementation can be seen at Figure 7. Figure 7. Software Implementation Software implementation includes (a) the main display in this Android application has SAKLAR A button to enter the display of switch A, SAKLAR B button to enter the display of switch B, PENGATURAN JARINGAN button to display network information and configuration in the browser, and there is also the name of the network is connected to the designed device, (b) the display of switch A contains information on switch status, voltage, current, power, on time, and off time of electronic device A, in addition there is a TOMBOL SAKLAR A button which functions to turn on or turn off electronic device A, RESET TIMER A button to reset the on and off time of electronic device A, WAKTU NYALA A button and WAKTU PADAM A button to set the turn time on and time off of electronic device A automatically, (c) the display of timer setting A appears when selecting the WAKTU NYALA A or WAKTU PADAM A button, in this display there has hours and minutes that can be set in a 24-hour format, the Cancel button to cancel, and the OK button to save the electronic device A timer setting, (d) the display of switch B has a similar appearance to the display of switch A, the difference is used for controlling and monitoring electronic devices B, (e) the display of timer setting B has a similar appearance to the display of timer setting A, the difference is used to set the time on or off electronic devices B.

4.3.
Controlling System Result Controlling system result are obtained from testing by connecting the AC power supply, electronic devices A and B to the designed device, then the 2 channel relay module and 3 pin hotel switch function test were carried out. The component function test for controlling in this research can be seen at Table 2.

Analysis of Controlling System Result
Analysis of controlling system result is applied to determine the success rate of the control method used. The analysis applied is controlling analysis using the main switch, controlling using the switch button, and controlling using the timer. The experiment was carried out 60 times in each test. Controlling analysis using the main switch in Table 4 is carried out with 4 stages of testing, the first is the test to turn off and turn on the fan, the second is the test to turn off and turn on the lamp, the third is the test to turn off and turn on the water pump, and the fourth is the test to turn off and turn on the drill. All tests got perfect results, from 60 trials none failed. The success rate of the four tests obtained results of 100% and 0% failure rate. Controlling analysis using the switch button in Table 5 is carried out with 4 stages of testing, the first is the test to turn off and turn on the fan, the second is the test to turn off and turn on the lamp, the third is the test to turn off and turn on the water pump, and the fourth is the test to turn off and turn on the drill. All tests got perfect results, from 60 trials none failed. The success rate of the four tests obtained results of 100% and 0% failure rate. Controlling analysis using the timer in Table 6 is carried out with 4 stages of testing, the first is the test to turn off and turn on the fan, the second is the test to turn off and turn on the lamp, the third is the test to turn off and turn on the water pump, and the fourth is the test to turn off and turn on the drill. All tests got perfect results, from 60 trials none failed. The success rate of the four tests obtained results of 100% and 0% failure rate.

Analysis of Monitoring System Result
Analysis of monitoring system result is applied to compare the results of the voltage, current, and power readings displayed on the Android application with a digital watt meter. The comparison of the readings was carried out on electronic devices A and B with 10 minutes of testing time. Monitoring analysis electronic device A (fan) in Table 7 is that the voltage readings (V) produced by the designed device with a digital watt meter are almost the same, but the current (A) and power (W) readings from the designed device are still not close to the digital watt meter. Monitoring analysis electronic device B (lamp) in Table 8 is that the voltage reading (V) produced by the device design with a digital watt meter is close to, but the current (A) and power (W) readings from the device design are still not close to the digital watt meter.

Conclusion
The conclusion of this research is the designed device and Android application that have been built has been able to control and monitor electronic devices A and B. Users can control electronic devices A and B through main switch on the designed device, switch button and timer on Android application, realtime monitoring of the use of power, current and voltage of electronic device A and B is carried out through the Android application. The test results show that the Android application and tool design can control with a 100% success rate in each type of test, in the future adjustments of current monitoring need to be made so that the power monitoring results are better.