chrisb2 / pi_ina219

This Python library supports the INA219 voltage, current and power monitor from Texas Instruments with a Raspberry Pi using the I2C bus. The intent of the library is to make it easy to use the quite complex functionality of this sensor.
MIT License
114 stars 34 forks source link

improbable values returned? #24

Closed cfaber closed 4 years ago

cfaber commented 4 years ago

Hi Chris,

first, thanks for the hard work on this library. second, I'm trying to use it with an ina219, which I think I have wired correctly but the results I'm seeing are a bit strange.

Here's my test code:

`#!/usr/bin/python3 from ina219 import INA219

ina = INA219(shunt_ohms=0.1, max_expected_amps = 3.0, address=0x40)

ina.configure(voltage_range=ina.RANGE_32V, gain=ina.GAIN_AUTO, bus_adc=ina.ADC_128SAMP, shunt_adc=ina.ADC_128SAMP) v = ina.voltage() i = ina.current() p = ina.power()

print('{0:0.1f}V {1:0.1f}mA'.format(v, i)) print('{0:0.1f} Watts'.format(p/1000))`

with no load on it I'm seeing the following:

19.4V 0.0mA 0.0 Watts

Under load (which should be 20ish volts at 3amps I'm seeing: 0.0V -66.8mA 0.0 Watts

I have it wired as follows:

Red: reference ground to 20v DC ground Orange: 3.3v -> ina219 VCC pin Brown: ground to ina219 ground pin Blue: SDA -> ina219 SDA pin Yellow: SLC -> ina219 SLC pin

on the ina219 the brown wire is connected to VCC+ which is connected to the 20v DC+ from the power supply, the red wire on VCC- is connected to the load.

Attached are photos of the layout (maybe that will help?) Anyways, any ideas you have would be helpful. Thanks! IMG_20200830_122152 IMG_20200830_122148