Energy monitor with acs712_5a

my project is lowest energy consumption in circuit, now I want to monitor power usage in circuit but I got a big problem.

when the sensor get data from sensor and send to server via esp8266-01(wifi module)
amp value is around 90-100 ma

my code make IC sleep(sleep.h) after data is sent to server, now problem occur
amp value is around 110-130 ma

my question
1.why amp value when sleep is more than amp value when get data from sensor?

2.I can use follow equation or not?
amp when sleep - amp when doing = energy reduced
130 - 100 = 30 ma (30 ma energy reduced)

help me please :slight_smile:
see the picture
v
v
v

Untitled.png

help me please :slight_smile:
see the picture

Help me please
post your code :slight_smile:

UKHeliBob:
Help me please
post your code :slight_smile:

my sensor code

void loop() {
wifiModuleControl();// this method is get sensor data and send to server

delay(500);
Serial.println("sleep z Z Z ");

delay(2000);
for(sleepLoop = 0; sleepLoop < 75; sleepLoop++){
Serial.println("sleep " + String(sleepLoop));
delay(100);
ADCSRA = 0;
MCUSR = 0;
WDTCSR = bit (WDCE) | bit (WDE);
WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);
wdt_reset();

set_sleep_mode (SLEEP_MODE_PWR_DOWN);
noInterrupts ();
sleep_enable();

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);
}

Can you please post your whole program, not just part of it, and when you do use code tags (far left icon above the editor) to make it more manageable

int rawValue = 0;
That can hold a maximum of 32767

for(int i = 0; i < 1000; i++) reads the A/D 1000 times
That could be 1023000

rawValue is likely overflowing.

Use:

unsigned long rawValue = 0;

Leo..