Httpsforum Arduino Cctenergy-Moniotr629438
Httpsforum Arduino Cctenergy-Moniotr629438
h>
#include <LiquidCrystal_I2C.h>
#include <TimedAction.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C
address
#include <EEPROMex.h>//Include EEPROMX writes float values
#include <Adafruit_ADS1015.h> //Include the libarary for 16Bit A/D converter
Adafruit_ADS1115 ads1115; //Sets' 16bit mode
#define ADS1115_REG_CONFIG_DR_860SPS//Set A/D converter regisiters
#define VOLTS_CHAN0 0 //Cylinder Pressure voltage channel
#define VOLTS_CHAN1 1 //Angle transducer channel
Adafruit_ADS1115 ads; /* Use this for the 16-bit version */
float Vmultiplier = 0.0001875F; // used to convet readings this is calculated
const unsigned long intervaloLectura = 200; //inervalo de lectura de sensores
[milisegundos]
float P;
//####### AV VOLTS #####################
uint16_t Read_AC_volts;
float AC_volts;
float AC_volt_temp;
float AC_Volts_Result;
//####### AV AMPS #####################
uint16_t Read_AC_amps;
float AC_amps;
float AC_Amp_temp;
float AC_amps_Result;
//########################
float bill_amount = 0; // 30 day cost as present energy usage incl approx PF
float energyTariff = 17.58; // Energy cost in INR per unit (kWh)
float cost;
float Killo_watts;
//
===================================================================================
=======
void TimerService01();// ADC ROUTINE Timed action
TimedAction Timedact01 = TimedAction(80, TimerService01);// mS
void TimerService02();//LCD timed actions
TimedAction Timedact02 = TimedAction(250, TimerService02);// mS
long day1 = 86400000; // 86400000 milliseconds in a day
long hour1 = 3600000; // 3600000 milliseconds in an hour
long minute1 = 60000; // 60000 milliseconds in a minute
long second1 = 1000; // 1000 milliseconds in a second
unsigned long startMillisec;
int days;
int hours = 1;
int mins, secs;
int tMins;
void setup() {
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV
(default)
ads.begin(); //start the 16bit A/D converter
lcd.begin(20, 4);
void loop() {
getTime();
Timedact01.check(); // Read ADC values
P = AC_Volts_Result * AC_amps_Result; // convert to whats
Killo_watts = P / 1000; // convert to killowatss
cost = energyTariff / 100; //set the cost of electric
bill_amount = hours * ( Killo_watts) * cost;
Timedact02.check(); // Display the data
}
/* === Generic routine for hours, minutes and seconds between two millis()
values.===*/
void getTime() {
}
//##Dipslay the data
void TimerService02() {
lcd.setCursor(0, 0);
lcd.print(AC_Volts_Result);
lcd.print("AC ");
lcd.print(AC_amps_Result);
lcd.print("AMP ");
lcd.setCursor(0, 1); // Displays all current data
lcd.print(Killo_watts);
lcd.print(" kWh HOURS");
lcd.setCursor(0, 2);
lcd.print(days);
lcd.print(":");
lcd.print(hours);
lcd.print(":");
lcd.print(mins); //second1
lcd.print(":");
lcd.print(secs); //second1
lcd.print(" TIME");
lcd.setCursor(0, 3);
lcd.print(bill_amount, 3);
lcd.print(" kWh COST");