0

So I have the basic setup ready with one relay that is controlling a 200W bulb. The Phase of this bulb is passed through a current sensor acs712. While running a simple analog read example sketch, I get output 511 from ADC, which is as expected. Then I subtracted this 511 from my measurement and observed the results while turning on/off the bulb.

int sensorValue;
void setup()
{
 Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
 sensorValue = analogRead(0); // read analog input pin 0
 Serial.println((511-sensorValue), DEC); // prints the value read
 delay(100); // wait 100ms for next reading
}

Here is the output graph;

enter image description here

While the bulb is off, the current remains 0, but when I turn on the bulb, the voltage fluctuates over positive and negative side. Why is the sensor showing this behavior ?, I am not using any additional capacitor for noise reduction. Do I need to ? but I guess this is not noise. Is it ?

asked Jul 10, 2016 at 18:25

1 Answer 1

0

You are seeing that because that is what the current is doing. It's called AC - Alternating Current. It's what the mains current is.

To work with AC you have to rapidly sample over a short period to get the maximum and minimum values. Subtract one from the other and that gives you the peak-to-peak current. You can then use that to calculate the RMS current which is what you are (most likely) interested in.

answered Jul 10, 2016 at 18:39
4
  • oh now I got that... Thank you so much :), got the code from henrysbench.capnfatz.com/henrys-bench/… and its working now Commented Jul 10, 2016 at 19:01
  • I'm not sure if that is the case here. Since it's AC the current would also be negative half the time, and we are not seeing this here. The acs712 seems to be made for AC, though I couldn't understand enough of the datasheet to say anything useful. Commented Jul 10, 2016 at 19:02
  • @Gerben It is negative, but around a 2.5V DC offset. That's the 511 reading Anum mentions. Commented Jul 10, 2016 at 19:04
  • Ahhh. Silly me. (-: Commented Jul 10, 2016 at 19:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.