OK I will try what you said when I get home.
Do I use you code like the following example?
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of wavelengths, time-out
mySerial.write(254); // cursor to 4th position on first line
mySerial.write(131);
mySerial.print(emon1.getVrms()); // write out the VAC value
mySerial.write(254); // cursor to 4th position on second line
mySerial.write(195);
mySerial.write(emon1.getIrms()); // write out the AAC value
mySerial.write(254); // cursor to 4th position on second line
mySerial.write(204);
mySerial.write(emon1.getApparentPower()); // write out the AAC value
delay(1000); // short delay
}
You said that the 5 values are private but these are located above the keyword private: aren't they public then?
This part is public:
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;
And this part is private:
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; // ''