is that fine I make a bit changing in Emonlib.cpp add two lines for MUX before reading the analog value let me know if that configuration will go wrong in the calculation. if not then why I see garbage value while measuring current with no output load if the load is added then it works fine also it measure the voltage correctly but there is 4 to 5v variation when the board will get power on again why?
14.50, 18.96, 232.54, 0.08,0.76
13.23, 17.44 , 232.49, 0.07,0.76
14.37, 18.83, 232.38, 0.08, 0.76
13.25, 17.44, 232.32, 0.08, 0.76
14.61, 18.72, 232.41, 0.08, 0.78
13.14, 17.67, 232.32, 0.08, 0.74
14.48, 18.84, 232.32, 0.08, 0.77
13.11, 17.48, 232.36, 0.08, 0.75
14.67, 19.06, 232.28, 0.08, 0.77
13.20, 17.65, 232.30, 0.08, 0.75
14.36, 18.74, 232.22, 0.08, 0.77
while(st==false) //the while loop...
{
//-------------------------------Configration for slecting Voltage-------Select Y2--------------------
digitalWrite(D0,LOW);
digitalWrite(D1,HIGH);
//delay(1);
//-------------------------------------------------------------------------------------------
startV = analogRead(inPinV); //using the voltage waveform
if ((startV < (ADC_COUNTS*0.55)) && (startV > (ADC_COUNTS*0.45))) st=true; //check its within range
if ((millis()-start)>timeout) st = true;
}
while ((crossCount < crossings) && ((millis()-start)<timeout))
{
numberOfSamples++; //Count number of times looped.
lastFilteredV = filteredV; //Used for delay/phase compensation
//-----------------------------------------------------------------------------
// A) Read in raw voltage and current samples
//-----------------------------------------------------------------------------
//-------------------------------Configration for slecting Voltage-------Select Y2--------------------
digitalWrite(D0,LOW);
digitalWrite(D1,HIGH);
// delay(1);
//-------------------------------------------------------------------------------------------
sampleV = analogRead(inPinV); //Read in raw voltage signal
//-------------------------------Configration for slecting Current-----Select Y1----------------------
digitalWrite(D0,HIGH);
digitalWrite(D1,LOW);
// delay(1);
//-------------------------------------------------------------------------------------------
sampleI = analogRead(inPinI); //Read in raw current signal
for (unsigned int n = 0; n < Number_of_Samples; n++)
{
//-------------------------------Configration for slecting Current-----Select Y1----------------------
digitalWrite(D0,HIGH);
digitalWrite(D1,LOW);
// delay(1);
//-------------------------------------------------------------------------------------------
sampleI = analogRead(inPinI);
// Digital low pass filter extracts the 2.5 V or 1.65 V dc offset,
// then subtract this - signal is now centered on 0 counts.
offsetI = (offsetI + (sampleI-offsetI)/1024);
filteredI = sampleI - offsetI;
// Root-mean-square method current
// 1) square current values
sqI = filteredI * filteredI;
// 2) sum
sumI += sqI;
}