I2C INA219 Current Sensor with External Shunt Resistor

Good Evening All,

Apologies if this has been covered already, however I couldn't find anything in other posts.

I have an INA219 I2C sensor which I am wanting to use for measuring current up to a maximum of 200A (extremely rare to reach this figure).

The circuit to be measured is 12v and the sensor is to be used with an external shunt.

I have already removed the on-board 0.1Ω shunt from the board and connected up my external 200A, 50mV shunt which has a resistance of 0.25mΩ.

I have it connected to an Arduino Nano and I am receiving figures from the board, using the example sketch.

However, I am struggling to calibrate the INA219 library to the 200A, 50mV shunt to get accurate readings.

I am only interested in the Bus Voltage and Shunt Current for my application, ideally with an accuracy of 0.1V and 0.1A respectively.

Does anyone have any experience in calibrating these boards who may be able to assist me?

I hope I have provided enough information.

Thanks for any assistance in advance.

H

Methinks if you reduce shunt resistance from 100mΩ to 0.25mΩ (400*).
then current readout should be multiplied by 400.
Assuming you do have Kelvin connections to the shunt.

Doubt you can get that 100mA resolution.
You're only giving the chip 50mV instead of the 320mV with the 0.1ohm resistor.
I calculate only 340 A/D values across the 400Amp (±200) range.
That's a resolution of 850mA per A/D value.
Don't know if the library you're using has the option to increase the PGA gain (to 40 or 80mV).
Leo..

Thank you for the reply Wawa.

Just for further clarity, I am using a INA219 High Side DC Current Sensor Breakout - 26V ±3.2A Max [STEMMA QT] : ID 904 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits as the board.

Regarding your suggestion, I put a load on the circuit and took some readings with the INA219 and also with an accurate multimeter.

I placed the meter in series with the shunt and with the load I had on it, it measured at 1.71A, whereas the INA219 showed 5.5mA. Whilst in theory I should be able to multiply this by 400, this ends up being 2.2A.

I then took a voltage reading across the shunt which showed 0.41mV, whereas the INA219 showed 0.56mV.

Heres the code I'm running:

#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;


void setup(void) 
{
  Serial.begin(115200);
  while (!Serial) {
      // will pause Zero, Leonardo, etc until serial console opens
      delay(1);
  }

  uint32_t currentFrequency;
    
  Serial.println("Hello!");
  
  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  // you can call a setCalibration function to change this range (see comments).
  ina219.begin();
  // To use a slightly lower 32V, 1A range (higher precision on amps):
  //ina219.setCalibration_32V_1A();
  // Or to use a lower 16V, 400mA range (higher precision on volts and amps):
  //ina219.setCalibration_16V_400mA();

  Serial.println("Measuring voltage and current with INA219 ...");
}

void loop(void) 
{
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  
  Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");

  delay(2000);
}

From what I understand, there are adjustments in the library that need to be made for the different shunt. There are some embedded steps however I tried following these without any luck.

I think that the PGA gain can be adjusted in the library, however I am just unsure how to do it.

Any assistance would be of great assistance.

Adafruit_INA219.cpp (17.6 KB)

Adafruit_INA219.h (9.39 KB)