Vcc calibration of EMON

using arduino on USB power and a uSD card shield ( DFRobot interface shield (run uSD with 5V!!))

cpu power drops below 4.8V what is a measuring error of 4%.

pls see:  code.google.com/p/tinkerit/wiki/SecretVoltmeter

Vcc readback
long readVcc() {
// call: readVcc();
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate AVcc in mV
return result;
delay(100);
}

 

EMON // KLL
VCCread=readVcc();
// calibrate on Vcc in millivolt
V_RATIO = AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE * AC_VOLTAGE_DIV_RATIO * VCCread / 1024.0 * VCAL / 1000.0;
I_RATIO = CT_TURNS / CT_BURDEN_RESISTOR * VCCread / 1024.0 * ICAL / 1000.0;

the calibration runs one time, prior to the 3000 Ain loop.

 

TrystanLea's picture

Re: Vcc calibration of EMON

Thanks for the heads up, we use this already on the emontx, It means the battery voltage can vary from 3.5 all the way down as they discharge and the measurements are kept accurate

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.