Measuring accu capacity with an INA219

Hello dear forum members,

I hope I’am posting in the right category but I have a problem that most likely relates more to my “circuit” and the lack of understanding and less to programming.

What I try to do: I would like to actively drain a rechargeable battery until the voltage reaches a certain level, and monitor the current consumed during that time. So I bought an INA912 module and connected it as shown in the attached picture of my breadboard (I of course left away the USB>RS232 communication, and the 5V power supply for the Arduino).

Now what I assumed was that if i run the out-of-the box INA219 get current example that i would get:

  • the correct voltage of the battery
  • and the current flow

(I planned to use a MosFet to disconnect the battery from getting drained, when falling under a pre-defined voltage level - but that is not of relevance for my problem).

Now what happens when I use the circuit below (100 Ohm Resistor, different power sources) is the following (VIN- floating means, I removed the orange wire connecting it via resistor to the ground)

Connecting a 5V regulator:
VIN- floating:
Bus Voltage: 4.97 V
Shunt Voltage: -0.03 mV
Load Voltage: 4.97 V
Current: -0.40 mA

VIN- connected to ground via 100 Ohm resistor
Bus Voltage: 4.78 V
Shunt Voltage: 4.46 mV
Load Voltage: 4.79 V
Current: 44.60 mA

Connecting a fully charged LiPo cell (4.06V):
VIN- floating:
Bus Voltage: 4.06 V
Shunt Voltage: -0.06 mV
Load Voltage: 4.06 V
Current: -0.50 mA

VIN- connected to ground via 100 Ohm resistor
Bus Voltage: 3.93 V
Shunt Voltage: 3.79 mV
Load Voltage: 3.94 V
Current: 37.40 mA

I observe a decrease in the measured bus voltage. If I take my voltmeter I can not confirm that voltage drop at this little load. But it get’s worse: To drain a 2.000mAh battery, I would like to take smaller resistors to increase current flow. If I go down the discrepancy gets always bigger:

4,04V LiPo Cell with 50 Ohm resistor (not severe)
Bus Voltage: 3.93 V < my voltmeter measures still 4.04V
Shunt Voltage: 8.00 mV
Load Voltage: 3.95 V
Current: 79.50 mA

4,04V LiPo Cell with 33 Ohm resistor
Bus Voltage: 3.75 V < my voltmeter measures 4.034V
Shunt Voltage: 11.30 mV
Load Voltage: 3.76 V
Current: 113.90 mA

What am I doing wrong ? With this heavy difference between real voltage of the battery and the measured voltage, I would instantly disconnect the battery because when I want to drain like 250mA, the INA912 would report me a voltage so low, that I’d assume the battery is empty.

First off, you need to rotate the processor board 90deg on your breadboard given the current position shown is shorting the pins in the 4 strips into which they are inserted.

The Arduino is not measuring voltage, only current, if you want to measure voltage you will have to power the Arduino separately or use the internal 1.1 volt VREF.
The voltage of a power source is naturally going to fall when the load is increased, the amount of sag depends on the source’s capacity and the magnitude of load.

Hi 756E6C,

just to make sure:

  • the arduino is powered separately using an external DC power source with 5.0 V

  • the reported voltage is wrong, as I measured it with a working voltmeter and I did not increase the drain to a level, that should cause the power source to fall (even another 5V regulator connected to Vin+/Vin- that delivers 2A falls at a load of 44.6mA, which is unplausible)

as far as I got it, the arduino is querying the INA219 Board via I2C Bus, and the INA219 on board is returning both: voltage and current, so i should be able to measure both.

If you are measuring the voltage at the orange wire, you are measuring the voltage AFTER the current sensing resistor in the INA219, of course it will be lower, you need to measure the supply voltage at the VIN+ pin.
Might come down to "who do you trust", your meter or the INA219.

considering the description of the INA219 it reports as voltage the difference between VIN+ and GND of the board ... so it should report the right voltage - and even if it would measure after the little 0,1Ohm shunt resistor, as you can see from the use-case:

Powered by a 2A 5.0V regulator
VIN- connected to ground via 100 Ohm resistor
Bus Voltage: 4.78 V
Shunt Voltage: 4.46 mV
Load Voltage: 4.79 V
Current: 44.60 mA

I would expect to measure: 4.97 V between GND and VIN+ (as this is the current, provided by the power supply), due to ohm law it should be 4,965 V between GND and VIN- (as the little shunt causes a very small drop of 0.005V)

With a 33 ohm load, what does your meter read with the + probe on the power supply + terminal and the - probe on the VIN+ pin? What does the INA219 say?

Floating VIN- Pin:

Output from INA219:
Bus Voltage: 4.97 V
Shunt Voltage: -0.02 mV
Load Voltage: 4.97 V
Current: -0.50 mA

Measured with voltmeter between + terminal of power supply and ground: 4,969V
Measured with voltmeter between + terminal of power supply and VIN+ (as you requested) 0,000V

Connected VIN- via 33 Ohms to GND:

Output from INA219:
Bus Voltage: 4.76 V
Shunt Voltage: 14.04 mV
Load Voltage: 4.77 V
Current: 140.60 mA

Measured with voltmeter between + terminal of power supply and ground: 4,933V
Measured with voltmeter between + terminal of power supply and VIN+ (as you requested) 0,107V

Are you sure you have connected the battery (polarity) as on the Fritzing picture.
The INA219 is basically a high-side sensor with a CM range of -0.3 to 26volt.
Changing polarity of the battery the way you have connected it will fry the chip.
Maybe safer to have +5volt as battery reference/common instead of ground.
Leo..

Hi Leo,

yes, the battery is connected as illustrated on the fritzing picture, which means that the + pole is directly connected to the VIN+, and the - pole is connected to the "common ground" - and I hope that I did not fry the chip but I have two of the INA-boards and both show the same result. Strangely it's working perfectly if not under load.

Could you be a little more specific what you mean by "Maybe safer to have +5volt as battery reference/common instead of ground."? I'm not a native speaker and no expert in electronics, so I want to be sure, that I got it right ?

Thanks a lot,
Stefan

As said, the INA219 has a common mode range of about 0volt (-0.3 absolute max) to 26volt.
It means that both shunt terminals have to fall within that range.
Connecting the battery with wrong polarity results in -1.5volt on the input, and will fry the chip.

Now you have battery/resistor connected to ground.
Not a problem to connect both to common +5volt instead of common ground, since the INA can measure above it's own supply.

Just realised that you loose the ability to measure bus voltage when you do this.

The problem you're having (dropping bus voltage) might be because you have connected +batt and resistor to the wrong terminals (swap them). The INA measures voltage on one current terminal.
Leo..

hi leo - sorry for asking back one more time: If I got you right you want me to exchange the connections from battery and resistor at the VIN+ / VIN- ports ?

Just had a better look at the INA219 datasheet.
The chip measures battery voltage at the Vin- pin.
You have connected battery+ to the Vin+ pin.
Battery voltage is now skewed by battery current, so yes, swap the two current terminals.

All of this is assuming Adafruit (or the cloner) has labeled the terminals right.

You can leave the rest of the circuit as is, as long as you don't put the battery in the wrong way.
Leo..

Hi Leo, thanks for your efforts but I'am afraid that this did not really solve the problem.

The results after changing the ports at the sensor are:
Bus Voltage: 4.78 V
Shunt Voltage: -14.28 mV
Load Voltage: 4.77 V
Current: -142.90 mA

but in reality it should be 4,933V. I somehow can't fight the feeling that it has to do with the circuit or the resistor. Does it really make no difference if I use a real consumer (e.g. a light bulb/...) vs. the resistor?