Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voltage reading error #3

Closed
Jim4Beam opened this issue Jun 17, 2015 · 2 comments
Closed

Voltage reading error #3

Jim4Beam opened this issue Jun 17, 2015 · 2 comments

Comments

@Jim4Beam
Copy link

Hello,
first let my say thank you for the good and easy library!
I got messed up with the adafruit one.

I have a 0.001Ohm (1mOhm) Shunt at a 24V (nominal) batterie system. Max Voltage is 27V vully charged. Max Current is +30A and -120A.

I have set the defaults in the .h file to:

define D_I2C_ADDRESS 0x40 // I2C Adresse(64)

define D_RANGE 1 // 0: 0-16V, 1:0-32V

define D_GAIN 3 // Range: 2: +-160mV, 3: +-320mV

define D_SHUNT_ADC 3 // ADC 3: 12-bit, single sample, 532uS conversion time

define D_BUS_ADC 3 // -||-

define D_MODE 7 // 7: continuous conversion

define D_SHUNT 0.001 // R-Shung [Ohm]

define D_V_BUS_MAX 32 // U-Bus-Max [V]

define D_V_SHUNT_MAX 0.160 // U-Shunt_Max exp. [V]

define D_I_MAX_EXPECTED 150 // I-Max exp. [A]

Current works fine, BUT the voltage reading is at 26V (Multimeter) -6V!??
If i measure the Arduino Vcc its ok 4,8V.
If I set #define D_RANGE to 0, it reades 16,00V at max Battery Voltage.

What am I doing wrong, or have i grilled my INA219?

Thank you!

@Jim4Beam
Copy link
Author

found and fixed the Problem. In INA219.cpp line 137:

// returns the bus voltage in volts
float INA219::busVoltage()
{
//int16_t temp;
unsigned int temp;
temp = read16(V_BUS_R);
temp >>= 3;
return (temp * 0.004);
}

Changed temp variable to unsigned int! Now the voltage reading goes up to 30V. :)

@johngineer
Copy link
Owner

Great! I'll update the code next chance I get. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants