ACS723 low current AC 220V

Hi all,

I bought an ACS723 low current at SparkFun, this sensor can measure AC and DC low current, but when I try to measure AC current (100mA) sensor doesn't work, is anyone have already used this sensor with 220v ??
My output never change for AC current.

He works weel with DC current (same current 100mA)

Where is you code you used? Please read How to use the forum before posting it.

PS Yes, it can do AC current, but it only gives you the instantaneous current. Aka, you have to time the measurements and/or do RMS/average calculations.

Yes sorry here is my code (this code came from SparkFun I've updated this by adding VRMS = (voltage/2.0) * 0.707 found at http://henrysbench.capnfatz.com/henrys-bench/arduino-current-measurements/acs712-arduino-ac-current-tutorial/)

const int analogInPin = A0;

// Number of samples to average the reading over
// Change this to make the reading smoother... but beware of buffer overflows!
const int avgSamples = 10;

int sensorValue = 0;

float sensitivity = 100.0 / 500.0; //100mA per 500mV = 0.2
float Vref = 2570; // Output voltage with no current: ~ 2500mV or 2.5V

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

double VRMS = 0;
void loop() {  
  // read the analog in value:
  for (int i = 0; i < avgSamples; i++) {
    sensorValue += analogRead(analogInPin);
    delay(2);
  }

  sensorValue = sensorValue / avgSamples;

  // The on-board ADC is 10-bits -> 2^10 = 1024 -> 5V / 1024 ~= 4.88mV
  // The voltage is in millivolts
  float voltage = 4.88 * sensorValue;
  VRMS = (voltage/2.0) * 0.707; 
}

VRMS nerver change with or without charge

You are averaging a sinusoidal signal, which is always close to 0.

RMS = root-mean-square, look it up :wink:

couka:
You are averaging a sinusoidal signal, which is always close to 0.

RMS = root-mean-square, look it up :wink:

Ok how can I accomplish that ? This code isn't good ?

float voltage = 4.88 * sensorValue;
VRMS = (voltage/2.0) * 0.707;

simon884:
Ok how can I accomplish that ?

As I already said, look up what RMS really is and how to calculate it.

You are just measuring the average value, not the RMS-value.

You also need to zero out sensorValue at the beginning of loop()