Hi.
I am switching a 12V lamp (up to 20A) to ground through an Nfet. I have a 0.002Ohm shunt resistor on the low side of the load, between the negative of the lamp and the drain of the Nfet. The Nfet has very low Rds-ON, so for all intents and purposes pin Vin- is at ground or 0V when the light is on.
I am using the Adafruit_INA219 library for Arduino. Slightly modified to return an intiger rather than a float. The readRegister() function returns an intiger, as my LSB = 1ma the intiger returned should be my current draw in mA.
With a 1.8A draw I would expect to get the equivalent of decimal 18000, but I get 152. With two lamps in parallel, drawing 3.2Amps I get 304, and with three lamps drawing 4.8A I get a reading of 456. The scaling is accurate in that double the amps doubles the reading, but I was expecting the return values to be in milliamps, so I don't know why the return values are so low.
With the light off, the voltage at the shunt resistor is the bus voltage, ie the same as the high side, which returns perfectly as 12756 (12.756V) so I know my I2C is working properly.
I am using the same library and function calls, but with a different IC and configuration settings, to measure the solar panel current charging a battery, and it works perfectly. The shunt resistor, however, is placed on the high side ie between the regulator out and the battery+.
Do you think that having the shunt on the low side is causing the problem?
Calculations and settings as follows:
VSHUNT_MAX = 0.04 ......(20A * 0.002Ohm = 0.04V)
Minimum_LSB = 20A/32767 = 0.000610
Rounding up I choose my Current_LSB to be 1mA or 0.001
//calValue = .04096/(0.001*0.002) = 20480
ina219_currentDivider_mA = 1; // Current LSB = 1mA per bit
my config settings are as follows:
calValue = 20480;
wireWriteRegister(INA219_REG_CALIBRATION, ina219_calValue);
uint16_t config = INA219_CONFIG_BVOLTAGERANGE_16V |
INA219_CONFIG_GAIN_1_40MV |
INA219_CONFIG_BADCRES_12BIT |
INA219_CONFIG_SADCRES_12BIT_1S_532US |
INA219_CONFIG_MODE_SVOLT_CONTINUOUS; // reads shunt voltage only for LAMP, I'm not interested in bus voltage.
wireWriteRegister(INA219_REG_CONFIG, config);