0% found this document useful (0 votes)
39 views3 pages

Power Meter With Load

This document summarizes a smart energy meter project that monitors energy usage using an Arduino board and LCD display. It includes code to: 1) Read voltage and current sensors and calculate RMS power consumption over time. 2) Display real-time power, voltage, current and accumulated energy usage on the LCD screen. 3) Allow toggling a transistor switch using a button to control a load. 4) Log sensor readings and calculations to the serial monitor.

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Power Meter With Load

This document summarizes a smart energy meter project that monitors energy usage using an Arduino board and LCD display. It includes code to: 1) Read voltage and current sensors and calculate RMS power consumption over time. 2) Display real-time power, voltage, current and accumulated energy usage on the LCD screen. 3) Allow toggling a transistor switch using a button to control a load. 4) Log sensor readings and calculations to the serial monitor.

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*

Smart Energy Meter and Monitoring using ElectroSaving App


Khalid Akram (17EL12)
Ansar Bilal (17EL32)
Muhammad Fahad (16/17EL34)
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
const int sensorIn = A0;
const int buttonPin = 12;
const int transistorPin = 8;

int buttonState = 0;
int mVperAmp = 78;

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double kilos = 0;
int peakPower = 0;

void setup()
{

pinMode(buttonPin, INPUT_PULLUP);
pinMode(transistorPin, OUTPUT);

Serial.begin(9600);
lcd.begin(20, 4);
lcd.clear();
lcd.setCursor(6,1);
lcd.print(" WELCOME");
lcd.setCursor(5,2);
lcd.print("Energy Meter");

delay(1000);
lcd.clear();

void loop()
{
int sensorValue = analogRead(A1);
float volt = sensorValue * (241.0 / 1023.0);

Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707
AmpsRMS = (VRMS * 1000)/mVperAmp;

int RMSPower = volt * AmpsRMS; //Calculates RMS Power Assuming Voltage 220VAC,
change to 110VAC accordingly
if (RMSPower > peakPower)
{
peakPower = RMSPower;
}
kilos = kilos + (RMSPower * (2.05/60/60/1000)); //Calculate kilowatt hours
used
delay (2000);
buttonState = digitalRead(buttonPin);

if (buttonState == LOW)
{

digitalWrite (transistorPin, HIGH);

else
{

digitalWrite (transistorPin, LOW);

Serial.print("\t AC Voltage = ");


Serial.print(volt);
Serial.println(" Volt");
Serial.print("\t \t AC Current = ");
Serial.print(AmpsRMS);
Serial.println(" Amps");
Serial.print("\t \t \t Power = ");
Serial.print(RMSPower);
Serial.println(" Watt");
Serial.print("\t \t \t \t Energy = ");
Serial.print(kilos);
Serial.println(" Kwh");

lcd.setCursor(0, 0);
lcd.print("V="); lcd.print(volt);
lcd.setCursor(0, 1);
lcd.print("I=");lcd.print(AmpsRMS);
lcd.setCursor(0, 2);
lcd.print("P="); lcd.print(RMSPower);
lcd.setCursor(0, 3);
lcd.print("Kwh=");lcd.print(kilos);

delay(1000);
}

float getVPP()
{
float result;
int readValue; //value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1023; // 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 minimum sensor value*/
minValue = readValue;
}
}

// Subtract min from max


result = ((maxValue - minValue) * 5.0)/1023.0;

return result;
}

You might also like