The new sense resistor I am using is a R010 BOURNS CRL2512-FU-R010ELF
How did you measure the resistor ?
I measured the resistor with one of these meters
https://www.amazon.co.uk/Acompatible-5000-Handheld-Meter-Tl-21/dp/B00S298KJOin DC resistance mode.
Did you zero out the multimeter probes before measuring?
I calibrated the meter before measuring, without and with the probes attached, in accordance with the instructions in the meters manual.
Did you clean the meter probes with isopropyl alcohol or something?
The meter was brand new out of the box and didn't see the need to do it although I will try it anyway.
The resistance may change as it heats up, if it's not a proper current shunt resistor... but shouldn't be that much difference.
It is a proper shunt resistor.
Also, what are you comparing the voltage/current measurements with?
I have two modules that I am just switching between. A standard module has a R100 (0.1 Ohm) shunt resistor and a modified module that has a R010 resistor. My code is setup to read both modules but only one is 'live' at a time as I switch the load between modules. If I switch in the original module with the 0.1R resistor and use the 32V_2A profile in the Adafruit library the Current and Voltage measurements that it is reporting are similar to what I am seeing with an inline Current meter and a Voltage meter over the PSU. The PSU has its own meters but they are generally not as accurate in my experience. I have also used a clamp meter for measuring the current. Overall with the standard Module the reading reported by the INA219 seem pretty close to the Meters.
When I switch in the other INA219 module that I replaced the R100 with a 0R10 (0.01 Ohm) resistor and use the Profile I created myself in the Adafruit library (32V_16A as I have already posted) this is where the problems are, as reported.
It seems you've commented out most of the calculations. Have you tried using the "default library" just with a different resistor? Sure you will get an error by a factor of 2 for the current measurement, but it will at least help determine whether its hardware or software (ie: your custom config).
The calculations are not meant to be commented In. They are there to use as a 'fill in the blanks' type formula. You have to make several calculations to get to one number.
Example: to get the 'ina219_calValue' you need to do 5 previous steps of calculations so that you get the correct numbers to 'plug in' for the 'ina219 calValue' calculation. There are 3 that take several steps;
ina219 calValue
ina219_currentDivider_mA
ina219_powerMultiplier_mW
These values also have to be changed if the resolution changes...
INA219_CONFIG_GAIN_1_40MV |
INA219_CONFIG_BADCRES_12BIT |
but I am just sticking to how the 2Amp profile was setup so they are unmodified. I am not 100% sure if that is the correct decision but I dont feel I have a choice as I can not choose any better.
All of the comments/instructions about the steps for the calculations have been taken from the Ti datasheet for the INA219 by Adafruit and included in the library as instructions in the form of comments.
There are several versions of the datasheet but this one has the formula examples (Page 17).
https://cdn-shop.adafruit.com/datasheets/ina219.pdf Have you tried using the "default library" just with a different resistor?
Yes it was the first thing I did and of course it was incorrect because in theory it was a factor of 10 out before all of the calculations. I initially thought I could just fudge that in my code and multiply the current by 10. However, in practice the 0.01 shunt resistor seems to read 0.02 in practice with the meter. I have tried both values in the equations.
As already stated, I am using a standard device and library to check that my meter reading are not a mile off. Even though the library states it goes up to 2Amps the standard device and 2Amp library does actually work up to 4.5Amps and the module is reporting similar values as the meters. So I believe how I am reading the values is close enough. Things just go downhill when I use the 0.01 Ohm resistor an a default or my own library 'profile'.
Here is the Adafruit .cpp driver library complete
https://github.com/adafruit/Adafruit_INA219/blob/master/Adafruit_INA219.cppMy target to be able to read is 24 volts at 8Amps although at the moment I am only going as far as 4.5Amps in testing with the modules before making my own beefier version as part of my project.
I will also mention that I am using an electronic DC load.
Thanks everyone for their help so far.