Hello world,
I'm doing a project to measure AC current / voltage in the main line ( when an appliance is connected to a wall socket ). 230V AC main line.
And I'm using ALLEGRO ACS-758-LCB-050A current sensor for current measurement.
( the acs758 sensor produces an voltage output when a current is flowing through the IC ; sensitivity of the IC is 40mV/A )
But the measured voltage is not stable and fluctuating often .
When I turn the arduino ( ATMEGA328P ) ic on, with no load connected to the project ( so there is no current flowing through the current measuring IC ) then it gives a ADC value around 506 ( this varies in between 505 - 510 with no load connected ).
But when I connect a load ( then there is a current flowing through the IC ), the ADC read value start to fluctuate very fast. And the ADC value drops to 450 even . So it then fluctuate from 450 - 570 .
So my problem is, how this drops to 450 with a load connected ? ( without a load, the reading is stable between 505 - 510 ; so if there is a load connected probably this adc read value must be increased but must not drops below 505 as i know )
The code I used is below . Comments are highly appreciated ! XD
LOAD I USED = A WATER HEATER ( since I couldn't find any other high current appliances from around )
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);const int numReadings = 30;
float readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
float total = 0; // the running total
float average = 0; // the averagefloat currentValue = 0;
void setup()
{
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
lcd.begin(16, 2);
}
void loop()
{
total= total - readings[index];
readings[index] = analogRead(A3); //Raw data reading
readings[index] = (readings[index]-510)*5/1024/0.04-0.04;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
total= total + readings[index];
index = index + 1;
if (index >= numReadings)
index = 0;
average = total/numReadings; //Smoothing algorithm from (http://www.arduino.cc/en/Tutorial/Smoothing)
currentValue= average;
// Serial.println(currentValue);
// delay(30);lcd.setCursor(0, 1);
lcd.print(analogRead(A3));
// Serial.println( readVcc(), DEC );
delay(200);
}