Hi,
I am using an ACS712 with puts out 2.56V in idle on my Analog0 Pin (measured with voltmeter between A0 and GND). The sample sketch for voltage measurement puts out 3.98. What can cause this?
Thanks!
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}
Every practical (real) sensor has gain and offset which are determined by 2-point calibration. The data sheets says that that the output sensitivity of the ACS712 current sensor is 66 to 185 mV/A. It looks like that the sensor possesses some offset in addition to gain.
The equation float voltage = sensorValue * (5.0 / 1023.0); is valid for a sensor which has no offset like LM35 Temperature Sensor. For your sensor, you have the idle response (idle to me 0A) is 2.56V. Now apply some current to the load (say, 5A) and measure the output voltage, and then you determine the response equation y = mx +C.
GolamMostafa:
For your sensor, you have the idle response (idle to me 0A) is 2.56V. Now apply some current to the load (say, 5A) and measure the output voltage, and then you determine the response equation y = mx +C.
The ACS712 is a RATIOMETRIC sensor.
Zero current output is therefore not a constant 2.5volt (or 2.56volt), but VCC/2.
Therefore A/D result is always ~512 at any supply voltage if you power the sensor from the MCU supply with default Aref. Assuming you stay within the voltage range of the sensor (4.5-5.5volt).
Sensor gain has AFAIK the same ratiometric behaviour.
Gain goes up with supply voltage and A/D goes down with voltage, resulting in a stable gain.
Leo..
The problem is that there is no ratiometric relationship between sensor supply and ~1volt Aref of the Wemos.
You never will have a stable zero and stable current readings.
For testing, change this line
float voltage = sensorValue * (5.0 / 1023.0);
into
float voltage = sensorValue * (3.3 / 1024.0);
I assume you know that the ACS712 (and the circuit boards) are not designed to measure 230volt AC.
Potentially very dangerous if you are planning to measure three fase currents in a metal/grounded cooktop.
Leo..
I will try your suggestion, in this case I am trying to measure the consumption of a washing machine. Which sensor is then suitable for 230v AC?
Thanks!
I tried something completely different now, with sucess.
I sent 3,3V to the ACS712 and tweaked the center of the RMS a bit and am now getting readings that make sense. The whole circuit is enclosed in a case, so I think it should be safe.
If you want to stick with the ACS712...
If you use a 180k resistor between sensor output and analogue-in, then the analogue input range of the Wemos is 0-5volt.
Then you can power the sensor from 5volt, and you should get about 512 without current (zero crossings).
5volt supply to the sensor must be stable.
Leo..
jankir:
I tried something completely different now, with sucess.
I sent 3,3V to the ACS712 and tweaked the center of the RMS a bit and am now getting readings that make sense. The whole circuit is enclosed in a case, so I think it should be safe.
The ACS711 is the 3V capable chip in the series, the ACS712 is 5V only...