Skip to content

setShuntConversion()

Arnd edited this page Dec 12, 2020 · 4 revisions

setShuntConversion(conversionTime [,deviceNumber]);

The shunt conversion time ranges from 148μs to 8.244ms, with longer conversion sampling times generating more accurate measurements. When coupled with the setAveraging() call the exact Timing and accuracy of measurements can be set.

The method accepts the "conversionTime" in Units of microseconds and the value is rounded down to the closest actual value allowed for the INA2xx device in question. Specifying "100000" for an INA219 would get rounded down to the nearest value (85.10ms in this case), or to 41.56ms on an INA226.

The datasheets illustrates that longer measurement periods increase accuracy.


Example:

INA_Class INA(); // Instantiate the class
void setup() {
  INA.begin(10,100000); // 10A Maximum with a 0.1 Ohm shunt resistor
  INA.setMode(INA_MODE_CONTINUOUS_BUS); // only compute bus values
  INA.setShuntConversion(5000); // set conversion time as close to 5ms as possible
} // of setup
void loop() {
  uint16_t BusMillivolts = INA.getBusMillivolts();
  Serial.print("Bus voltage is ");
  Serial.print((float)BusMillivolts/1000,3);
  Serial.print(" Volts\n");
  delay(5000); // wait 5 seconds before next measurement        
} // of main loop