hi guys.. i have developed a project where i am using acs712 current sensor to measure current of home appliances i.e ac load connected to 230v AC mains.when i dont connect any load its showing 0.18 amps. when i connect a 15W bulb it shows 0.31 amps but its fluctuating from 0.26 Amp to 0.31 amp. also when i connect a bigger load like a soldering iron it doesnt show any significant change in current. please help me with the code.
your help would be much appreciated.
below is the code:
const float acsOut =A0;
int acsSensitivity =66;
float voltage =0;
float vRms=0;
float ampRms=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float voltage =getVpp();
vRms =(voltage/2.0)*0.707;
ampRms =(vRms*1000)/acsSensitivity;
Serial.println("amps Rms");
Serial.println(ampRms);
}
float getVpp()
{
float result;
int readValue;
int maxValue=0;
int minValue=1024;
uint32_t start_time=millis();
while((millis()-start_time < 1000))
{
readValue =analogRead(acsOut);
if(readValue > maxValue)
{
maxValue=readValue;
}
if(readValue < minValue)
{
minValue=readValue;
}
}
result=((maxValue-minValue)*5.0)/1024.0;
return result;
}
I am currently facing a similar problem. How did you solve it?
If you have similar problems, you might made the same errors in the setup. Post a wiring diagram of your setup and post your code. The OP's code does read maxima/minima values which usually don't make sense.
pylon:
The OP's code does read maxima/minima values which usually don't make sense.
It does if you want to read AC current.
OP did use a 30Amp sensor (the 66mV/A).
That, and the 10-bit A/D of an Arduino, will give a resolution of about 20watt per A/D step.
Too course to detect a 15watt lightbulb.
Leo..
P.S. The ACS712, and the boards they are mounted on, are not designed for 230volt mains.
A (clip-on) current transformer is much safer.
Leo..
P.S. The ACS712, and the boards they are mounted on, are not designed for 230volt mains.
But, the data sheets of ACS712 has provided the following information which indicates that there is ensured/tested isolation between the 230V hot circuit and the low voltage side!
The datasheet also mentions a max working voltage of 184volt peak (~128volt AC).
AFAIK 230volt AC requires 4kV test isolation.
There is also the ACS758.
Leo..