MCUCR = bit (BODS) | bit (BODSE);
MCUCR = bit (BODS);
interrupts ();
sleep_cpu ();
sleep_disable();
}
}
ISR (WDT_vect)
{
wdt_disable();
}
////////////////////////////////////////////////////////////////////////////////////////
my current monitor code
float testCurrentCal(){//not compare value to meter
const int analogIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawValue= 0;
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;
for(int i = 0; i < 1000; i++) {
// 0-5 = 0-1023 // vIn/analogIn = 5/1023
RawValue = RawValue+analogRead(analogIn);
delay(1);
}
RawValue=RawValue/1000.0+15.0; // +15 make default value = 0
Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp)+13.514; // +13.514 make deafult value =0
Serial.print("Raw Value = " ); // shows pre-scaled value
Serial.print(RawValue);
Serial.print("\t mV = "); // shows the voltage measured
Serial.print(Voltage,3); // the '3' after voltage allows you to display 3 digits after decimal point
Serial.print("\t Amps = "); // shows the voltage measured
Serial.println(Amps,3); // the '3' after voltage allows you to display 3 digits after decimal point
delay(100);
}