SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By hdias
#115876
Hi,

I bought the ACS712 Low Current Sensor Breakout - SEN-08883, but when I tried to use the sensor is not functioning as it should. I connected the sensor to a Arduino board and the sensor readings are always the same regardless of whether the sensor is connected to a circuit or not. I also tried to calibrate the sensor by following the procedure that is on the product page but without success. The information that exists on the Internet is minimal. Is there a manual or more information so I can see to put the sensor to work?

Thanks in advance,

Henrique Dias
By esklar81
#115907
Henrique,

I suggest you start by dividing this into whether the sensor board is working and whether the Arduino and its code are working.

If you put a voltmeter between the output terminal of the sensor board and its ground, do you get a voltage that varies with varying current?
  1. If not:
    1. Check your input power (not signal) and ground to the sensor board. Measure the voltage between the 5V and GND pins.
    2. Check that the current source you are using does, in fact, send varying current through the sensor inputs. If you have a suitable ammeter, use that. If you don't, put a resistor in series and measure the voltage across it.
    3. If you have been using an AC current source, try a DC one. The product page says "The bandwidth on the ASC712 Low Current Sensor Breakout has been set to 34Hz", but it doesn't say which 34 Hz. If it's 0 Hz to 34 Hz and you're trying to use line AC (50 or 60 Hz), that's not likely to work well.
    4. Try adjusting the gain and zero of the sensor board, while applying current to its inputs and monitoring its outputs with a voltmeter.
    5. If you can get reasonable responses, see the "If so" section below.
    6. If you still don't have reasonable responses, either contact SparkFun Tech Support by e-mail or post a schematic or detailed description of how you tested this.
  2. If so:
    1. Disconnect the current source and set the zero of the sensor board so that you have an output of 0.5 V.
    2. Connect the current source, provide a current close to, but not below, the maximum current you intend to measure, and set the gain of the sensor board to get a 4.5 V output.
    3. Try a few different current input values and check the output voltages with a voltmeter. The output voltage should be 0.5 V + (actual current/calibration current)*4 V.


I'm going to write the following on the assumption that you have a 5 V Arduino. If you have a 3.3V Arduino, let me know and we'll work from there. If the sensor is working, but not being read by the Arduino:
  1. Try applying different voltages between the Arduino Ground and Analog Input pins. I suggest trying with the pins connected to each other by a 100 to 1000 ohm resistor in series with either:
    1. series arrangements of: 0 (0 V), 1 (~1.5 V) , 2 (~3.0 V), and 3 (~4.5 V) alkaline cells or
    2. series arrangements of: 0 (0 V), 1 (~1.2 V) , 2 (~2.4 V), and 3 (~3.6 V) nickel metal hydride (NiMH) cells
  2. If that does not display reasonable values:
    1. Post a pin-specific description of your connections to the Arduino, including a description of the power supply you are using.
    2. Copy and paste the code you've entered (not the code you meant to enter) into a posting on this forum, using the Code button above.
    3. Copy and paste any error messages you got from the Arduino IDE.


When you report the results of the above, if you still have a problem, I'll see what I can do to help.

Good Luck,
Eric
By hdias
#116033
Hi Eric,

Thanks for your suggestions because they are very useful to diagnose the problem. My goal is to measure the current of a 11.1V/ 2200 mA battery. But for testing I assembled the circuit as shown in the attached image. I put a Voltmeter between the output terminal of the sensor board and its ground, and I get a voltage that varies with varying current.

For example, without the current source (9V battery) I got a 518 mV output. With the current source I got a 526 mV output. The variation is not very significant.

Another thing I do not understand is the calibration and how the values from the Voltmeter relates to the values that I get on the Arduino board. I followed your suggestion and tried to calibrate the sensor. First without the current source to obtain an output of 0.5V. Rotating each of the pots I can read on the voltmeter display values ranging from 0V to 5V. But it's hard to get a 0.5V output. To obtain them I have to rotate the Vref pot and then the Gain pot because I have big oscillations. This 0.5V value is the reference value (Vref)?

With the current source connected I tried to rotate the Gain pot to get a 4.5V output. I rotated the pot in clockwise until the end, and the maximum I could get was a 2.445V output. This value is the Vref value?

After this procedure I removed the current source and the value dropped to 2.432V.

I also repeat the same procedure for other current sources: 4.5V, 11.1V and 15V.

On the product page has a simple way to calculate the sensitivity. The sensitivity is calculated as (Vref - Vdeflect)/(current input). But then how do I relate the sensitivity with the value read by the Arduino board?

The code I'm using to read the sensor values can be found on this page.

Thanks for the help,

Henrique
ACS712LowCurrentSensorBreakout.jpg
You do not have the required permissions to view the files attached to this post.
By esklar81
#116040
hdias wrote:Hi Eric,
Thanks for your suggestions because they are very useful to diagnose the problem. My goal is to measure the current of a 11.1V/ 2200 mA battery.
Do you mean a 2200mAh (milliampere-hour) battery, or one you expect to be discharging at a current of 2200 mA? I suspect part of the problem may be with the ranges of current you are trying and the range of the sensor.
hdias wrote: But for testing I assembled the circuit as shown in the attached image. I put a Voltmeter between the output terminal of the sensor board and its ground, and I get a voltage that varies with varying current. For example, without the current source (9V battery)
It's important to distinguish between current sources and voltage sources. The 9 V battery is a voltage source (The big hint is that it's described by a voltage, not a current.). The current you get is determined by:
I = (Vres)/Rres
Rres, the resistance of the resistor, is 560 ohms
Vres, the voltage across the resistor, is Vbat - Vled. That's approximately 9 V -2V = 7 V (If you want a more precise estimate, check the datasheet for your LED. If you want to use real data, first measure the resistance of the resistor, then measure the voltage across the resistor when the circuit is operating.)
So the current is 7 V/560 ohms = 0.0125 A = 12.5 mA
hdias wrote:I got a 518 mV output. With the current source I got a 526 mV output. The variation is not very significant.
What you appear to have gotten is am 8 mV change in output for a 12.5 mA change in input. That's a sensitivity of:
8 mV/12.5 mA = 0.64 mV/mA = 640 mV/A.
The datasheet for the sensor IC says that its sensitivity is 180 to 190 mV/A. The SparkFun product page says the gain is adjustable from 4.27 to 47. If we multiply the gain and the IC's sensitivity, we get a sensitivity range of:
4.27 * 180 mV/A = 769 mV/A to 47 * 190mV/A = 8,930 mV/A. The calculated value of 640 mV/A is close enough to the lower end of this range for me to believe the sensor and its board are working.
hdias wrote:Another thing I do not understand is the calibration and how the values from the Voltmeter relates to the values that I get on the Arduino board. I followed your suggestion and tried to calibrate the sensor. First without the current source to obtain an output of 0.5V.
This may be my fault. I did not read the sensor datasheet before writing my original post. If I had, I would have noticed that the output from the sensor IC is Vcc/2 (~2.5 V, in this case) if there is no current. That's because the sensor IC has a bidirectional output. If the current is "forward", its output is between Vcc/2 and Vcc (~2.5 V and ~5 V, in this case); if the current is "reverse", its output is between Gnd and Vcc/2 (~0 V and ~2.5 V, in this case). I suggest you try calibrating again, this time trying to set the board's output to 2.5 V with no input current.
hdias wrote:Rotating each of the pots I can read on the voltmeter display values ranging from 0V to 5V. But it's hard to get a 0.5V output. To obtain them I have to rotate the Vref pot and then the Gain pot because I have big oscillations.
According to the note on the schematic, the two trimpots need to be turned in different directions to increase the values they control.
hdias wrote:With the current source connected I tried to rotate the Gain pot to get a 4.5V output. I rotated the pot in clockwise until the end, and the maximum I could get was a 2.445V output. This value is the Vref value?
Frankly, I don't have a clear understanding of what they mean by "Vref" either.
hdias wrote:After this procedure I removed the current source and the value dropped to 2.432V.
If I understand you correctly, you got 2.445 V output for 12.5 mA input and 2.432 V for a 0 mA input. That's a difference of 13 mV for 12.5 mA, or a sensitivity of:
13 mV / 12.5 mA = 1.04 mV/mA = 1040 mV/A, which is in the expected range.
hdias wrote:I also repeat the same procedure for other current sources: 4.5V, 11.1V and 15V.
You need to pick one current at which to set the gain. To do this appropriately, you need to provide a simple current source (a voltage source in series with a resistor) of a known current that is slightly larger than the largest current you are trying to measure.
hdias wrote:On the product page has a simple way to calculate the sensitivity. The sensitivity is calculated as (Vref - Vdeflect)/(current input).
It might be easier to think of this as: Sensitivity = (Vtest -Vnone)/Itest, where:
Itest is the test current you applied,
Vtest is the output voltage at the test current, and
Vnone is the output voltage with no test current.
hdias wrote:But then how do I relate the sensitivity with the value read by the Arduino board? The code I'm using to read the sensor values can be found on this page.
That code appear to display the raw value from the analog to digital converter (ADC) in the Arduino. I suggest you read some of the material on the Arduino site about measuring voltage and about converting the raw ADC value to something more useful, such as measured current.
hdias wrote:Thanks for the help
You're welcome,
Eric
By hdias
#116045
Thanks Eric.

This is the best explanation that I got until now :D . Now I understand how the current sensor works. I'm going back to test the calibration, but now I think the sensor is working correctly.

Thanks and Merry Christmas,

Henrique
By PodexPerfectusSum
#116982
I just got mine a couple of days ago and this thread was quite useful in understanding how to tune the sensor, but my readings are still hinky. I'm using a 500mA load I'm using to calibrate the sensor. Adjustment is quite difficult as every time I go near it with a screwdriver, the DMM goes from 0.000mV to 4.85V and I don't even have to touch the thing. If I put the screwdriver on the vref adjustment pot and the DMM shows 4.85V, I turn the pot about halfway and the voltage the DMM reports goes to 0.000mV. If I swing the GAIN pot all the way counter-clockwise, I can play with the vref pot for about five minutes of the most minute tuning ever and get it to somewhere between 1V and 3V.

I'm starting to suspect that I might have a bad part.
By PodexPerfectusSum
#117088
I've clipped the alligator on my DMM's positive test lead onto the sensor's output. The DMM's negative lead is clipped to a jumper which ties into the same row on my breadboard as the sensor's ground pin. 5VDC is supplied by a computer power supply.
By PodexPerfectusSum
#117255
I attempted attaching a resistor in series with the sensor but that had little to no effect. It's not really worth this much trouble to me, but it'll probably make some archeologist scratch his head someday.
By enmsh
#159650
if my load is a resistor and i connect this sensor in parallel in as much its small internal resistance most of the current of the source will pass in this sensor and it will be maximum and that mean it won’t be the real load current when i remove the sensor.
IS it connected in parallel or in series with load?
so if i had a dc voltage source 26.3 v and load = 3.48 ohm and i expect the current sensed to be 7.6 A how will it be calculated by this sensor ?
By Mee_n_Mac
#159651
as you have already reasoned it out it's intended to be connected in series with the load that way the current that runs through the sensor is the same current that runs through the load of course this assumes the added small resistance of the sensor doesn't affect the circuit in any appreciable way