Ina 219 wiring / voltage measurements

Hi guys, I wanted to ask for your support regarding ina219 wiring, I intend to measure the battery voltage level and my diagram is as follows:

(Sorry for manual sketch, just wanted to quickly ask for advice).

There is communication and everything seems to work perfectly but I have an impression that I am measuring not the proper voltage as it reports basically all the time 4.93-4.92V and then the battery dies suddenly, when measured with multimeter it showed 2.9V. How do I need to change my wiring to measure the battery voltage?

TIA. J

The sketch is very good. Can I ask why dont you use a simple voltage divider circuit and an adc pin on the esp32 c3 rather than use more energy on the ina219?

Just for experimenting. The ESP in final version would go into deep sleep. But still my question is valid - I think I am not measuring the battery voltage, seems like I am measuring the board voltage I suppose… ?

Can you measure with a volt meter between vin and gnd pin on esp32 to see if it reads 5 or 3.3 v.

I can do. Have not done it as it should be 5V as per data sheet…

18650 wont be enough usually to power 5 v without a boost converter. Too high for 3.3 v without something like an LDO.

Theoretically yes but esp32 converts the power in voltage to 3.3V. So the whole circuit works perfectly fine. I have a bmp 085 hanging on the same gpios with different address than ina and I have everything I want from this test. Except I just can not get the proper voltage measured.


There should be a shunt voltage. I think you should have vin+ and - swapped


Difficult to do this as im passenger driving cross the country.

Uh, could it be that the ina219 measures current- not voltage?

I use one to measure voltage in a gate buzzer.
I still think voltage divider with adc in battery powered device will save more battery but op just wants to get it working for learning purposes. Even in deepsleep the ina will be powered.

Is current not usually derived from voltage across a shunt?

Yes, and the OP is likely measuring the current powering the ESP. That would account for it being constant then zero.

I can give it a try, but not really sure this changes anything… I

Until it doesn’t.
When your battery voltage goes below 3.3V+Vdif you are operating in “gray zone”, LDO can’t regulate the voltage correctly. Ina might not be happy without stabile >3V supply.
Try how it works with fully charged battery.

Agree. But below 3.3 that would be anyway the case, wouldn’t it?

What? Do you understand the difference from voltage and current? You are measuring the shunt voltage which is directly relatable to the current through the shunt. It will be constant as long as the voltage is sufficient to run the ESP. When the voltage gets too low for the ESP to function, it shuts down and the current drops to nearly zero.

Have you read the whole topic or are you just jumping on a high horse after reading one phrase, which might be slightly unfortunate as I am not a native English speaker? Have you got a solution for the problem I am trying to find and understand or are you here just to show that you know more? Have you read the community rules? If any of the answers is „no” than please leave your comments somewhere else.

Are you powering the ESP32 via the USB port with the battery connected?

I don’t see how you can have 4.92V when the battery can only supply a maximum of around 4.2V.

If this is the case, you are injecting 4.92V into the battery

The battery is indeed in the charger shield. I need to make sampling more frequent to see the correlation with the battery voltage and the level of voltage from the shield. Thanks for turning my attention to this.

I asked because “…but esp32 converts the power in voltage to 3.3V” makes no sense at all.

You are trying to measure voltage with a current sensor. It won’t work.
@Spiro has the correct solution in post#2.