Electrical – INA219 measure voltage of battery with RPi

raspberry pivoltage measurement

schematic

simulate this circuit – Schematic created using CircuitLab

I want to measure voltage of 12V battery powering something by INA219 connected parallel to this battery and read it with RPi via I2C. Is this possible with INA219? Should I use something else for this? I tried to connect it like I imagine but I had to use 1K resistor between INA219 and battery and my reading then look like this:

Bus Voltage: 0.008 V
Bus Current: 12.305 mA
Power: 0.000 mW
Shunt voltage: 1.240 mV

This way Bus current looks exactly like my voltage provided on Vin

I tried connecting grounds from battery and RPi but there was no change.

Added schematic. Is it clearer now?

Best Answer

See the schematic below, taken from the datasheet. Reading the datasheet explains that VIN- is the input from which the bus voltage is measured. You should connect this VIN- to your battery's positive terminal if you only want to read voltage. If you want both current and voltage, connect as shown below with "Supply" being your battery positive terminal and "Load" being the power input on your "Device powered from battery".

Edit: to be clear, the measured voltage is VIN- minus the INA219's GND. You will need to connect the INA's GND to the battery's negative terminal, and likely to the RPi's GND as well.

Schematic, Figure 13 from INA219 Datasheet