Design and Implementation of Low-Cost Real-Time Energy Logger for Industrial and Home Applications

With the significant increase in energy demands in the last decade, the issues of unnecessary energy usage have increased rapidly. Therefore, there is an immediate need to provide a cheap and easily accessible monitoring tool for the energy consumed by an appliance used in homes and industries. Instead of monitoring the total power consumption of the houses and/or industries, it is useful to monitor the power consumption of the individual appliance, which in turn, helps in saving the overall energy usage and thereby makes it cost-effective. This paper presents a cost-efficient design and implementation of a monitoring system that can precisely measure the current and voltage of each appliance. The design provides tracking of device activity in a real-time environment for the industries and helps in adopting to the green initiative. The design comprises of Arduino based micro-controller and Raspberry Pi, that performs precise measurements of current and voltage of the device, followed by measuring the power consumed by the device. This paper presents two different system designs, one for the single-phase measurements and the other for the DC measurements. The single-phase measurement device comprises of 10-bit ADC whereas, the 24 V DC measurement device comprises of a 12-bit ADC, which provides higher measurement accuracy compared to other systems available in the market. The implemented design uses the EmonCMS web application to accumulate and envision the monitored data. It provides a flexible and user-friendly solution to monitor the measured data easily on any android or iOS devices.


Introduction
In the past decade, there have been increase in energy demands due to the continuous development of new technologies, that contributed in making the human life easier. Electrical appliances and machines are an essential part of the day-to-day life of humans, and this leads to increase in the electricity usage [1]. Due to this, we have seen the rise of smart grid initiatives and smart metering that can monitor the power consumption and increase any electric grid's efficiency with the smart meter, which would reduce the environmental cost [2]. The development of these devices is linked with managing the power consumption, which would only be possible after getting the full consumption report from commercial, industrial, and domestic usage. Currently, several households as well as industries use energy loggers that are capable of visualize, monitor and/or manage total power consumption.
It is very important that this information is accessible and available to users, always. Here is where the concept of Internet-of-Things (IoT) appears. It implies "A worldwide network of interconnected objects uniquely addressable, based on standard communication protocols" [3]. The service of IoT is extensively spread to industrial and home applications in everyday tasks. Our aim is to use this service for the purpose of energy monitoring for producing cost effective solutions whilst maintaining a certain level of lifestyle. Any industry or house under observation that uses the IoT network can be segregated into three major categories as shown in Fig. 1.
Usually, most of the energy loggers available in the commercial market, helps the user to monitor and manage the overall power consumption of the household. Alternatively, if the user has the freedom to connect it to the individual appliances, it allows the user to visualize and manage the data from these individual appliances on a single cloud platform. This will enable the user to have a better understanding of the appliances efficiency and power consumed by it, however, this is expensive. Therefore, this paper proposes two costefficient monitoring system designs, one for single-phase measurements and the other for 24 V DC measurements. Additionally, the data measured using these systems is accumulated using EmonCMS web application, that can be easily accessed using any android or iOS devices for data analysis and monitoring.

Literature Review
The past decade years have observed rapid advancement in the technologies that lead to significant improvement in the lifestyle of humans. Thus, the increasing demands for more advanced technologies have led to increase in household energy consumption, ultimately 1 3 resulting in the energy crisis. Therefore, optimization of the energy consumption has attracted several researchers to develop monitoring system that can keep track of the energy usage at home which can provide a good estimate of the appliances that consumes higher energy.
There have been several efforts made to design energy-efficient appliances [5][6][7][8]. However, a further reduction in energy usage can be obtained if the real-time energy monitoring of these energy-efficient appliances is carried out, that provides the consumer with details of the energy used by the appliances. A similar study is presented in [9], where the energy consumption of the home appliances is monitored using Energy Measurement and Communication Unit (EMCU). It proposes to install the EMCU in each outlet, where the measured values at this outlet are transferred periodically to the home server with the help of ZigBee. The particular ZigBee technology is used in [9] to ensure that the low power is consumed by this technology. The data collected at the home server is then used to generate that power profile of all the appliances in the house. The studies presented in [10] suggested that home energy management systems with the capability to record the data using specialized hardware and software can play a significant role in lowering the energy usage and reduce the greenhouse gases. Additionally, implementing smart grids as suggested in [10,11] could also be a part of smart energy system. A specialized approach of automatically analyzing the data from smart meters in order to determine the consumer characteristics is presented in [12], where the user carries out energy efficiency campaigns for the household appliances. Different technologies and features that can be incorporated with the smart energy meters has been discussed in detail in [13].
Furthermore, study on importance of security features in smart energy meters is also presented in [13]. A detailed analysis of various infrastructure and communication protocols for smart energy along with a wide range of energy management models including the hardware and software is discussed in [14]. Furthermore, reference [14] also emphasizes the significance of monitoring, controlling, and supervising of the household appliances along with the appropriate communication protocols that ensures the reliability of the data collection with the help of advanced algorithms and sampling tools. Another similar concept of measuring individual loads but in a three-phase measuring system is presented in [15], where the device logs the data onto the SD card. The PIC is interfaced with isolated current and voltage sensors for measurement. The calibration is manipulated to maintain the linearity, to measure the three phases individually and calculate the error percentage for the instantaneous measurements. The device in [16] uses the similar monitoring system with the Internet of Things concept for monitoring the energy consumption of a building. It uses PZEM-004t sensor with Arduino Nano microcontroller and ESP8266 (serial-to-Wi-Fi module) to send the data to the cloud. The device is developed for three-phase four-line power line (for a laboratory building). The measurements were taken for a week, however, no comparison between the actual values and the measured values was made by their equipment. This module measures the AC voltages between 80 and 260 Vrms with current up to 100 A. The cloud server Thingspeak is used to store the data online and the data is sent to it every minute the device is switched ON.
A study in [17] presents the power meter designed with the Arduino to measure the power consumed by individual appliances, to understand the usage of each appliance via cloud and further to control them. The data is displayed on the power monitoring website and control established helps put a track on the consumption and bill on day-to-day basis. It measures the real-time current values with the SCT-013-030 non-invasive, split core current transformer. The Wi-Fi module ESP8266 sends the real time data wirelessly. The data is viewed on the Nokia 5110 display module to show the power consumed. This device measures the overall household consumption or a particular room's usage but can also be used to understand specific appliance power usage. Reference [18] shows an energy meter for the domestic usage. The energy meter is designed with the non-invasive current sensing unit, which can measure power at any given point. To send the data, ENC28J60 Ethernet module was used to send the data to be viewed over any smartphone. The [19] represents the similar module which incorporates a GSM/GPRS module to transmit the voltage and current detected values periodically, with the help of a GPRS/GSM network where the only disadvantage is the network reliability between lengthy distances, affecting the reliability and speed of the system. The energy logger described in [20] uses the non-invasive CT sensor, with a PZEM-004T with the electric energy measurement chip SD3004 with the ESP8266 (Wi-Fi module) to send the data to the server. The ESP8266 communicates via RS-232 with the PZEM-004T. The ESP sends the data wirelessly to the server every 20 s and uploads the data in the JSON format to raspberry Pi 3 where it hosts the database and local server. Here, Grafana is used to create a dashboard and the values are displayed in a graphical format, and as a function of time [20].

Background
A generic configuration and architecture of any power monitoring system that uses the IoT platform includes a four-layered architecture i.e., sensing layer, Networking layer, Service layer and Interface layer [21]. The first and foremost task is to acquire data via sensors. These are connected to the processor or are wireless in nature and are placed in different scenarios to acquire the raw data of the surroundings. Secondly, the processor then acquires this data and converts into sensible information. The final stage is making the data available to the user (which is also the end stage for an IoT network) via internet. Here most of the systems use servers to upload the data after processing to be accessible by users. The system proposed in this paper uses raspberry pi, which acts as our local server to upload the data after processing. Hence, the data is then available online to the authenticated users. Figure 2 shows a simple block diagram of a monitoring system that has four sections namely data procurement, processing, transferring, and presenting [4].

Data Procurement (Sensors)
Sensors play a vital role in any IoT system. The sensor layer ensures the acquisition of data and work with wireless systems to get the seamless real-time data from the environment variables. A wireless network can have several sensor nodes that leads to the seamless flow of data and this contributes to the significance of Big Data. Hence, they provide the data from the physical world with the objective to get the accurate information via the intelligent interface [22,23]. This large amount of data is transferred to cloud servers, via

Data Processing
After the data is acquired with the help of sensors, it is passed to a platform to manage the acquired data, which is mostly done by a micro-controller like Atmega328P (Arduino), Raspberry Pi etc. The Arduino is one of the most common micro-controllers used to acquire and process data with the flash memory varying from 32 to 512 kB (depending on the model type) and 2 kB RAM [24] and is programmed to follow the instructions to get the raw data and convert into sensible information.
The other microcontroller is Raspberry Pi, which is also known as a mini computer, could be used as the gateway or the Central Processing Unit (CPU), and processes the data much faster than the Arduino and has the ability to handle complicated tasks than the traditional micro-controller [25].
The Raspberry Pi has the USB, Ethernet and Wi-Fi abilities that implies three different ways to transfer/upload data on the servers which makes the procedure much convenient and gives the user a choice by taking different factors into consideration i.e. data processing time, data transfer rate, communication protocol etc. The Raspberry Pi also has a slot for memory card, which might be used to host a database to store the particular node's data. Different nodes can store their own data but all the data can be combined from all the nodes onto the cloud server. Therefore, two or more nodes can post onto one cloud and compare the data with each other.

Data Transfer
The next important step is to transmit the data between nodes and controllers using one of the various communication protocols, either wired or wireless. These might be via Wi-Fi, Bluetooth, LoRa, ZigBee, Ethernet etc. The choosing of technology depends on the application i.e. if it is a low range communication or a long range one and various other factors such as data rate, accuracy etc. The other thing to take in account is the compatibility of two devices and implement the data transference.
The monitoring system uses the serial connection for the transmission of data from the micro-controller to the gateway since it is a wired connection; it is the fastest means of transferring data from sensors to Atmega328P to Raspberry Pi, which then uses Wi-Fi protocol to send the data to cloud. Wi-Fi is used, as the wireless connection is needed for the monitoring of data, as providing internet connection via Ethernet cable does not seem like a feasible solution in this case.

Presenting the Data
All the IoT systems consists of different gadgets, also known as 'things', which communicates through different communication protocols. Due to this diverseness, there might be issues while combining two or more technologies for data transfer and communication between devices, which makes it harder to have an event with two devices obliging each other [21].
There are different ways of presenting the data, either via the web application (mobile) or on the website. The other prospect is to consider the option of hosting the webserver on the gateway (Raspberry Pi) accessible locally via the Ethernet connection (via webbrowser; accessible via local IP address). The Pi has the ability to run software packages that hosts the web app for the data visualization, in a graphical format.

Proposed Monitoring System
The proposed monitoring prototype is designed to measure the electricity consumption with the individual loads to understand the consumption of each machine (at homes) and the heavy usage machines at the industries. This real-time monitoring framework will endow better awareness into the energy and power consumption information of the industries, which in-turn will enable the green initiative for the industries and help save money with the consumption statistics. Here we have designed the three prototypes with different abilities to measure power consumption. The prototypes include the abilities to measure 1-phase AC and 24 V DC logging units. The proposed energy logger comprises of sensing, processing, and data visualization units with the slight understanding of data transmission and communication relations. Figure 2 already provides the basic overview of the components of the system.

CT Sensor (AC)
There are several CT sensors like RI-CT050 sensor [26], KCT-24 sensor [27], SEN-11005 sensor [28] and YHDC SCT-013 [29] that could be used for AC measurements. However, since the proposed solutions presented in this paper requires the device to attach at a particular appliance for the AC measurements, the CT sensor was chosen such that it would handle the current for a single appliance. YHDC SCT-013 current transformer (CT) is used as an AC current sensor to measure current from electrical wire and give output in mA. The required voltage to operate Atmega328P chip is maximum 3.3 V DC. So, 22 Ω burden resistor is used to convert induced current of CT into voltage. A schematic diagram of the connections of CT sensor with Atmega328P is shown in Fig. 3. Resistors R19 and R17 in the circuit diagram are a voltage divider that provides the Voltage source. Capacitor C1 has a low reactance of a few hundred ohms that provides a path for the alternating current to bypass the resistor. A value of 10-μF capacitor is suitable.
The CT sensor gives analogue output and is directly connected to the Atmega328P (Arduino) of the monitoring unit for 1-phase.

CT Sensor (DC)
For the DC logger, the CT sensor used is Magnelab's HCT-0016-100 and can measure the current up to 100 A. The HCT-0016-100 has a self-locking mechanism [30]. The same company also provides other CT sensors (DC) with different current ratings, however, for this research the CT sensor with rating of 100 A was selected, as this sensor needs to be attached to only single appliance. The DC sensor gives the output of 0-4 V at the rated input current. Therefore, a voltage divider is used to scale down 4 V and 24 V (in case of voltage measurements) to below 3.3 V to meet the requirement of the ADC input. Figure 4 shows the schematic connection of CT sensor for 24 V DC logger.

DC Current Measurements
An off-the-shelf split-core DC current sensor was used, which can sense input current of 0-100 A DC and transform it to 0-4 V DC voltage output, with stated full-scale accuracy of ± 1% at frequencies of 50/60 Hz [6]. The CT includes a closed-loop ferrite core, a hall sensor, a differential amplifier, and a Zener diode. Figure 5 illustrates the schematic diagram of the sensor and Fig. 6 shows the linear relation- ship between the input current and the output dc voltage. The sensor requires a ± 15 V dc power source in order to operate properly. Furthermore, a similar circuit, is used to couple the CT to the microprocessor analog input. However, the voltage divider resistors value has changed to R 1 (10 K Ω) and R 2 (18 K Ω) to regulate a 4 V to below 3.3 V.

DC Voltage Measurements
Voltage measurements in the range of 0-24 V were made with the circuit shown in Fig. 7. A voltage divider comprised of R 1 (120 K Ω) and R 2 (15 K Ω) is used to turn a large voltage into low voltage, as the microprocessor analog inputs can only measure between 0 and 3.3 V. The R 3 (1 K Ω) comes in series with R 1 to limit the current flow. A filter capacitor is placed parallel to the pulsating output to allow the passing of low-frequency components and attenuates higher frequency components.
The circuit configuration also contains a bi-directional Zener diode to protect inputs from the high voltage.

Gateway
The Raspberry Pi 3B + model is used as a gateway and is intentionally selected because of its size, cost, choice from more than one communication protocols (Bluetooth, Ethernet, Wi-Fi etc.) abilities to do function as a minicomputer and widely used with real-time  applications. With the SD card slot, the memory can be expanded as per our needs and CPU working at 1.4 GHz provides increased speed than previous models.
Due to its compatibility with the Arduino (ensuring the proper data flow), capability of running the server software packages, hosting the database on the SD card and visualize the data at the local network [25], makes it as the perfect gateway for the system.

Single-Phase Monitoring System
The energy-monitoring device is a system that can be used to measure and monitor realtime AC voltage, current, real and apparent power. The monitoring devices comprise of Current Transformer (CT), Voltage Transformer and emonPi module. All of its hardware is based on the Arduino and Raspberry Pi platforms and need a power of 5 V DC. These monitoring units are connected to the laptop via Ethernet to access the local server, which is accessible via the IP address of the Raspberry Pi and sends the data to EmonCMS cloud via Wi-Fi through Pi. The Single-Phase circuit consists of three CT sensors, so it measures three loads at a time. Figure 8 shows the block diagram of single-phase measurement whereas Fig. 9 shows the single-phase energy logger prototype.

24 V DC Monitoring system
A 15.5 V DC power supply gives a maximum output current of 10 A, where the input voltage that is given to the circuit is between 2.8 and 15.5 V to power up the electrical load. A CT sensor to detect DC current (HCT-0016-100; Sect. 4.1.2) is clamped between 15.5 V Fig. 8 Single-phase blockdiagram Fig. 9 Single-phase prototype energy logger DC power supply and electrical load to sense DC element from the current carrying wire. Figure 10 below shows the block diagram for DC measurement whereas Fig. 11 shows the DC energy logger prototype.

Safety Test Setup
The CT sensor clips around a single electric wire, either live or neutral, NOT both, so it is important to separate the main electrical wire in three i.e., live, neutral and earth. Leaving open high voltage electric wires can be very dangerous on some occasions. Hence, the safety box is designed in order to keep the split electric wires outreach of human connect as shown in Figs. 12 and 13.
Two types of boxes were designed; one for installing current and the other for voltage transformer. In one of the boxes only CT sensor is installed and in other design, both CT and voltage transformer is installed. The plug and socket are connected to the power distribution board and an electric load.

Calibration Procedure
It is significantly important to calibrate the system before it is used for measurements, to minimize any uncertainty in measurements and use it accurately. Steps used for calibration are listed as: 1. The primary step is to write a sketch (or program) to measure the current, voltage and power factor of an equipment. 2. The second step is to measure the voltage of the mains and adjust the voltage constant to a particular value or average out the first 100 values to get the voltage calibration constant. This will ensure that the readings obtained from the device is consistent with the meter readings. The new calibration coefficient can be calculated as: 3. Calibrate the current by connecting the meter serially with the CT sensors and workout the calibration so that the current reading on the serial monitor is the same as the measured current. 4. If the voltage input is being used with the load, the phase angle must be adjusted so that the real power New Calibration coefficient = Present Calibration coefficient × Actual Reading Device Reading

Results
In order to validate the performance of the proposed energy logger, power measurements were carried out for 24 V DC load as well as single-phase load systems. PM3000 power analyzer is a calibrated measurement device that is used as the reference for these measurements in order to determine the relative error of the proposed energy logger. The power recorded for the singe-phase linear load by the energy logger and the PM3000 analyzer is shown in the Fig. 14. In this case, a 200 W incandescent lights were used. In order to take sufficient samples, the number of lights that were used were gradually increased from 1 to 6. Figure 14 shows a linear curve for the consumed power, as expected. In order to check the accuracy of the energy logger, the relative error curve for this measurement is shown in Fig. 15. The relative error curve suggests that the relative error decreased from + 3.78 to + 1.57% with increasing the number of loads. A similar measurement was undertaken, where the single-phase linear load was replaced by 24 V DC source in the form of incandescent lights. The number of loads were again increased from 1 to 6. A linear plot of the power consumed was observed as expected and is presented in Fig. 16. The relative error curve of the power measured by energy logger compared to the PM3000 analyzer is shown in Fig. 17.

Data Logging
This section will show that the data coming through on the web-interface (local and remote) is decoded properly and the received information is correct.
Here we have the data from 24 V DC device with the DC power supply that shows the value of current and voltage when applied across a load. This verifies the data coming through is correct and is validated through this. Figure 18 shows the screenshots of power supply and the web-interface data to show that the when the supply voltage (on the power supply) was changed, this change is reflected on the local and the web interface as shown in Figs. 19 and 20.

Proposed System Comparison with the Existing Solutions in the Market
A comparison of the proposed system with the existing solutions in the market is shown in Table 1 on the basis of price, features which are comparable to our device and installation feasibility.

Conclusion
A low-cost and accurate energy logger have been proposed in this paper to measure the power consumed by the industrial and home appliances. The overall system approximately costs around 90 GBP, which is relatively less expensive compared to existing solutions in the market having similar features. Additionally, the measurements for single-phase and 24 V DC loads using the proposed energy logger is presented in comparison to the data obtained using PM3000 commercially available energy logger. The  proposed energy logger presents a relatively low error as compared with the PM3000 energy logger. The data measured by the energy logger can be viewed remotely using the EmonCMS web application and can be viewed on any android or iOS devices.