Sorry if this has been already discussed, but I can't find anything in the other posts.
I have an INA219 I2C sensor that I want to use to measure currents up to a maximum of 50A (it's very rare to reach this figure).
The circuit to be measured is 12V and an external shunt sensor.
I've removed the on-board 0.1Ω shunt from the INA219 and connected it to my external 50A shunt, 75mV which has a resistance of 1.5mΩ. I connected it to the Arduino uno according to the sketch below and received the results on the serial monitor.
However, I'm having trouble calibrating the INA219 library to a 50A, 75mV shunt to get an accurate reading. I just want to measure Bus Voltage and Shunt Current for my application.
Does anyone have experience calibrating this board that might help me?
Please post the code, using code tags, and links to the board and the library you are using.
If you are using the Adafruit library, there are some notes on their site about calibration for an external shunt. If I recall correctly, that requires modifying the library code.
I looked quickly at the code and it seems to just print out the data.
Can you go into more detail?
What trouble are you having?
Do you know your 75A test current is stable, or you trying to input mv to simulate the shunt voltage?
The shunt voltage is the voltage across the shunt. It doesn't matter what shunt you have, this is the voltage across it. You can calculate the actual current in your program.
float shuntvoltage = 0; //<----------------------------------------- voltage across shunt
float busvoltage = 0; //<---------------------------------------- bus voltage
float current_mA = 0; // ignore for your application
float loadvoltage = 0; // ignore for your application;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
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.println("");
Have you been reading my sketch on #3? I already put the formula in my sketch, but the results on the serial monitor were incorrect. How come? What's wrong and what should I do? Does the library need to make changes? tia^^
The INA219 has an internal current calculation function.
Which is used by Adafruit's library.
Current doesn't calculate from shunt voltage with software.
Therefore, the magic number of fomula result with used shunt resistor values is written to the calibration register of INA219.
Of course, it is possible to read only the shunt voltage without using the current reading function and calculate it with software.
I looked through your code and looked at the Adafruit example. I see only minor differences however since you are getting erroreornous results I suggest you try the Adafruit example: "getcurrent.ino" as it is written, make NO changes. Don't add the device address as you did with your code.
I don't know if the above will solve your issue but it is what I would do if I were in your place.
If that doesn't work then the only two options are: