NanoRama

Enter Your Project for a chance to win a Nano Grand Prize bundle for the most innovative use of Arduino plus a $400 shopping cart!

Submit an EntrySubmit an Entry  Back to homepage
Project14 Home
Monthly Themes
Monthly Theme Poll

 

A smart energy monitoring system that will ease the inspection, monitoring, analysis, and fare calculation of energy

 

First of all, Happy Birthday Project14 and Arduino

 

In Kerala (India), the energy consumption is monitored and calculated by frequent field visits by technicians from the electricity/energy department for the calculation of energy fare which is a time-consuming task as there will be thousands of houses in the area. There is no provision to check or analyse the individual energy consumption of houses in a period of time nor to create a report of energy flow in a certain area. This is not just the case of Kerala, but throughout many places in the world.

 

This project involves the development of a smart energy monitoring system that will ease the inspection, monitoring, analysis, and fare calculation of energy. The system will additionally allow generating user specific or area specific charts and reports to analyse the energy consumption and energy flow. The system module which will be given a unique user code to identify the particular housing unit where the energy consumption has to be measured. The power consumption will be monitored with the help of a current sensor interfaced to an Arduino board using Analog connection. The energy consumption data and the unique user code of the user can be uploaded to a dedicated cloud service at real-time. The data from the cloud will be accessed and analysed by the energy department to calculate individual energy consumption, generate individual and collective energy charts, generate energy reports and for detailed energy inspection. An LCD display module can be integrated into the system to display real-time energy measurement values. The system will work independently if a portable power source such as dry cell battery or Li-Po battery is attached.

 

 

The main focus of this project is to help optimize and reduce the energy consumption usage by the user. This not only reduces the overall energy costs, but will also conserve energy.

 

The components that are used in the project are:

 

  • MKR Zero / Arduino Uno
  • ACS712 Current sensor
  • LCD Module [I2C version preferred]

 

   

 

The hardware connection diagram for prototype is as follows:

 

 

 

Use the below connection if you prefer an I2C LCD module.

 

                                                  [Picture courtesy from respective sources]

 

Power from the AC mains is drawn and passed through a the current sensor which is integrated into the household circuit. The AC current passing through the load is sensed by the current sensor module (ACS712) and the output data from the sensor is fed to the analog pin (A0) of the Arduino UNO. Once the analog input is received by Arduino, the measurement of power/energy is inside the Arduino sketch. The calculated power and energy is then displayed on the LCD display module.

 

In AC circuit analysis, both voltage and current vary sinusoidal with time. Also various power are considered. Of these, some Power may also be lost in the form of heat or radiation while long distance transmission.

Real Power (P): This is the power used by the device to produce useful work, expressed in kW.

So, Real Power = Voltage (V) x Current (I) x cosΦ

Reactive Power (Q) : This is often called imaginary power which is a measure of power oscillates between source and load, that does no useful work, expressed in kVA

So, Reactive Power = Voltage (V) x Current (I) x sinΦ

Apparent Power (S) : It is defined as the product of the Root-Mean-Square (RMS) Voltage and the RMS Current. This can also be defined as the resultant of real and reactive power, expressed in kVA

So, Apparent Power = Voltage (V) x Current (I)

 

Relation between Real, Reactive and Apparent power:

Real Power = Apparent Power x cosΦ

Reactive Power = Apparent Power x sinΦ

We are concerned only on the Real power for the analysis.

 

Power Factor (pf) : The ratio of the real power to the apparent power in a circuit is called the power factor.

Power Factor = Real Power/Apparent Power

Thus, we can measure all form of power as well as power factor by measuring the voltage and current in the circuit. Following section discusses the steps taken to obtain the measurements that are required to calculate the energy consumption.

 

The AC current is conventionally measured by using a Current transformer. ACS712 was chosen as the current sensor because of its low cost and smaller size. The ACS712 Current Sensor is a Hall Effect current sensor that accurately measures current when induced. The magnetic field around the AC wire is detected which gives the equivalent analog output voltage. The analog voltage output is then processed by the microcontroller to measure the current flow through the load.

 

More on Hall effect

 

Hall Effect is the production of a voltage difference (the Hall voltage) across an electrical conductor, transverse to an electric current in the conductor and a magnetic field perpendicular to the current.

 

Image result for hall effect

                [Picture courtesy from respective sources]

 

To know more about the ACS712 sensor and its working, use this link.

 

The output from the ACS712 Current Sensor is an AC voltage wave. The following calculation are done:

 

  1. Measuring the peak to peak voltage ( Vpp )
  2. Divide the peak to peak voltage(Vpp) by two to get peak voltage (Vp)
  3. Multiply Vp by 0.707 to get the rms voltage (Vrms)
  4. Multiply the Sensitivity of the current sensor ( ACS712 ) to get the rms current.

 

Mathematically, we have:

[The following are the basic current consumption measurement equations]

 

Vp = Vpp/2

Vrms = Vp x 0.707

Irms = Vrms x Sensitivity

The sensitivity for ACS712 5A module is 185mV/A ,20A module is 100mV/A and 30A module is 66mV/A.

 

Real Power (W) = Vrms x Irms x pf

Vrms = 230V (known for India)

pf = 0.85 (known)

Irms = Obtained using above calculation

 

For calculating the energy cost, the power in watts is converted into energy:

Wh = W * (time / 3600000.0)

Watt hour a measure of electrical energy equivalent to a power consumption of one watt for one hour.

For calculating kWh:

kWh = Wh / 1000

The Total Energy cost is:

Cost = Cost per kWh * kWh.

 

The information is then displayed onto the LCD display.

 

The below figure depicts the prototype under testing.

 

Modifications (In Progress)

 

  • The Arduino UNO is being replaced by an Arduino MKR Zero
  • Additional functionality of logging to SD Card
  • Cloud connection, Interface and data logging
  • Generation of Automatic usage reports

 

Code

 

//-------------------------------------------------------------------------------//
//-- PROGRAM GOALS                                                               //
//-- A smart energy monitoring system that will ease the inspection,             //
//-- monitoring, analysis, and calculation of energy fare.                       //
//-------------------------------------------------------------------------------//

#include "rgb_lcd.h"

#define Pin A0
rgb_lcd lcd;
const int chipSelect = 43;
const int house_id = 1;
const int averageValue = 10;
int sensorValue = 0;
float sensitivity = 1000.0 / 800.0;
float Vref = 265;
String msg = "";
unsigned int Sensitivity = 185;
float Vpp = 0; // peak-peak voltage 
float Vrms = 0; // rms voltage
float Irms = 0; // rms current
float Supply_Voltage = 233.0;           // reading from DMM
float Vcc = 5.0;         // ADC reference voltage // voltage at 5V pin 
float power = 0;         // power in watt              
float Wh =0 ;             // Energy in kWh
unsigned long last_time =0;
unsigned long current_time =0;
unsigned long interval = 100;
unsigned int calibration = 100;  // V2 slider calibrates this
unsigned int pF = 85;           // Power Factor default 95
float bill_amount = 0;   // 30 day cost as present energy usage incl approx PF 
unsigned int energyTariff = 8.0; // Energy cost in INR per unit (kWh)

void setup() 
{
    Wire.begin();

    lcd.begin(16, 2);
    delay(1000);

    pinMode(SS, OUTPUT);
    if (SD.begin(chipSelect)) 
    {
      sd_write = 1;
      dataFile = SD.open("STEMS_log.txt", FILE_WRITE);
      dataFile.println("Project STEMS");
      dataFile.println("by Jiss");
      dataFile.println("");
    }

    lcd.setCursor(0, 0);
    lcd.print("Project STEMS");
    lcd.setCursor(0, 1);
    lcd.print("By Jiss");

    delay(1000);

    lcd.setCursor(0, 0);
    lcd.print("House ID -->");
    lcd.setCursor(0, 1);
    lcd.print(vehicle_id);
    if(sd_write)
    {
      dataFile.println("House_id: " + house_id);
    }
}

void loop() 
{
  for (int i = 0; i < averageValue; i++)
  {
    sensorValue += analogRead(Pin);
    delay(2);
  }

  sensorValue = sensorValue / averageValue;
  float unitValue= RefVal / 1024.0*1000 ;
  float voltage = unitValue * sensorValue-Vref;
  float current = (voltage - Vref) * sensitivity;

  Vpp = voltage;
  Vrms = (Vpp/2.0) *0.707; 
  Vrms = Vrms - (calibration / 10000.0);
  Irms = (Vrms * 1000)/Sensitivity ;
  if((Irms > -0.015) && (Irms < 0.008))
  {
    Irms = 0.0;
  }
  power= (Supply_Voltage * Irms) * (pF / 100.0); 
  last_time = current_time;
  current_time = millis();    
  Wh = Wh+  power *(( current_time -last_time) /3600000.0) ; 
  // calculating energy in Watt-Hour
  bill_amount = Wh * (energyTariff/1000);

    lcd.setCursor(0, 0);
    lcd.print("Current -->");
    lcd.setCursor(0, 1);
    lcd.print(current + " mA");
    if(sd_write)
    {
      dataFile.println("Current: " + current);
    }

    lcd.setCursor(0, 0);
    lcd.print("Power -->");
    lcd.setCursor(0, 1);
    lcd.print(power + " W");
    if(sd_write)
    {
      dataFile.println("Power: " + power);
    }

    lcd.setCursor(0, 0);
    lcd.print("Bill Amount -->");
    lcd.setCursor(0, 1);
    lcd.print(bill_amount + "INR");
    if(sd_write)
    {
      dataFile.println("Bill Amount: " + bill_amount);
    }

  sensorValue = 0;
  delay(1000);
}