# Total current consumed from a battery

I would like to know how could I know the current consumed from a battery using this sensor, or other similar, using a microcontroller.

What I would like to know is shown in this video, where you can see the current consumption.

• This sensor is for 0-50A. That is a lot of current to draw from a battery unless it is a Lead-Acid cell cranking a car engine - even then it will only drive this sort of current for a short time.
– uɐɪ
Oct 21, 2010 at 16:43
• You can draw plenty from a LiPo - 40A isn't uncommon for some powerful RC motors. Oct 21, 2010 at 16:46

In order to measure the current consumption or the battery's state of charge, you need to integrate current over time. The most basic method is to sample a current sensor (be it a hall-effect, shunt resistor, whatever) at a fixed rate fast enough to capture your current signal (10-100 Hz might be fine for a RC plane), and multiply it by the sample time to obtain charge (A·h, mA·h, coulombs, whatever). The Allegro sensors have an adjustable bandwidth, so you could get away with fs = 2*BW

Once you have the current consumed, you could subtract that from your battery's capacity to obtain the 'fuel level', preferably padded with a good margin of safety.

This method will not be terribly accurate, because the battery's useful charge is not exact, and will fluctuate wildly depending on discharge rate and temperature, among other variables, but it should be good enough to provide a rough 'gas gauge'.

I've used a small high-side current-sensing resistor and connected an Arduino ADC to each side to measure the voltage on each side (--> voltage difference --> current).

It's not very accurate because of the limited resolution of the converters, and because the important quantity is a small difference between two similar voltages.

You could improve on this by using an op-amp to amplify the difference in voltage, and then output a single DC voltage corresponding to the current.

I didn't see a datasheet for this sensor via the supplied link, but from the photo see that the sensing element is a hall-effect device, p/n ACS754.

According to the manufacturer's website, this is a discontinued part:

"DISCONTINUED PRODUCT. These parts are no longer in production. The device should not be purchased for new design applications. Samples are no longer available. Date of status change: May 3, 2010."

Also, according to the ACS754 datasheet, the output offset voltage at zero current and 25C is +/- 10mV, which (at 40mV/A) means that any readings less than 250mA could be suspect. What current range do you intend to sense?

• Madmanguruman, thank you very much, I don't knew what was that sensor...
– mtz
Oct 22, 2010 at 8:27
• @mtz: Don't worry about the sensor being discontinued, there is a drop-in replacement, the ACS758 which is pretty much identical but supports a wider voltage range with improved accuracy. Oct 22, 2010 at 13:54