OK bear with me, I am at my office now so I can't test the code but I think I understand now.
Here is the code for Emonlib.h
class EnergyMonitor
{
public:
void voltage(int _inPinV, double _VCAL, double _PHASECAL);
void current(int _inPinI, double _ICAL);
void voltageTX(double _VCAL, double _PHASECAL);
void currentTX(int _channel, double _ICAL);
void calcVI(int wavelengths, int timeout);
double calcIrms(int NUMBER_OF_SAMPLES);
void serialprint();
long readVcc();
//Useful value variables
double realPower,
apparentPower,
powerFactor,
Vrms,
Irms;
private:
//Set Voltage and current input pins
int inPinV;
int inPinI;
//Calibration coeficients
//These need to be set in order to obtain accurate results
double VCAL;
double ICAL;
double PHASECAL;
//--------------------------------------------------------------------------------------
// Variable declaration for emon_calc procedure
//--------------------------------------------------------------------------------------
int lastSampleV,sampleV; //sample_ holds the raw analog read value, lastSample_ holds the last sample
int lastSampleI,sampleI;
double lastFilteredV,filteredV; //Filtered_ is the raw analog value minus the DC offset
double lastFilteredI, filteredI;
double phaseShiftedV; //Holds the calibrated phase shifted voltage.
double sqV,sumV,sqI,sumI,instP,sumP; //sq = squared, sum = Sum, inst = instantaneous
int startV; //Instantaneous voltage at start of sample window.
boolean lastVCross, checkVCross; //Used to measure number of times threshold is crossed.
int crossCount; // ''
};
In the original sketch there is a piece of code:
emon1.calcVI(20,2000);
It looks to me this is a reference to the code below:
void calcVI(int wavelengths, int timeout);
I guess this part means I should be able to call it in a sketch right?
double realPower,
** apparentPower,**
** powerFactor,**
** Vrms,**
** Irms;**
using:
emon1.realPower
emon1.apparentPower
emon1.powerFactor
emon1.Vrms
emon1.Irms
Is this correct or not?