Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

setShuntConversion()

Arnd edited this page Jun 22, 2018 · 3 revisions

setShuntConversion(Key[,deviceNumber]);

‼️ This library is now deprecated and has been replaced by the INA library. All existing INA226 functionality and functions have been implemented ‼️

Set measurement time as specified below for the device given in "deviceNumber"; setting all devices if the "deviceNumber" parameter is omitted.

Measurement time for the shunt is controlled with this function, allowing the following values:

Key
(Binary)
Measurement Time
001 140μs
001 204μs
010 332μs
011 588μs
100 1.1ms (Default)
101 2.116ms
110 4.156ms
111 8.244ms

The datasheet illustrates that longer measurement periods increase accuracy.


Example:

INA226_Class INA226(); // Instantiate the class
void setup() {
  INA226.begin(50,100000); // 5V bus with maximum current of 500mA
                           // A 0.1 Ohm shunt resistor generates 50mV max
  INA226.setMode(INA_MODE_CONTINUOUS_BUS); // only compute bus values
  INA226.setShuntConversion(6); // set conversion time 4.156ms or 240.6 per second for all devices
} // of setup

void loop() { uint16_t BusMicroAmps = INA226.getBusMicroAmps(); Serial.print("Bus amperage is "); Serial.print((float)BusMicroAmps/1000,3); Serial.print(" mVolts\n"); delay(5000); // wait 5 seconds before next measurement
} // of main loop