# Measuring the capacity of a battery using ACS712 current sensor ! help !

Hello everyone,
I would like to know if it is possible and how to make a capacity measuring device which will tell how much the battery still have mAh current left in it according to the circuit it is used in using the current sensor ACS712 like this video ?

It depends on the range of currents involved. The ACS712 is a hall-effect sensor which is not particular accurate at low current, whereas shunt-resistor current-sensing can be very accurate, but severely limits the maximum current.

Are you thinking of deliberately discharging a battery to test its capacity, or do you want to monitor some circuit to predict when the battery is nearly empty? What battery chemistry?

With any current sensor you can measure total charge by integrating over time, but issues of accuracy and dynamic range are important as is the power consumption of the measurement circuit.

As I understand what you are asking is how to make a battery "fuel" gauge. It is possible. You could take most of the ideas from the video but realize you need to know the current capacity of the battery to determine how much energy is left. The capacity will change over time and is also temperature and load dependent. Since you are burning energy why not just add a low value resistor in the low side and measure the voltage drop, that would be more accurate then the hall sensor. Depending on what resistance you use you may have to add an amplifier circuit using an op-amp or other convenient method to get the voltage to something the Arduino can read. This has been tried many times and there is no perfect solution that I know about. You will have to determine the tolerance you can live with. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

The video uses a fixed 10 ohm discharge resistor, and measures the voltage across it (on both sides).
I don't see the need for any current measurement, since current can simply be calculated.
Leo..

MarkT:
It depends on the range of currents involved. The ACS712 is a hall-effect sensor which is not particular accurate at low current, whereas shunt-resistor current-sensing can be very accurate, but severely limits the maximum current.

Are you thinking of deliberately discharging a battery to test its capacity, or do you want to monitor some circuit to predict when the battery is nearly empty? What battery chemistry?

With any current sensor you can measure total charge by integrating over time, but issues of accuracy and dynamic range are important as is the power consumption of the measurement circuit.

I want to predict when the battery is empty. I am using a Lipo battery and I want to when i plug it the arduino knows what is its capacity at that point if it is half full for example
It does not have to be so accurate just a prediction

gilshultz:
As I understand what you are asking is how to make a battery "fuel" gauge. It is possible. You could take most of the ideas from the video but realize you need to know the current capacity of the battery to determine how much energy is left. The capacity will change over time and is also temperature and load dependent. Since you are burning energy why not just add a low value resistor in the low side and measure the voltage drop, that would be more accurate then the hall sensor. Depending on what resistance you use you may have to add an amplifier circuit using an op-amp or other convenient method to get the voltage to something the Arduino can read. This has been tried many times and there is no perfect solution that I know about. You will have to determine the tolerance you can live with. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

well yes but my problem is that i do not have enough pins left just 2, so my idea was to use this ACS712 because it needs only 1 analog pin

An INA216 breakout board could be a better solution for your (unspecified) project.
Voltage, current, power, all in one.
Leo..

Wawa:
An INA216 breakout board could be a better solution for your (unspecified) project.
Voltage, current, power, all in one.
Leo..

well the big question here is how to let my current sensor read the value of the battery in whatever state it is ?

firashelou:
well the big question here is how to let my current sensor read the value of the battery in whatever state it is ?

Voltage/current sensors just measure voltage/current.
You have to figure out a way to make sense of that.

The video constantly discharges a battery until the voltage drops below a certain point.
Easy way to measure battery capacity at that specific current.

Much harder if you want to keep track of remaining charge with varying loads.
Googling "Arduino coulomb counter" might give you some hints.
Leo..

Wawa:
Voltage/current sensors just measure voltage/current.
You have to figure out a way to make sense of that.

The video constantly discharges a battery until the voltage drops below a certain point.
Easy way to measure battery capacity at that specific current.

Much harder if you want to keep track of remaining charge with varying loads.
Googling "Arduino coulomb counter" might give you some hints.
Leo..

thanks Wawa
what I am thinking about is using this current sensor and then accumulate the current used and subtract it from the value entered in the program for example 2200 mAh and saving the remaining value to EEPROM of arduino. And having a pushbutton to be used when a full battery is plugged to reset the remaining value. And this way I would have an approximate device to measure the capacity.

Real life batteries have lower capacity at higher currents, so you might have to correct for that, and capacity
falls with time (self-discharge) and depends on temperature too.

You'll probably want to use the battery voltage as well, to reliably detect the onset of full discharge as the
coulomb-counting isn't highly accurate.

MarkT:
Real life batteries have lower capacity at higher currents, so you might have to correct for that, and capacity
falls with time (self-discharge) and depends on temperature too.

You'll probably want to use the battery voltage as well, to reliably detect the onset of full discharge as the
coulomb-counting isn't highly accurate.

I have an idea of making a capacity tester for the battery then take a wire from arduino PWM pin to my second arduino analog pin which will show to the screen connected to second arduino

You got me curious so I did a bit of research and it is not that hard to make a battery fuel with an Arduino. You need at least 22 bits of analog conversion, This is from Analog Devices web page: "Coulomb Counter (Battery Fuel Gauge)
Analog Devices’ battery management gas gauges and coulomb counters accurately measure and report battery capacity in single cell or multicell handheld applications. Charge accuracy is uncompromised thanks to a variety of unique sensing techniques that appear seamless to the user. High-side current sensing allows downstream failure detection and avoids ground disturbance. Analog integrators digitize charge directly, resulting in cancelled amplifier offsets, minimal gain error, and better overall charge accuracy. Some models also provide battery voltage and temperature, while others integrate a sense resistor to minimize component count and increase accuracy even further. All devices have small footprints and provide simple digital interfacing with a host processor." You can get them assembled from Banggood, RobotShop and others for a few bucks. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

gilshultz:
You got me curious so I did a bit of research and it is not that hard to make a battery fuel with an Arduino. You need at least 22 bits of analog conversion, This is from Analog Devices web page: "Coulomb Counter (Battery Fuel Gauge)
Analog Devices’ battery management gas gauges and coulomb counters accurately measure and report battery capacity in single cell or multicell handheld applications. Charge accuracy is uncompromised thanks to a variety of unique sensing techniques that appear seamless to the user. High-side current sensing allows downstream failure detection and avoids ground disturbance. Analog integrators digitize charge directly, resulting in cancelled amplifier offsets, minimal gain error, and better overall charge accuracy. Some models also provide battery voltage and temperature, while others integrate a sense resistor to minimize component count and increase accuracy even further. All devices have small footprints and provide simple digital interfacing with a host processor." You can get them assembled from Banggood, RobotShop and others for a few bucks. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

Just saw this reply! Sorry for late response great i will search for it thank you

gilshultz:
You got me curious so I did a bit of research and it is not that hard to make a battery fuel with an Arduino. You need at least 22 bits of analog conversion, This is from Analog Devices web page: "Coulomb Counter (Battery Fuel Gauge)
Analog Devices’

@gilshultz
Thanks.. Tom..

however there is no further useful information.

You need at least 22 bits of analog conversion

which gives 0.000024 % accuracy - I dont see why.

If the battery is rated in Ah I dont see why "coulomb counting" (coulomb = 1 amp second) cant give a reasonable result, which is all you can expect ...

without exhaustive data on the individual battery (discharge curves at different tempertures, different currents, battery degredation etc).

And as MarkT says

You'll probably want to use the battery voltage as well, to reliably detect the onset of full discharge as the coulomb-counting isn't highly accurate.

Of course the issue with coulomb counting is you need to record the charge drawn from the battery provided it is at full capacity when you start integrating (coulomb counting); and how do you know its INITIAL state of charge?

johnerrington:
https://www.analog.com/en/products/power-management/battery-management/coulomb-counter.html

however there is no further useful information.

You need at least 22 bits of analog conversion

which gives 0.000024 % accuracy - I dont see why.

That's for high dynamic range when the load varies.
Many devices alternate between high current and low current modes (active v. sleep mode). The
active current might be 100mA, the sleep current 5uA. If you want 1% accuracy for both cases
thats 21 bits or so...

However there's an easier way - use a diode shunt to give a logarithmic voltage reading representing
the current, makes for great dynamic range at the expense of accuracy (but estimating battery
capacity is a rough and ready thing anyway). 10-bit ADC is probably good enough then.

The main downside to using a diode in this way is that temperature correction may be needed for
reasonable performance as diode forward voltages depend on temperature as well as current.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.