Development of Smart Earth Leakage Circuit Breaker Using IoT and Power Electronics

The Smart Earth Leakage Circuit Breaker research is based on IoT& power electronics-based protective switchgear for domestic consumers for the protection against earth leakage faults. In this paper, we have shown how to create a custom web server using HTML and CSS language and hosting this webserver to ESP module using Serial Peripheral Flash File System (SPIFFS). Along with protection against earth fault it provides, controlling of tripping current or fault current, monitoring voltage, power, current, power factor parameters of the connected load, monitoring fault parameters, Indicating the device status whether the ELCB is on or off, and the condition of ELCB it is in faulty condition or healthy condition and to let the user set the value of the tripping current on the webserver at which the ELCB must trip.


Introduction
Earth Leakage Circuit Breakers (ELCB) are very much essential for the safety of human beings in residential as well as industrial premises. The significance of ELCB for home installations is elaborated in [1]. This is the era of technological revolution and the "Internet of Things" (IoT), so using IoT we can make our existing devices smarter and better with advanced features and enhanced protection that is what Smart ELCB is all about. It will be a smarter device and user-friendly compared to an existing system and one can easily operate it [2]. This paper is focused on building a unit of Smart Earth Leakage Circuit Breaker (Smart ELCB). This ELCB will show the status of the ELCB device whether it is on or off, ELCB will provide the tripping function when the earth leakage fault is detected, it will also monitor voltage current and power on a web server or our monitoring medium.By using the parameters measured by the Wi-Fi module the limits of the tripping current can be set in mA, which will be measured continuously as long as the control circuit is powered on. This control circuit takes power from the SMPS circuit which converts 230 V to 5 V DC and provides this supply to the ESP module and energy metering chip to measure the energy and control parameters [2]. These parameters are shown on the webserver using the "GET POST" method for the asynchronous web server.
The earth leakage current beyond 30mA causes the death of the electrocuted human. Although the range from 10mA-30mA has a fatal effect on people's life. So the sensitivity of such currents is Following are the working of the components used in the smart ELCB module. MCB: -Miniature circuit breaker used with ELCB to protect not only from earth leakage currents but also from the short circuit. Triac: -It is used for switching purposes, It is a three Quadrant Triac which is controlled by MOC3021 Optocoupler and ESP8266 microcontroller, The port pin sends the gate signal so the Triac is fired and the load is turned on, It is controlled by online web server user. 3 SMPS: -The power supply circuit for the control circuit to enable the controlling of the ELCB takes the mains supply directly to keep the control circuit turned on to detect whether the device is on or off. ESP8266: -It is the heart of the control circuit. The monitoring of energy parameters, control parameters, remote controlling, and hosting of the webserver, is achieved through this device only. HLW8012: -It is an energy monitoring chip used for the measurement of energy parameters, which gives the output RMS value of the current, voltage, power and power factor of the connected load. Optocoupler: -It is used for providing isolation between Triac and ESP8266. Also, it delivers the signal from ESP8266 to Triac to operate it safely. Core Balance Current Transformer (CBCT): -whenever the fault appears the CBCT secondary provides a proportional signal for the detection and measurement of fault.
To measure the amount of fault current flowing from primary we are connecting the CT secondary terminals to the A0 and GND which will read the proportional values of the fault current.

Implementation Methodology
The Smart ELCB module discussed in this paper works on the Asynchronous web server through which the controlling, monitoring and switching of the load are done. The web server is hosted by the ESP8266 module which is used in the control circuit of the ELCB [3].
The ELCB also measures the fault current by the use of CBCT secondary terminals and it is calculated by the ESP8266 module. This module calls the required function whenever the Client Request to the server is given. By the GET POST method, the Values calculated by the HLW energy metering chip and CBCT sensors are provided on the webserver for monitoring purposes.

3.1IoT based communication
Here, we are using the ESP8266 WiFi module as the medium for our IoT communication. This module will work as a controller of the device as well as a communication medium to communicate with the webserver by which we are operating the ELCB and connected loads can be controlled simultaneously [9]. So basically, we are using IoT communication for operating, controlling, and monitoring ELCB so we can easily handle our device [3].

Figure 2.Physical Demonstration of IoT based smart ELCB
The above image in figure 2 shows the physical demo of smart ELCB, to study IoT based communication we must understand the basic components used in it as per the block diagram the circuit contains all the above-mentioned components of ELCB although, the main component used is ESP8266 asynchronous web server library and ESP async TCP library to setup the asynchronous webserver.

3.2Creation of web server and its application
The asynchronous web server from the library provided by Random Tutorials here ESP async libraryis used. As we have used this we can connect more than one connection at the same time, To use this library just include this library with other important files to be included for the webserver like File system library FS.h, This library will help us to serve the HTML indexes and the CSS file for desired sheet styling as per our web server. Then ESP async TCP library is utilized for arranging the data in such a fashion which allows the safe exchange of data between the server and client without disturbing or leaking the data [3]. After using these libraries we can successfully set up the webserver on our ESP module.
First, we have to select the port for the webserver to which the IP address will redirect the user, and the HTML, CSS, and JS file will be served at the same port for which the webserver is hosted this can be done by command: -AsyncWebServer server(80);

Figure 3.Web Server Request handlers
We have to give the requests for giving the input to the web server as shown in the image in figure  3. These requests are called request handlers. The first request is to provide the index file for the webserver which is an HTML file, then we are adding CSS files and corresponding requests for images, data are given to the web server these requests provide required data to be shown on the webserver for real-time monitoring of parameters and these parameters are taken from the sensor nodes explained further in this paper. Finally, after the creation of the backend process of getting data, these data will be available to the remote web server and hosted on the ESP module whichever device will connect with these ESP will be able to access this web server on a particular IP address.
The server.on request is required to communicate with the webserver by using a microcontroller, the request contains "/URL to be redirected" for the execution of a particular function in that URL, a method to get the data "HTTP_GET", and a server request function "AsyncwebServerRequest*Request" which serves the purpose of accessing the data at that particular URL. Similarly, Request handlers use SPIFFS to get the HTML, CSS file as per figure 3.

Use of serial peripheral flash file interface: -
The serial peripheral interface flash file system (SPIFFS) is used to serve the HTML and CSS file to the webserver by the request handler. These files are contained in the flash memory of the ESP8266 chip and are used whenever the requested function value is required by the webserver for example if the HTML index is required by IP address to redirect it to the HTML file then this HTML file will be included in the flash memory of chip and the insertion of these outer files to the flash memory of the ESP8266 will be done using the FS.h library, this is not enough to work along with library we will need to use the spiffs installer for the ESP8266 which can be obtained from here [spiffs installer]. Once this installer is installed, sketch data is uploaded from the particular data folder which contains necessary files, icons, and other files to use for the webserver.

Data monitoring to the webserver: -
We send the measured parameter values of the energy meter to the web server using HTML, JAVASCRIPT, and REQUEST HANDLERS [2]. The HTML code stores the processor values which are updated by the Sensor values or parameters and then by the use of javascript we are calling the function to give the output on that particular processor of data to be stored and finally when we send the request handler to the Async web server it gives us the particular value of the parameter on the webserver [9]. As explained in the above figure 4, the data from the sensor is given to the variable processors that are used in the main program as shown below and then it is linked to the HTML code with the help of the same processor functions and when the value is being extracted the same processor gives out the Value of sensors and the HTML web server is updated with new values. The function "getvoltage ()" as shown in figure 5 gets the RMS value of voltages from the energy meter chip with the help of HLW8012.get voltage function, It returns the output in string form to display on the webserver, the function "getvoltage ()" is also a string, this is because the use of placeholder value in HTML file is done as string form only, that's why each parameter is considered as a string.   So as we have shown above 3 parts of code in figures 5 to 7, to send the sensor value from sensor to webserver, here we have shown just one value of voltage parameter. First, we are getting the voltage parameter by using HLW8012.getvoltage for the HLW8012 sensor which will give us the RMS voltage value. Then we are storing that function's output, which is the actual voltage value, into the place holder created in HTML where the voltage value will be given to HTML id and used as particular data for HTML file for webserver, and then finally we are requesting to send the data to the webserver by get method as shown above in figure 7.

HLW8012 Energy Monitoring
Chip: -To choose the compact, accurate, reliable, and effective energy metering chip to be used in smart home devices and automation devices this chip HLW8012 is considered as the best option [11]. This chip interfaced between power mains and the connected load, and according to the block diagram, it is used after the Triac of smart ELCB, so the connected device will only show the readings whenever the Triac is turned on and after that only the chip will give the output, the pin diagram of the chip is shown in figure 8 [6].

Figure 8.HLW8012 pin diagram
The chip gives out square wave pulses proportional to the main power input, voltage, and current. The datasheet of the chip contains information about the chip output measurement as the frequency function, like for 12W active power the output pin frequency is 1 Hz and for computation of voltage and current, the SEL pin is regulated high and low, if the SEL pin is high the voltage output will be observed from the CF pin of the chip and if the SEL pin is low current output will be observed. For 0.5V or 15mA 1Hz, proportional frequency is generated. With the use of these data along with the modified calculation and programming this chip can be easily used for energy monitoring, the basic code for the working of this chip is from HLW8012code this repository.
By the use of the computation and data processing from this chip, as shown above, the energy parameters are sent to the webserver.

Final data monitoring on the webserver: -
The following image in figure 9 shows how the data monitoring and controlling is working on the actual web server that we've been implemented as in previous sections. As we can see there are the customization index logos and tables arranged and editable HTML file used with CSS file which improved the visibility of the custom webserver. Actual data upload during the snapshot can also be shown in which energy parameters and control parameters show the real-time data of the load. The tripping current limit is set to 30mA and the ELCB state is on hence condition is "NO FAULT". Also,some fault current value is shown, the "maximum fault current" is the value of the leakage current flowing during the entire operation of the smart ELCB.

Data Updating to the webserver
To get the real-time data from the sensors continuously and Serving them on the webserver for monitoring purposes we need to use some Data updating techniques to continuously monitor the realtime data from the sensor readings which shows the accurate operation of the device in terms of reliability and use of it [3]. As we have used a customized webserver we can use two techniques for data refreshing to web server [8].
Adding HTML script to reload the page: -In this method, the meta request method is used to reload the whole page after a given time the meta tag is used as shown in figure 10, but the limitation of this method is that while reloading the webpage or web server, each element of the HTML web server is updated as new and it may take time due to loading of elements which may mess up the data and customization, The main problem was with HTMLbutton elements, We have used ON and OFF buttons on the webserver whenever the button is pressed the action takes place, but when the page is reloaded the button automatically resets which was useless for real usage of this method and also this is the main reason to not using this method for data updating. Although it works fine if we have only Data string monitoring of the webserver. Using Asynchronous Java XML script: -In this method, JavaScript is used for updating each parameter, the main advantage of using this method is that a particular data set is updated, unlike the whole web page. This method uses a placeholder value which is provided by the ESP8266 code and when the given variable is provided with the value, the value stores it as a placeholder, This JavaScript requests a particular placeholder to get the latest reading from the sensor nodes, when it receives the value it updates HTML element with that placeholder id.
The image in figure 11 describes the data updating of the fault current value. As we can see the "maxfaultcurrent" placeholder is used to get the fault current value as well as updating the value. At the start, the function is defined for a particular id to store and update the value. The HTTP request for taking the latest data is made and after receiving the latest fault current value it is sent to the HTML id which will be the updated value of fault current. And at last, the amount of time is defined for how many milliseconds the value should be updated. Here 2000 i.e. every 2 seconds the latest value of fault current will be shown on the webserver. The same method is used for other parameters also to get the real-time data monitoring parameters. Figure 11.Javascript to reload maxfaultcurrent data 3.4.1 Customization of webserver: -Data accumulated by the webserver needs to be organized properly to make it easily understandable and easy to read. The web server used in this image contains logos, Custom styling sheets, various data tables, and parameters to display the actual reading of the particular load devices, The Parameters are divided into two tables energy and control parameters to show corresponding values of the connected load, This whole process is made possible due to table formatting, CSS, HTML elements and spiffs to interface these outer files and logos to the flash memory of the ESP8266.

Fault current calculation: -
Here, the fault current is measured from the secondary side of the CBCT. So, whenever the earth leakage occurs, we will get a proportional signal on the secondary side, and that we will use it as our input data to the analogue pin of the microcontroller, this signal will be very small in magnitude in terms of 40-50mV and it will be in the range of mA. Depending upon the connected burden resistor across Core balance CT terminals, the proportionality is obtained by standardizing this values with the help of multi-meter and then simply selecting the particular multiplier for accurate measurement of the fault current flowing in faulty as well as healthy condition [7]. The CBCT secondary terminal gives out the signal proportional to the fault current flowing through primary the samples are taken and measured in the microcontroller (ESP) and calibration is done.Samples are taken when themeasurement function is called in the main loop and the value of voltage is obtained by multiplying these samples with the appropriate multiplier value we get a range of the measured current value calibrated by the multimeter [7]. This method increases the processor time, through its effect is not seen visible but memory consumption increases and some modification should be done to have valid fault current calculation code.After this process the correct and accurate value of fault current is obtained and by use of HTML and JavaScript, we are sending these values to the webserver. The webserver layout is shown in figure 12.

Controlling Of Tripping Current Value
We are using the HTML slider using input as a range which will add the slider on our web server. This slider is storing the integer values from minimum limit 10 to maximum limit 30. By using the if loop to constantly monitor if the value of measured fault current is greater than the slider value then the ELCB switch must be stop hence tripping the load, if the value of fault current is smaller than that slider value the ELCB must auto reclose and the power is restored [8].

Figure 13.Earth Leakage Current Value Set Slider
As shown in figure 13, the method gives us the control to limit the tripping current value that when the ELCB should trip. Hence giving us control over the selection of fault current at which, ELCB should trip.
The slider value variables were not saved inside the HTML code due to which there was no update in the slider value on the webserver. After saving the values inside the parameter and updating the input message variable we converted the string input from the webserver to the int value after which we can successfully detect the tripping value and trip at a set value of current.

Switching Control
To control the switching of the ELCB, We have demonstrated the use of HTTP requests made by HTML elements which control the execution of a particular function when called upon, by this requests the webserver is redirected to the function containing the actual function to operate, hence in our case we have used the buttons elements and when these buttons are clicked on the client-side webserver the HTTP requests are made and the function inside this request that is to turn on or off the particular port of the ESP8266 microcontroller and when this port is controlled operation of Triac is controlled hence we can use this method for remote switching application of the smart ELCB [10]. Below, we have shown detailed components and usages to make this process more understandable.

TRIAC AS A SWITCHING DEVICE.
Various advantages of thyristor and TRIAC are explained in [5]. Because of the above all merits, we had chosen to use an electronic switch (TRIAC) rather than the mechanical component of ELCB. We disassembled the component from ELCB and connected TRIAC to it.
Bi-directional switching devices like TRIACs are used for switching functions in AC circuits. A positive voltage or a negative voltage can be used to trigger the TRIAC in the direction required. Thus, four different zones are possible for the operation of a TRIAC. At the starting of our project, we operated it on the 1st and 3rd quadrant but now we give MT2 the same supply to the gate because it is sinusoidal so, in other words, we used natural commutation for triggering our gate [6].  To start the Triac we have to give a gate signal then only the Triac will turn on so here we are giving gate signals from our microcontroller ESP8266 through 560Ω resistor to the Triac and controlling the operation of the Triac by controlling the signal of the gate. The circuit for this is shown in figure 14.
The neutral terminal here is taken as a reference to 5V and the gate supply is given through D6 pin and GND so that the Triac will operate in the 2 nd and 3 rd quadrant due to signal obtained during the actual LOW in the Port pin. The port pin now acts as active high.

ESP with Triac using Optocoupler: -
The Optocoupler is required mainly to interface between power and control circuit but in our case, we have to use it to protect the differentiation between reference terminals. The Optocoupler used is of MOC3021 series with diode main current rating 1.5V, and optical Triac ratings of 600V, 4A. As we are connecting our Triac to 230-240V supply and this high voltage will be dangerous to our controller so it is necessary to isolate our controller from this amount of voltage so here we are using an Optocoupler to provide isolation to our controller so it won't get damaged due to high amount of current or voltage. You can see the connections of that in figure 15 [12]. More details about Optocoupler used in the smart ELCB is discussed in further points.

OPTO-COUPLER MOC3021
: -A TRIAC can be used to drive the Optocoupler MOC3021 which has a zero-crossing detection capacity. The loads up to 400 V can be driven by the output driven by a TRIAC. AS TRIAC can conduct in both directions, AC loads can be easily controlled. The TRIAC will conduct as soon as the AC wave crosses 0 V. This helps in avoiding the injection of direct peak voltage on the load and thus damage is prevented. The sufficient rise and fall times help in controlling the output voltage. Thus, MOC3021 is a perfect choice to control the high voltage AC loads. The pindiagram of MOC3021 is shown in figure 16.

Figure 16. Moc3021 Optocoupler Pinout
As the current rating of the Optocoupler is limited, it cannot drive loads directly. A power electronicsbased switch, TRIAC is connected at the output. A TRIAC provides sufficient current required to drive the load. TRIAC is controlled by the Optocoupler. Figure 17 shows a circuit diagram wherein an AC bulb is controlled by a microcontroller along with an Optocoupler and TRIAC. The connection with the main load and the Triac is similar but the difference is of HLW chip in case of smart ELCB as per block diagram, the energy metering chip is interfaced between load and Triac else the connection is same as below, this connection can be used as a reference for use of Triac with AC load control with other loads also [13].

Result and Discussions
This section shows the final results and operational condition of the smart earth leakage circuit breaker as we can see there is an off and on condition of ELCB in both normal and fault conditions, the webserver snapshots are shown.

Normal OFF condition
When ELCB is in OFF condition we can see in figure 18 that the parameters on the load side are zero and the state of ELCB is also OFF and there is no fault condition because ELCB is in a normal OFF condition. And fault parameters will also be zero. When ELCB is in ON condition we can see in figure 19 that the parameters on the load side are as per the load connected on the load side and the state of ELCB is showing as ON. There is no fault condition because ELCB is in a normal operating condition. And fault parameters will also be zero because it is in no-fault operating condition [7]. When there is an increment in earth leakage current greater than 30mA the ELCB will turn OFF. ThenELCB is in fault condition we can see in figure 20. The parameters on the load side are zero because due to fault ELCB is trip and is in OFF condition and the state of ELCB is showing as OFF. And here we can see the value of fault parameters fault current and amount of maximum fault current.

Figure 21. Web server auto-reclosed
After the tripping of ELCB one will clear the fault as the fault will be cleared ELCB will be turned ON to normal operating condition automatically. We will be able to see the load side parameter again as per the load connected and the value of the current fault current is zero and the last maximum value of fault current will be stored which we can see in figure 21.

Conclusion
In this paper,the development of smart earth leakage circuit breakers for household applications is explained. The implementation is based on IoT, webserver interfacing, and parameter measuring to meet Smart ELCB features. The prototype is already developed and tested.
This ELCB contains an automated power restoration feature when the fault occurs. Further, it includes the feature of energy and control parameter monitoring. In which we can monitor or can see the values of load energy parameters like voltage, current, power, etc., and in control parameters, we can see the value of fault current and the maximum current value of which ELCB has trip last. And setting the value of fault current at which the circuit breaker must trip. And the range of this tripping value is from 10 mA to 30 mA.
For future work, we can make this experimental model of ELCB to the Domestic product, and by manufacturing; we can establish this device for housing protection application and commercialization.