ESP32 Based Electric Energy Consumption Meter

: In recent years, the Smart Energy Meter has attracted a lot of attention from all over the world. In this paper a design and prototyping a low-cost IoT energy monitoring is presented, which may be utilized in a variety of applications such as power billing, smart grid energy management, and home automation. The system is based on a low-cost ESP32 microcontroller that is interfaced non-invasive Current Transformer (CT) sensors, and voltage sensor to get data from sensor nodes and deliver it to a Blynk server over the internet. The studies' findings showed that the system for monitoring energy consumption can precisely record voltage, current, active power, and cumulative power consumption.


Introduction
Electric energy use has surged in recent years. As a result, a large increase in energy supply was required. due to population growth and other factors in the coming decades development of the economy as a result, there is a demand-supply imbalance [1]. According to the current scenario, the power generated, which is mostly derived from fossil fuels, will be depleted within the next 20 years. Electronic energy monitoring solutions are currently available on the market that are extremely accurate. In the case of residential applications, the majority of these monitor the power utilized in a domestic household. Consumers are frequently disappointed with their power bills since they do not display the power used at the device level [2]. The Internet of Things (IoT) is a new sector, and IoT-based devices have ushered in a revolution in electronics and information technology.
Energy usage, particularly electricity consumption, is one of the most critical issues we face today. An effective technique to monitor this energy consumption is required [2][3]. The Internet of Things (IoT) offers a solution to these issues. Hardware, software, and the cloud are all interconnected. As a result, we offer an energy consumption model. Household appliance monitoring system that can be used to calculate energy consumption of the family and to keep the user up to date on his or her electricity usage and be able to make informed decisions [4].With the advent of Internet of Things (IoT) technology [5], an existing energy meter with an industrial communication protocol can be adapted to improve connection and observability of power and energy consumption. This can be accomplished by utilizing IoT technology [6]. As a result, this study presents an approach that incorporates IoT technology so that current digital energy meters in buildings can be modified to enable for online monitoring.

Existing Literature Survey
An IoT-based smart energy meter was developed by Kumar L using ATMega 328p microcontroller, voltage sensor, current sensor, ESP 8266 wi-fi chip and a SIM 900 GSM module [7]. The ESP 8266 sends data to the ThingSpeak cloud platform through the internet. When updating data to the cloud fails, an alternative solution is a 4G GSM module that sends data to the appropriate contacts as an SMS. The energy meter calculates the amount of energy consumed each hour using Fast Fourier Transform as well as the cost of that consumption. However, because the ATMega 328p is expensive, a low-cost microcontroller is required for use in smart meters.
Yaghmaee M developed a smart energy metering system that can be used in industrial and residential settings to measure how much energy each electrical device consumes and to control electrical appliances [8]. Sensor nodes, a gateway, and a server make up the system. Power consumption, power line parameters, and environmental variables such as gas leakage, temperature, and humidity are all collected by the sensor node. The data is sent from the sensor node to an Android HTTP gateway running on a Raspberry Pi 3.
The gateway connects to the Internet in order to send data to a central server. PIC microcontroller PIC16F877, CT sensor, and voltage transformer are used in a smart meter proposed in [9]. The meter regulates the energy supply and evaluates power usage depending on the load demand. Most importantly, this meter can calculate the cost of grid and solar energy consumption for settings that use both. Using NodeMCU with built in Wi-Fi chip ESP 8266 and a GSM module, Prathik M proposed the design and implementation of an energy monitoring system in [10]. This system provides daily power consumption of electrical equipment and manages the appliances, thereby saving energy. The electricity board section of the system informs customers about their bills, payments, and scheduled outages. If the consumer does not pay on time, the user is notified. If the customer does not pay, an alarm message is sent and the power to the remote server is turned off.
Visalatchi S designed a system based on Atmega328P. The system is leveraged by the energy meter for power theft detection and control [11]. When a fault is found, an algorithm is used to connect and disconnect the meter. The meter is connected to and unplugged from the Int. J. Comput. Commun. Inf., 23-35 / 25 utility devices using relay logic. The GSM module allows the central authority server and energy meter to automatically send SMS messages to the consumer.
A novel LDR-based method for monitoring the energy usage of an autonomous meter reading system is proposed in by Anirudh Kumar. It is impossible to modify or tamper with this energy because the energy meter belongs to the utility company [12]. Each AMR energy meter operates at a particular frequency, and the LED will either shine or flash for that frequency. This frequency is connected to the energy usage that was recorded on the memory card. The power consumption utilization factor is calculated using LED flashing. Through HTTP and the ESP 8266 module, estimated energy data will be sent to the server.
A Bluetooth-enabled energy meter was proposed for wireless reading in [13]. To obtain meter readings with minimal human intervention, the system employs automatic meter reading and an automatic polling mechanism. To develop a low-cost and dependable Bluetooth-enabled energy meter, a CSR Bluetooth BlueEZ module and an Analog Devices ADE7756 energy meter are used. Bluetooth has limited communication range hence cannot be adopted for long distance communication.
In Kaur M proposed an energy consumption monitoring system based on Arduino-Uno and Ethernet [14]. A user accesses the information using an IP addresss on their devices. However, this system requires a high initial installation cost. An Automatic Meter Reading system was proposed in, which consists of an external module that reads data from existing analog energy meters without the need for the energy meters to be replaced [15]. A WiMAX transceiver is used to send data from the meter to the server.
A system-on-a-chip (SoC) for energy monitoring and measuring with a revolutionary lowpower digital signal processor (DSP) architecture is proposed in [16]. The SoC based on Cotex-M0 can monitor electrical signals and tally both active and reactive energy. Additionally, it can monitor the grid by directly accessing and analyzing waveforms. Measuring and metering methods are implemented in a unique DSP architecture with fewer instructions. By virtue of the DSP's flexibility, the SoC can be utilized in applications with varying bandwidth and response time requirements. SoC achieves increased metering precision and reduced power usage.
Woong Hee Kim et al. suggested an energy management system that uses a ZigBee wireless sensor network and an intelligent home gateway to sense, record, and update electricity data in real time to enable real-time electricity consumption monitoring [17]. Information collecting, information processing, and information presentation are three technological components of the method. The system uses online and mobile interfaces to identify and operate electrical appliances.

Aims and Objectives
The following specific objectives support the main goal of this research study, which is to design a freestanding ESP32 electric energy consumption meter. The building blocks of the ESP32 Electric energy consumption meter is based on the ESP 32 as a heart Microcontroller receiving sensor data from the SCT-013 current transformer and Voltage sensor and relaying it to the blynk cloud servers. The SCT-013 is a non-invasive AC current sensor that measures up to 100 amps of AC current using a split core clamp meter sensor. Alternating current is measured by sensors called current transformers (CTs) [18]. They are particularly helpful for figuring out how much electricity a facility uses overall. The SCT-013 current sensors can be connected directly to the live or neutral wire, negating the need to rewire high-voltage electrical work. A current transformer is made up of a primary winding, a magnetic core, and a secondary winding [18]. The secondary winding is contained within the transformer's casing and is made up of several twists of thin wire.
Specifications for SCT-013 Current Transformer  A high-precision ZMPT101B voltage transformer is the foundation of the ZMPT101B AC Single Phase voltage sensor module, which is used to detect precise AC voltage [18][19].
With an Arduino or an ESP32, you can measure AC voltage quite effectively using this method. The analog output of the ZMPT101B sensor can be adjusted in response to the sensor's ability to measure voltage up to 250V AC. The module contains a multi-turn trim potentiometer for calibrating and adjusting the ADC output, and it is simple to use [18]. In the prototype, the voltage signal is being measured and sent to the ESP32 microcontroller.  The ESP32 family of system-on-a-chip microcontrollers are inexpensive and low-power devices that come equipped with dual-mode Bluetooth and built-in Wi-Fi [20]. The ESP32 series' Tensilica Xtensa LX6 dual-core or single-core, Tensilica Xtensa LX7 dual-core, or Tensilica RISC-V single-core microprocessors have integrated antenna switches, RF baluns, power amplifiers, low-noise receive amplifiers, filters, and power-management modules. Espressif Systems, a Chinese business with its headquarters in Shanghai, invented and created the ESP32, which is produced by TSMC using their 40 nm technology. [21]. The ESP 32 microcontroller is the prototype's brains.  It is an open source Arduino software that allows you to build and test instructions that compose a program or a sketch for Arduino boards [23]. It facilitates the writing of code. It's simple to use and allows you to upload sketches to the microcontroller boards. It is compatible with Windows, Linux, and Mac OS X [23]. Before designing the programming for the ESP32, various considerations were considered in this study. To begin, the ESP32 package has been added to the IDE. Secondly, an EmonLib and Blynk libraries has been added.

A. EmonLib Library
The Emonlib Library is utilized by Electricity Energy Meter. Every 5 or 10 seconds, EmonLib, a Continuous Monitoring of Electricity Energy, repeats a series of voltage and current measurements [24]. The voltage and current input channels are continuously measured in the background by EmonLib, which then determines a real average value for each channel and notifies the sketch when the measurements are ready to be read and processed.

B. Blynk libraries
The most popular Internet of Things platform, Blynk, allows you to scale up your deployed products, connect any device to the cloud, and create apps to control it [18]. More than 400 hardware models, including Arduino, ESP8266, and ESP32, can be connected to the Blynk Cloud using the Blynk Library. Users can control any IoT-based application using the Blynk application, which is available for both Android and iOS mobile devices. It enables users to create their own custom graphical user interface for an IoT application. The Blynk application will display data from IoT electric energy consumption meters in the prototype [18].

A.Circuit Schematic Diagram
The circuit schematic diagram's link is simple to understand. Both the SCT-013 Current Transformer and the ZMPT101B Voltage Sensor VCC are connected to the ESP32's 5V supply, Vin. The ESP32's GND is connected to the GND pins of both modules. The ESP32's GPIO35 is connected to the analog output pin of the ZMPT101B Voltage Sensor. The analog output pin of the SCT-013 Current Sensor is connected to ESP32's GPIO 34 in a similar manner. The voltage divider and filter circuit consist of a 10uF capacitor, two 10K resistors, one 100-ohm resistor, and two 10K resistors. The input AC terminal of the voltage sensor is wired with the AC wires that need to be measured for current and voltage. The current sensor clip is similarly unconnected, with only a single live or neutral wire is put within the clip as illustrated in figure 6 [18]. Figure 6. Circuit Schematic Diagram of Electric Energy Meter [18] Experimental Results The operation of the created ESP32 electric energy consumption meter in this section. The user-interface dashboard is displayed in Figure 9; the web dashboard of the sensor node was used as an example. Blynk app was used to generate the dashboards. The dashboard is made up of gauges that show the RMS voltage, current, and power utilized as well as energy consumed. The 16X2 LCD displays how the measured energy data changes over time. The sensor data was gathered and transferred to the blynk server from the energy sensor prototype.

A. Implementation Results
The implemented prototype outlines the Vrms to 246.82 V and Irms to 0.0067A displayed on the 16x2 LCD display. The energy profile of the light bulb was effectively Int. J. Comput. Commun. Inf., 23-35 / 31 captured in the energy monitoring system, as shown in Figure 7. It devoured, according to the widgets. As a result, this type of power and energy consumption exists. Tracking can be a highly valuable technique for determining the power and energy of a system in companies and households, consumption patterns of appliances or electrical machinery are studied and analyzed for decision making.

B. Serial Monitor Results
The sensor data comprising of Vrms Irms, Power and Energy consumption can be observed on Serial Monitor COM port 4 as from the ESP32 electric energy consumption meter using the baud rate of 9600.

Business Benefits
The business benefits of employing smart energy meters to the homes and businesses is quite vast. Esp32 electric energy consumption meters are connected to the blynk cloud system and take automatic readings of your company's energy consumption. This eliminates the need to manually take and submit readings [25,26]. The electric energy consumption process is fully automated, which saves time for households as well as industrial processes.
Households, factories and business entities may have a better understanding of their energy usage and track usage patterns with ESP32 electric energy consumption meters. This enables users to gain a better understanding of their electric energy usage and take the appropriate actions to achieve their objectives and also be able to connect whether those objectives are related to boosting energy efficiency or lowering corporate costs which in turn adds business benefits [27,28].

Conclusion and Future Scope
In today's smart world environment, the coexistence of many networks with different characteristics and energy efficiency is at the top of the list of hurdles to the realization of an automated ESP32 electric energy consumption meter. The architecture for the energy monitoring was outlined in this study. A monitoring system that is aware of both energy and power consumption. The proposed smart home energy monitoring system is automated. To collect sensor data and control the system, the ESP32 Microcontroller interfaced with the current transformer and voltage sensor where prototyped and the blynk cloud was used for retrieving sensor data to web clients.
The results of the experiments revealed that the designed energy monitoring system can successfully monitor voltage, current, active power, and temperature. electricity consumption Int. J. Comput. Commun. Inf., 23-35 / 33 over time. This work could be improved in future research discover more about the energy usage profile and how to detects which appliance is in use automatically using machine learning techniques.