Code
Code
The main object of the project is to develop smart energy meter is not only measure
the consumer’s power consumption in KWH but also to enable and support real
consumption in rupees according to consumer tariff, so meter reader don’t need to
visit each customer for the consumed data collection and to distributed the bill
slips. In our invented meter we do not have any rotating parts .The energy
consumption is calculated using measurement voltage and current with help of
potential divider and ACS712 ,measure voltage and current respectively. Power
product of voltage and current, its unit watt or KW and energy is product of power
(watt) and time (Hour). so we use mentioned standard formula and using Arduino
Microcontroller Programming , we are calculating total energy consumption of
consumer load. Microcontroller has an interface in size of 16*2 LCD, it shows
important data dimensions such as voltage, current,active and power and energy
consumption it also shows power qualities.
/*
@Author : Mayur Khatri
Description: Smart Energy Meter
Last Edited: 01-May-2016
Implementatation: GSM Module shield implementation with arduino tested with LCD.
*/
#include <SoftwareSerial.h>
#include <LiquidCrystal.h> // Importing LCD Library file
/*
* RS: Pin 12
* EN: Pin 11
* D4: Pin 5
* D5: Pin 4
* D6: Pin 3
* D7: Pin 2
*/
LiquidCrystal lcd (12, 11, 5, 4, 3, 2); //lcd display pin
char mobileNumber; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(9, 10);
const int voltageSensor = A0; // voltage pin
const int currentSensor = A1; // current pin
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module
double sumWH = 0.00000;
float WH = 0;//energy consumption in watt hour
double sumRupees = 0.00000;//Total energy consumption in rupees
float rupees = 0;//energy consumption in rupees
double Voltage = 0;//AC supply peak voltage
double vrms = 0;//AC supply rms voltage
double current = 0;//load peak current
double irms = 0;//load rms current
double power = 0;//
void setup()
{
Serial.begin(19200);
SIM900.begin(19200);
delay(500);
SIM900.print("AT+CLIP=1\r"); // turn on caller ID notification , to get missed
call number
delay(100);
lcd.begin(16,2); // Display Columms, Rows and Size
lcd.clear();
delay(100);
SIM900.println((char)26); // ASCII code of CTRL+Z
delay(100);
}
void energyCalculations()
{
// getting voltage from Input PIN
Voltage = getVPP(0);
vrms = (Voltage / 2.0) * 0.707 * 575; //find total voltage
Serial.print("VOLTAGE : ");
Serial.print(vrms);
Serial.println("Volt");
// getting current from Input PIN
current = getVPP(1);
irms = (current / 2.0) * 0.707 * 1000 / mVperAmp;
// Serial.print("CURRENT :");
// Serial.print(irms);
// Serial.println("Amps");
power=(vrms * irms * 0.3099);
//Serial.print("POWER :");
// Serial.print(power);
//Serial.println("watt");
WH = (power / 3600);
//Serial.print("ENERGY CONSUMED :");
//Serial.print(WH);
//Serial.println("Watt-Hour");
rupees = getReading();
// Serial.print("ENERGY CONSUMED IN RUPEES :");
//Serial.print(rupees);
// Serial.println("Rs.");
lcd.print("w");
//delay(1000);
lcd.clear(); // clear the screen
lcd.setCursor(1,0); // set the cursor at 1st col and 1st row
lcd.print(WH);
lcd.print("WH ");
void loop()
{
energyCalculations();
gsm();
//if(SIM900.available() > 0)
// {
// Serial.println("Inside SIM900 avaialble");
// Serial.write(SIM900.read());
// delay(200);
// }
void gsm()
{
//Serial.println("Inside GSM");
if(SIM900.available() > 0)
{
//Serial.println("SIM900 is available");
delay(10);
mobileNumber = SIM900.read();
Serial.print(mobileNumber);
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
delay(10);
mobileNumber = SIM900.read();
if(mobileNumber == 'X')
{
// delay(10);
Serial.println("Number Matched !");
Serial.println("Sending Billing to Customer");
//delay(90000);
sendBilling();
}
}
}
}
}
}
}
}
}
}
}
}
return result;
}
float getReading()
{
float solution;
return solution;