acs712 current sensor 5A

Hi;
Im using acs712 to masseur dc current between 200ma to 5a
Im Having a serious problem
the Raw value of the analogPin that it connected to the sensor is really unstable !
when there is no load it changes from 509 to 519 ! when the recommended value is 512!
and when i connect 1 amper load it changes from 495 to 534 !
pleas any help !

Ayasab:
Im using acs712

the Raw value of the analogPin that it connected to the sensor is really unstable !
when there is no load it changes from 509 to 519 ! when the recommended value is 512!

and when i connect 1 amper load it changes from 495 to 534 !

  1. Which one. There are many with different current ranges.
    Don't expect a 30Amp model to measure 200mA reliably.
    200mA would only be ~three A/D values.

  2. Not uncommon with these hall sensors. They are noisy, and need averaging/smoothing code.

I assume you measure DC. Post your code (in code tags).
Leo..

Thank you for your reply :slight_smile:

  1. Im using ACS712T ELC-05B
  2. Im measuring load that show me on the multi-meter 1.15 Amper (its a matrix of LEDs)
  3. The Raw Value that presents the analog read is very unstable !
    Here is the code Which I use:
/*
Measuring Current Using ACS712
*/
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;

void setup(){ 
Serial.begin(9600);
}

void loop(){

RawValue = analogRead(analogIn);
Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);


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(2500); 

}

and here is an example with the attachments : (masuring 200maper load -masuring 1.15amper load-masuring when no load )

example of 00amper masur.png

example of 1.15amper masur.png

example of 200mamper masur.png

Behaviour seems normal for code without averaging/smoothing.
I think sensors like this need it.
Don't expect a granularity of 10,000 (+ - 5.000Amp) from a sensor with 2.5% accuracy and ~820 A/D values. Serial.println(Amps, 2); is more realistic.

Try this (untested).
Leo..

/*
Measuring Current Using ACS712
*/
const int analogIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
unsigned int RawValue = 0; // can hold upto 64 10-bit A/D readings
int ACSoffset = 2500;
double Voltage = 0;
double Amps = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (int x = 0; x < 64; x++) // 64 analogue readings for averaging
  {
    RawValue = RawValue + analogRead(analogIn); // add each A/D reading to a total
  }
  Voltage = ((RawValue / 64) / 1023.0) * 5000; // Gets you mV
  Amps = ((Voltage - ACSoffset) / mVperAmp);

  Serial.print("Raw Value = " ); // shows pre-scaled value
  Serial.print(RawValue / 64);
  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

  RawValue = 0; // reset value
  delay(2500);
}

Tested with a Nano with 10k between A0 and ground and 10k between 5volt and A0.
Had to change

int ACSoffset = 2500;
to
float ACSoffset = 2492.6;

That got me a stable 0.000Amp readout.
The ACS712 would ofcourse be worse than fixed resistors.
Have fun.
Leo..

Wawa:
Tested with a Nano with 10k between A0 and ground and 10k between 5volt and A0.
Had to change

what the resistors do in this case? I notes that NO mines reading appears when I connect the resistors !
the reading with 0 load is 0 almost time an d stable! :slight_smile:
and when i connect 200m ampere load the reading is between 0.159 and 0.185 ! It is good :slight_smile:
Now i think I have to add an error value that equals to 20% !??

What about measuring AC current ? But with a square wave Not a sine wave !? I think I have to start a new Topic !!
Thanks a lot " Wawa " .......appreciate your Time and Help ! :slight_smile:

I didn't have a sensor handy, so I used two resistors to mimic a sensor.
You shouldn't use them ofcourse.

Just load the software from post#3, and DON't connect anything to the sensor's current connector.
You should read as close to 0.000Amp as possible.

If the sensor doesn't output exact mid-voltage (has some offset), enter a slightly higher or lower value than 2500 in int ACSoffset = 2500; to compensate. Reload the sketch every time untill you have an average of 0.000Amp.

Change ACSoffset to a float for smaller steps (decimal place) if you have to, as I did in post#4.

Then send a known contant DC current through the sensor, e.g. 1Amp, and change that '185' number untill you have the right current reading.

What is the frequency of the square wave. Is it AC, or square/pulsing DC.
Leo..

Wawa:
What is the frequency of the square wave. Is it AC, or square/pulsing DC.
Leo..

its the out put of an inverter so i think it is pulsing DC.

A 12volt to 110 or 230volt inverter?
Note that you can't safely use the ACS712 for 230volt AC.
Leo..

It is a 12vdc to 220vac inverter
I see the wave on the oscilloscope and it is square

Maybe best to measure the 12volt current draw.
As said, those 712 sensors (and circuit boards) are not made for high (mains) voltage.
Leo..

my loads are very low current 40watt lamp and 50watt fan motor !

Wawa:
Maybe best to measure the 12volt current draw.

do you mean to measure the input dc current of the inverter?

Ayasab:
my loads are very low current 40watt lamp and 50watt fan motor !
do you mean to measure the input dc current of the inverter?

Yes.
Might be about 4Amp for a 40watt lamp.
A lot safer to measure the low voltage side with these sensors.
Leo..

Thanks a lot ........

I have faced same issue and found solution with 100% accuracy. You can download complete code, with video tutorial from following link.

...(Voltage -2.5)...

That assumes Aref is constant, and exactly 5.000volt.

Your code won't work on e.g. a Nano on USB supply (Aref = ~4.3volt).

Read up about ratiometric sensors.
Leo..

Hello, I have a problem using Acs712 current sensor 30A, I am measuring Ac Motor current, the out is unstable and -1xx.xx Amp.. Anyone know how to fix it ? My motor is 240V 5.4Amp