Designing an Energy Meter Using Arduino Uno

: The continuous increase in the demand for electricity delivery services and the loss of electrical energy due to illegal consumption consider one of the important matters that need continuous monitoring of the transmission and distribution of electrical energy. This paper aims to design a smart electrical energy meter by using the Arduino UNO board that measures the voltage(V) and current(I) of an inductive load (resistance, coil) and calculating the frequency (f), effective power (P), power factor (PF) for this load at different values of the load and frequency. The proposed meter was designed by programming Arduino board and connecting Arduino with other electronic components to be the circle of the meter. The proposed meter was simulated and tested using Proteus software and the results obtained were good. The results showed a match between the meter reading of the values of the voltage, current, power factor, effective power, and frequency and the results obtained mathematically. The proposed meter can be developed to be able to connect to the communication networks so it can send the measured data periodically to the collection centers.


Introduction
The increasing use of distributed energy resources (DERs) such as distributed generators, electric vehicles, heat pumps, demand response, and energy storage brings significant uncertainties and, at high penetrations, may lead to operational difficulties in the distribution network [1]. Therefore, accurate knowledge of system states is critical for the network operator to ensure safe, prompt and cost-effective operation of the network, while making the best use of the assets [2]. Attention to smart meters in the world, especially Britain, has become one of the most important electricity research points in order to build a smart Grid that is able to protect and monitor electric power in transition lines. At beginning of 2021 the smart meters will be in use all over Britain according to the government's committee [3].

Smart energy meter
With the development of electronic chips and programming languages, smart energy meters evolved gradually with more hardware and software capabilities. So many researches have been conducted to develop a general purpose of smart energy meter in both hardware and software. Smart metering is recognized as an important starting point in the evolution of smart grids [4]. Smart meters employ advanced metrology, control, data storage, and Information and Communication Technologies (ICT) to provide near real-time consumption information to the consumers that will help them manage their energy use, save money, and reduce greenhouse gas emissions [5]. At the same time, smart meter measurements will: enable more accurate demand forecasts, allow improved asset utilization in distribution networks, locate outages, shorten supply restoration times and reduce the operational and maintenance costs of the networks [6,7]. Smart meters and their associated ICT infrastructure can improve the observability of distribution networks. However, their communication systems face significant technical and operational challenges [1]. The technical challenges include the lack of sufficient signal strength; the shortage of tools to detect network failure; and the indoor/outdoor placement of meters. Examples of the operational challenges include planned or unplanned maintenance of the system, software and hardware faults or malfunction of the smart meters, and customers unwilling to communicate their energy consumption data. These challenges make smart meter measurements susceptible to time delays or even temporary loss when requested by the energy suppliers or network operators [8,9]. Imprecise and lost measurements will degrade the performance or even disable a conventional state estimator. The presented system design Now days Arduino is getting more and more attention in the field of controllers because of its versatile features and rich library functions. It is user robust, fast and at the same time user friendly, it has the provision of measuring physical variables.
The active power is the product of voltage, current and power factor of load. So, to design AC watt meter using arduino, we firstly should know how to measure AC voltage, AC current and Power factor by using arduino.
Arduino board can only measure low DC voltage, less than 5v. Therefore, to measure high voltage and current, CTs (Current transformer) and PTs (Potential Transformer) will be used as additional components to concert high voltage and current to the range between 0V and 5V that the arduino can measure them. Though, arduino cannot measure some variables directly like frequency (f) and power factor (p.f), it can do that programmatically by various ways in codes, interrupt is one of the powerful features of the arduino programming which can be used to achieve like this task.
Power factor is the ratio of the active power (W) to the apparent power of the load (VA) as shown in figure (1) [10]: Where: t d is the time difference between both signals. V and I have been measured as mentioned before by the arduino, so the active power will be calculated by using the formula below: Where: P is the active power.
V is the rms voltage across the load.
I is the rms value of current across the load.
And Cos (α) is power factor of load. Fig. 2 shows the circuit diagram of the presented energy meter using arduino.
A source of unknown (frequency, voltage, current and power factor) is supplying power to the inductive load. Tow connections have been given to the digital pins 2 and 3 of Arduino to measure (f) and (t d ) programmatically to calculate (p.f). Other connections have been given to the analog Pins A 0 and A 1 by using potential transformer and current transformer to measure source voltage and current which flowing to the inductive load.
To show the measured values, Liquid crystal display is used to display frequency, voltage, current, power factor and active power. The connections are shown in the Schematic diagram. For verification, Oscilloscope is also connected to verify the reading of measured values.

Results
To examine the presented energy meter, a voltage source with various values of frequency has been applied to an inductive load. The inductive load is also changing depending on the value of a variable inductor which is changed to obtain a variable power factor. The relationship between inductor and power factor can be indicates as below: The obtained results according to frequency of the source can be divided into two cases. Both of these cases were also tested at a variable power factor according to the change in the value of the inductor as following: Case 1: i. Initially a 220V of unknown frequency is applied to the system; Figure (3) illustrates the wave forms of current and voltage. The shift between input signals is also shown by oscilloscope, and it can be measured as follows: So, difference time between both signals = 1.75ms (a bit less than one square) In terms of angle (degrees): Theoretically the power factor should be: It can be seen in fig. 2 that Arduino gives output of 0.86 or 86% which is considerable accurate, also it can be seen by oscilloscope that the total time period (T) of the signal is 20ms.
So, frequency = 1/Time period = 1/20m = 50 Hz The active power will be calculated as following: It can be seen that all the values displayed by smart meter monitor are about equal to the calculated values. The slight difference in current is due to the burden on CT.  ii. By changing the inductive load with same source voltage and same frequency, the power factor has been changed as shown in fig. 4. And by the same calculation steps in case (1), the power factor, frequency, and active power will be as below:

Case2:
a. When the frequency has been changed with the same inductive load as in case (1.a), the power factor will be changed. Fig. 5 illustrates the wave forms of current and voltage. The shift between input signals is also shown by oscilloscope, and it can be measured as following: So, difference time between both signals = 1.2ms (a bit less than one square). Also, it can be seen by oscilloscope that the total time period of the signal is 16.5ms. In terms of angle (degrees): Theoretically the power factor should be: The active power will be calculated as following: Frequency = 1/T = 1/16.5m ≈ 60 Hz a. By changing the inductive load with same source voltage and same frequency, it can be seen from fig.6 by oscilloscope that the difference time between both signals = 57.0ms (middle of square) and the total time period of the signal is 16.5ms. by the same calculation steps in case (2.a), the power factor, frequency, and active power will be as bellow: Theoretically the power factor should be: The active power will be calculated as following:

Conclusion
The presented energy meter has been implemented in tested this paper on deferent cases, this system can be easily and accurately used to measure voltage source, current, frequency, as well as to calculate power factor. the future will focus on two parts: first-measuring and calculating the cost of consumed energy and issue a consumer bill and send it to the billing center by connecting this system to the internet, so this will effectively be solving the problem of stressing the electrical grid and rising consumer awareness. Second-decreasing technical losses by improving power factor.