Purpose of the system
The purpose of this project is to design an energy-meter that can be plugged into individual electric appliances and measure the energy consumed by them.
The device will collect data from a current sensor (ACS712), send (ESP8266) and store this data in a cloud platform (Blynk) where it will be analyzed for trends such as: instant current and power, cumulative energy and expenditure.
There is an user interface where the user will be able to view the trends, turn appliances on and off, receive warning notifications for high energy consumption and for dropping energy efficiency - the value of this will be entered by the user according to the appliance.
The device will be of special use for shared accommodations, each user will be able to use it to measure their individual energy consumption and estimate the bill by sending a monthly report of the corresponding energy consumption and the electric energy tariff according to the UK's rates. The monthly report data will be send to the user by e-mail.
Use instructions
It will be necessary for the user to download the Blynk app from the App Store for iOS users or from the Play Store for Android users.
The following QR code can be scanned from the Blynk app to be able to access the energy-meter user interface.
The following user interface will appear:
It is possible to modify the desired values for the following parameters:
1. Device selector: The user is able to choose from different appliances registered in the application. The device selector allows to monitor and control each different appliance.
2. Supply voltage (V): The supply voltage changes according to geographical zones and it can be modified if needed. Standard in the UK is 224 V.
3. Power factor: The power factor measures how efficient is the consumption of electrical power. This parameter refers to the ratio of delivered useful power to the total power taken from the electrical network. The ideal ratio is 1.0, and in the UK, the ratio threshold is equal to 0.95. The power factor should be measured for each different load, since it can vary depending on the inherently reactive nature from the load and from the electric circuit that it is powered from.
4. Power rating (W): Every appliance has a different power rating and this value can be modified to satisfy each of them. It will monitor when power is going above the average rating and launch a notification to the user.
5. Energy tariff (£): The energy tariff is subject to change according to government subsides. Therefore, it is possible to change the cost of electrical energy per kWh to the current tariff.
6. Target energy (Wh): The user can input the amount of energy they wish to spend monthly in Wh, this is useful for consumption control.
7. Monthly data: This widget allows for modifications on the monthly data report sent to the user. The user is able to customise frequency, parameters received as well as add several recipients. The report is received in the CSV file format.
| Parameters Interface |
It is possible to modify the desired values for the following parameters:
1. Device selector: The user is able to choose from different appliances registered in the application. The device selector allows to monitor and control each different appliance.
2. Supply voltage (V): The supply voltage changes according to geographical zones and it can be modified if needed. Standard in the UK is 224 V.
3. Power factor: The power factor measures how efficient is the consumption of electrical power. This parameter refers to the ratio of delivered useful power to the total power taken from the electrical network. The ideal ratio is 1.0, and in the UK, the ratio threshold is equal to 0.95. The power factor should be measured for each different load, since it can vary depending on the inherently reactive nature from the load and from the electric circuit that it is powered from.
4. Power rating (W): Every appliance has a different power rating and this value can be modified to satisfy each of them. It will monitor when power is going above the average rating and launch a notification to the user.
5. Energy tariff (£): The energy tariff is subject to change according to government subsides. Therefore, it is possible to change the cost of electrical energy per kWh to the current tariff.
6. Target energy (Wh): The user can input the amount of energy they wish to spend monthly in Wh, this is useful for consumption control.
7. Monthly data: This widget allows for modifications on the monthly data report sent to the user. The user is able to customise frequency, parameters received as well as add several recipients. The report is received in the CSV file format.
After this, the device can be plugged into the energy socket and the selected appliance. The appliance can then be used normally.
The Blynk application will start showing the consumed energy data in a chart and the individual values for current, power and energy consumption will be displayed in the gauges.
There will be a value indicator with the amount in pounds to pay for the energy used, this quantity is cumulative and will restart itself every 30 days, in order to provide distinct monthly expenditures.
| Parameters Monitoring Interface |
Instructions for building the device
In order to build the device, the following materials were required:- ESP8266 microcontroller and Wi-Fi module
- ACS712 current sensor
- 5A relay
- 1.5 kΩ resistor
- 2.7 kΩ resistor
- MP1584EN DC-DC buck converter
The hardware design will be further discussed in the "Hardware design" section.
Blynk – IoT Cloud platform
The prototype was tested simulating two different appliances. The first one by using a light bulb as a load for the current sensor and the second one by using a cell phone charger plugged into the micro-controller ESP8266.
As an example, the light bulb consumes approximately 0.30 A and 70 W. This was confirmed by using the Blynk user interface.
The hardware design will be further discussed in the "Hardware design" section.
For the software design of the device, the following was used:
- Arduino IDE
- Blynk platform
The software design will be further discussed in the "Software design" section.
Hardware design
Design Features and Specifications
This project proposes a wireless
system for measuring, monitoring and controlling energy consumption from
different appliances by a plug-on mounting mode. The system obtains data from a
current sensor and remotely monitors them on an IOT cloud platform accessed
from a mobile base.
The selected microcontroller is the
ESP8266 module, an integrated Wi-Fi networking device capable of monitoring and
updating required data in a cloud-based. The chosen current sensor is the ACS712-30A, and the relay to control and switch the loads on
and off is the one channel relay module. Besides, the power supply adopted is a set of 4 AA
alkaline battery due its long-drawn life cycle. Finally, the proposed IoT cloud
platform is Blynk.
a)
Microcontroller
The ESP8266 NodeMCU V1.0 is a
standalone micro-controller that can manage and interact with different devices.
It is also able to communicate with a cloud platform to monitor the devices,
store data and send notifications [1] . The recommended voltage operating
conditions is from 3.0 to 3.6 V, and the current consumption can vary from 10
uA to 170 mA [2] .
This micro-controller was chosen for
its low-cost, reduced dimensions and sleep function that reduces power
consumption, making it very appropriate for the constraints in this design.
b)
Current Sensor
The ACS712-30A current sensor is
based on the Allegro ACS712ELC chip. This transducer device has a measurement
range from -30 to + 30 A. The working principle from the sensor is based in the
Hall Effect, the applied current flows to a copper conduction path that
generates a magnetic field, which is converted into a proportional voltage [3] .
The current sensor provides an
analog output signal in response to the variation through its terminals. The
output voltage at 0A is equal to VCC/2
(2.5 V according to the nominal power supply)[3] . A voltage divider
is required to this project because the current measured is analysed by the ESP
that has 3.3V input pins. Therefore, the readings from the sensor’s output pin
should be converted from 2.5V at the ACS to 1.65 V at the ESP.
(2.5 V according to the nominal power supply)
c)
Relay Module
The relay is an electrically operate
device that can control a high-power load by one low-power signal. The relay
module can sense input variables (i.e. current, voltage) and switch on and off
connected circuits by its output actuator that can by energising and
de-energising them. The one channel relay module operating voltage is 5.0V, and
maximum output is 250V, 10A [4]
Circuit Schematics
The following figure illustrates the
proposed connections for the selected components.
| Circuit Schematic |
Power Supply:
The 6.0 V set of battery is
connected to the VIN and GND pins from the microcontroller. The relay is
connected directly with the 3.3V pin from ESP, while the current sensor is
powered through a 5.0V voltage regulator. Whilst, the load sample uses an AC
power supply.
Components Pins-Out:
Current
Sensor:
·
Input
VCC: Connects to the 5V pin from
the voltage regulator
GND: Connects to the 0V pin from
the voltage regulator
OUTPUT: Connects to the analog input pin (A0) from the microcontroller
through a voltage divider
The
voltage divider circuit proposed has two series resistors, one extremity
connected to the sensor’s output and the other to the ground, with the middle
linking of the resistors connected to the analog pin from the ESP.
·
Output:
IP+: Connects to the load
IP-: Connects to the AC power source negative
Relay Module
·
Input:
VCC: Connects to the 3.3V pin from
the microcontroller
GND: Connects to the 0V pin from
the microcontroller
SIG: Connects to
the digital output pin (D7) from the microcontroller (it is the relay
controlling)
·
Output:
COM: Common pin connects to the AC
power source positive
NC: Normally Closed that set the
load at low (disconnected)
NO: Normally Open that set the load
at high, connects to the load
Blynk – IoT Cloud platform
The IoT cloud platform chosen for this project is the Blynk programme, a free mobile service, which can store data in the cloud, visualize them in real time, perform data analysis through a digital dashboard that can be easily build from a variety of widgets, and provide push notifications [5].
Software design
The following code was used for the reading of the current sensor, calculation of power and energy consumed as well as cost estimation. This code also includes the Blynk and ESP8266 libraries needed for communication and the set up of user notifications and measurements as well as the implementation of the Blynk user interface. Comments explaining each part of the code are highlighted in bold text.
#define BLYNK_PRINT Serial
int sensorIn = A0;
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A
Module
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "*****************************";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wifi ssid";
char pass[] = "********";
float Voltage = 0;
float VRMS = 0;
float AmpsRMS = 0;
float mainsVoltage = 0; //Change this value from UI
float power = 0;
float currentEnergy = 0;
float totalEnergy = 0;
//Change this value from UI
float tarrif = 0; // Pence/KWs Change this value from UI
float cost = 0;
// Device related constants
float maxEnergy = 0;
//This is our energy limit for the device in WattHour; Change this value from UI
float devicePower = 0;
//This is the device power rating in Watt. Change this value from UI
float devicePF = 0;
//This is device power factor. Change this value from UI
BlynkTimer timer;
void setup()
{
// Debug console
Serial.begin(9600);
// Blynk code
Blynk.begin(auth,
ssid, pass);
// Setup a function
to be called every second
timer.setInterval(2000L, myTimerEvent);
// set pinMode of A0
to input.
pinMode(sensorIn,
INPUT);
}
// Virtual pin V4 for power consumption
#define PIN_POWER V4
// Virtual pin V5 for rms Current
#define PIN_CURRENT V5
// Virtual pin V6 for energy consumption
#define PIN_ENERGY V6
// Virtual pin V7 for cost consumption
#define PIN_COST V7
// Keep this flag not to re-sync on every reconnection
bool isFirstConnect = true;
// This function will run every time Blynk connection is
established
BLYNK_CONNECTED() {
if (isFirstConnect)
{
// You can also
update individual virtual pins like this:
Blynk.syncAll();
isFirstConnect =
false;
}
}
void myTimerEvent()
{
// Calculate the
current
Voltage = getVPP();
VRMS = (Voltage/2.0)
*0.707;
AmpsRMS = (VRMS *
1000)/mVperAmp;
//Debug messages
relating to current
Serial.print(AmpsRMS);
Serial.println(" Amps RMS");
Serial.print(VRMS);
Serial.println(" V RMS");
// Calculate power
consumption, P = VI * PF.
calculatePowerConsumption();
// Calculate energy
consumption. Current energy and accumulated energy
calculateEnergyConsumption();
// Calculate total
Energy Bill so far
calculateTotalCost();
// check power Usage
and alert
checkPowerUsage();
// check
energyConsumption and alert
checkEnergy();
Blynk.virtualWrite(PIN_COST, cost);
Blynk.virtualWrite(PIN_POWER, power);
Blynk.virtualWrite(PIN_ENERGY,totalEnergy);
Blynk.virtualWrite(PIN_CURRENT, AmpsRMS);
}
float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue =
0; // store max value here
int minValue =
1024; // store min value here
uint32_t start_time
= millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue =
analogRead(sensorIn);
// see if you
have a new maxValue
if (readValue
> maxValue)
{
/*record
the maximum sensor value*/
maxValue =
readValue;
}
if (readValue
< minValue)
{
/*record
the maximum sensor value*/
minValue =
readValue;
}
}
// Subtract min
from max
result = ((maxValue
- minValue) * 5.0)/1024.0;
return result;
}
void calculatePowerConsumption(){
// Calculate power
consumption, P = VI * PF.
power = AmpsRMS *
mainsVoltage * devicePF;
Serial.print(power);
Serial.println(": is total power");
}
void calculateEnergyConsumption(){
currentEnergy =
((power/1000)*(2)); //energy in kwatts*second = KJ;
totalEnergy +=
currentEnergy; // accumulated energy
Serial.print("Total Energy Consumption = ");
Serial.println(totalEnergy);
}
// check if the totalEnergy Consumed. If it is higher, send
alert.
void checkEnergy(){
if (totalEnergy >
maxEnergy) {
Serial.println("High energy consumption");
// Note: We
allow 1 notification per 5 seconds for now.
Blynk.notify("High energy consumption alert");
}
}
//Calculate the total const inccured.
void calculateTotalCost(){
cost = (totalEnergy
* tarrif);
Serial.print("Total Cost = ");
Serial.println(cost);
}
/* check if the power consumed. If it is more than the
device power rating,
* there is a problem
with the device. It is consuming more power than expected.
* Send an alert for
higher values.
*/
void checkPowerUsage() {
if (power >
devicePower) {
Serial.println("Dropping energy efficiency");
// Note: We allow
1 notification per 5 seconds for now.
Blynk.notify("Dropping energy efficiency alert");
}
}
// Get Stored energy from server (stored value)
BLYNK_WRITE(V6){
totalEnergy =
param.asFloat();
}
// Get cost from server (stored value)
BLYNK_WRITE(V7){
cost =
param.asFloat();
}
// Configure maxEnergy Consumption from app
BLYNK_WRITE(V8){
maxEnergy =
param.asFloat(); // in Whr;
maxEnergy *=
3.6; // change to KWs
Serial.print("Max Energy = ");
Serial.println(maxEnergy);
}
// Configure tarrif from app
BLYNK_WRITE(V9){
tarrif =
param.asFloat(); // pence/KWh
tarrif /= 3600; // Change to pence/KWs
Serial.print("Tarrif = ");
Serial.println(tarrif);
}
// Configure devicePower from app
BLYNK_WRITE(V10){
devicePower =
param.asFloat();
Serial.print("Device Power = ");
Serial.println(devicePower);
}
// Configure
mainsVoltage from app
BLYNK_WRITE(V11){
mainsVoltage =
param.asFloat();
Serial.print("Mains Voltage = ");
Serial.println(mainsVoltage);
}
// Configure devicePowerFactor
BLYNK_WRITE(V12){
devicePF =
param.asFloat();
Serial.print("device
Power Factor = ");
Serial.println(devicePF);
}
void loop()
{
Blynk.run();
timer.run(); //
Initiates BlynkTimer
}
For further reference, the code can also be accessed at https://github.com/abenitrust/energy_metering/tree/master/RELAY-CURRENT-EVERYTHING
The code mentioned before is generic for any appliance and for any device, it is only necessary to change the Auth Number of the project. The Auth number is obtained through the Blynk application.
Testing
| User Interface for Appliance 1 |
Weaknesses
Unfortunately, our prototype has a considerable error range of 0.08 A or 20 W, this can be due to two factors: the first one is that the current is measured through the Hall effect, where it uses a magnetic-electric element to measure the current. This approach for measurement can have disturbances when placed near to other electromagnetic devices such as the 5 A relay that is being used to turn the appliance on and off.
The second factor that may be involved in the considerable error range is the fact that the chosen current sensor has the capacity of measuring up to 30 A and for the present testing environment - with only one light bulb, the consumption is only about 0.30 A. This may cause lower sensitivity and accuracy than that of a sensor with a lower measuring capacity. However, for the purpose of measuring household appliances, whose power and current consumption is much greater this error may be considerably lower.
Conclusion and Further Studies
The purpose of the project was successfully achieved by the monitoring and control of energy consumption from individual appliances, done by measuring the current in the circuit using an ACS712-30A sensor, as well as switching the appliance on and off using a relay module integrated with a microcontroller and Wi-Fi module ESP8266.
By entering the required input parameters in the mobile application it is possible to remotely collect and analyze the energy data from the sensor in real-time. The prototype has the potential to be applied in different types of appliances, concerning the parameters that have to be entered for each one.
For future work on the optimization and improvement of the energy-meter, the purpose is to replace the current sensor with an energy sensor. This will allow for a more accurate energy measurement, as with the current sensor voltage is assumed to be constant and this may not always be the case.
By entering the required input parameters in the mobile application it is possible to remotely collect and analyze the energy data from the sensor in real-time. The prototype has the potential to be applied in different types of appliances, concerning the parameters that have to be entered for each one.
For future work on the optimization and improvement of the energy-meter, the purpose is to replace the current sensor with an energy sensor. This will allow for a more accurate energy measurement, as with the current sensor voltage is assumed to be constant and this may not always be the case.
Currently, in order to measure the energy consumed per person, it is required that each user has their own device and that the plug it in when they use certain appliance and retrieve it after use. This could be improved by allowing multiple users to use the same energy-meter device integrating different user profiles in the Blynk application. Allowing the users to sign in to the application and select the specific appliance they will be using from a menu.
For further energy analysis, future users will be able to select a range of dates to display only the amount of energy consumed during that time interval. There will also be a menu of average energy consumption and dropping energy efficiency for common appliances such as washing machines or dryer machines instead of having the user input the values.
References
[1] M. Schwartz, Internet of Things with ESP8266, Packt Publishing, 2016.[2] Espressif Systems, ESP8266EX Datasheet - Version 5.9, 2018.
[3] Allegro, "Datasheet: ACS712 - Hall Effect-Based Linear Current Sensor IC," 2012.
[4] "Arduino lesson – 1-Channel Relay Module," 2017. [Online]. Available: http://osoyoo.com/2017/08/28/arduino-lesson-1-channel-relay-module/. [Accessed 24 November 2018].
[5] "Blynk," [Online]. Available: https://www.blynk.cc/. [Accessed 24 November 2018].

