The scheme is like this (with a 100_Ohm resistor instead of an led);
The current is DC.
The values are like this:
-0.81 A
2.35 Volts
average: -0.8445
-0.81 A
2.35 Volts
average: -0.8451
-0.75 A
2.36 Volts
average: -0.8485
-0.89 A
2.34 Volts
average: -0.8476
-0.96 A
2.32 Volts
average: -0.8531
-0.86 A
2.34 Volts
average: -0.8521
-0.91 A
2.33 Volts
average: -0.8573
Where A is ampers, volts are analoginput Volts and average is the Amperes averaged on 1000 samples.
I can not find a bug in the your sketch, but the sketch is not displayed well.
Can you put the sketch between < code > and < / code > tags ? It is the button with the scroll and the "<>".
The 5A version of the ACS712 is 185mV per Amp. I think your calculation is okay.
The ACS712 can measure the current in both directions.
The output is VCC/2 when there is no current.
If the voltage of the Arduino would be a perfect 5.00V, the output of the ACS712 should be 2.50V.
I think you use the USB to power your Arduino board. That is why the 5V is lower. The average of 1000 samples should normally be very stable, but your values might not be stable because the USB 5V is not stable.
Could you remove the load, and measure the 5V and the output of the ACS712. Is the output half of the value of the 5V ?
Peter_n:
The ACS712 can measure the current in both directions.
The output is VCC/2 when there is no current.
If the voltage of the Arduino would be a perfect 5.00V, the output of the ACS712 should be 2.50V.
I think you use the USB to power your Arduino board. That is why the 5V is lower. The average of 1000 samples should normally be very stable, but your values might not be stable because the USB 5V is not stable.
Could you remove the load, and measure the 5V and the output of the ACS712. Is the output half of the value of the 5V ?
You are right, I'm using arduino as power source (via USB). I use two different pins (5v and pin 5) to try to get ''clean'' result.
The ACS712 sends mostly negative values (below 2.5V) even though the current is positive (measured with multimeter).
You mean I measure the ouput of ACS when I connect it directly between the pin5 (or pin 5V) and the ground ? Wouldn't that be a short circuit which could fry something ?
No, measure the output when there is no current. Just remove the "load". I mean the "load" in the picture, the light bulb or led or resistor of 100 ohm.
Without load, can you use a multimeter to measure the voltage of the 5V pin and the output of the ACS712.
It is ~ 4.42 on Pin 5 (it varies between 4.35 and 4.5).
This is the pin with which I connect the load and acs712 with.
Now I need to modify the scheme in accordance with this ? Do I also need to measure the 5V pin (power for ACS712), does that one also has an effect on my circuit ?
Pin 5 ? Which pin is that ? I hope you use the "5V" pin and not the digital pin 5.
You could you make a photo of your wiring and attach it to a post.
If the 5V pin is 4.42V, that is low. Do you have a cheap USB cable or a laptop ?
You could use a power supply of 7.5V to 9V to the DC barrel jack (if you have an Arduino Uno).
Well, a breadboard has sometimes bad contacts, they can cause troubles.
Is there a reason why digital pin 5 (called 'pet' in the sketch ?) is used ?
Could you remove the load, to see if it is possible to measure 0 amps, and connect the sensor in a normal way:
Connect Arduino 5V pin to ACS712 module VCC.
Connect Arduino GND pin to ACS712 module GND.
Connect Arduino A1 to ACS712 module OUT.
Peter_n:
Well, a breadboard has sometimes bad contacts, they can cause troubles.
Is there a reason why digital pin 5 (called 'pet' in the sketch ?) is used ?
Could you remove the load, to see if it is possible to measure 0 amps, and connect the sensor in a normal way:
Connect Arduino 5V pin to ACS712 module VCC.
Connect Arduino GND pin to ACS712 module GND.
Connect Arduino A1 to ACS712 module OUT.
Thats why I used the 'pet' pin. If you do it like that, how do I measure any current (I need another source, the ''battery'' on the picture above, so I used 'pet' as my 'battery').
I connected it like you said (just the 3 pins you told me, so 0 -current should be on measuring leads ?), and here is what I get on analogeread:
-0.22 A
2.46 Volts
average_amps: -0.1921
-0.09 A
2.48 Volts
average_amps: -0.1941
-0.33 A
2.44 Volts
average_amps: -0.1866
-0.04 A
2.49 Volts
average_amps: -0.1839
-0.17 A
2.47 Volts
average_amps: -0.1851
-0.41 A
2.42 Volts
average_amps: -0.1879
-0.20 A
2.46 Volts
average_amps: -0.1846
-0.30 A
2.44 Volts
average_amps: -0.1821
-0.17 A
2.47 Volts
average_amps: -0.1882
-0.20 A
2.46 Volts
average_amps: -0.1875
-0.09 A
2.48 Volts
average_amps: -0.1898
-0.17 A
2.47 Volts
average_amps: -0.1872
-0.28 A
2.45 Volts
average_amps: -0.1840
-0.17 A
2.47 Volts
average_amps: -0.1867
-0.09 A
2.48 Volts
average_amps: -0.1906
-0.28 A
2.45 Volts
average_amps: -0.1915
-0.33 A
2.44 Volts
average_amps: -0.1850
-0.17 A
2.47 Volts
average_amps: -0.1897
-0.12 A
2.48 Volts
average_amps: -0.1858
-0.25 A
2.45 Volts
average_amps: -0.1925
-0.09 A
2.48 Volts
average_amps: -0.1910
-0.04 A
2.49 Volts
average_amps: -0.1895
It doesn't measure the 2.5V as 0, (as the 5V pin doesn't give the full 5V, with a multimeter I get around 4.55, 4.6V).
Perhaps something is not connected right, using the USB power should not cause oscillation.
I'm sorry, but I still no idea how you have connected it. I also don't have you sketch between code tags, so I can not try your sketch.
What is your goal ? To measure the output current of digital pin ?
A value of -0.19A for a 5A range is 4%. That is getting closer, but still not good enough.