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

setBusConversion()

Arnd edited this page Jun 22, 2018 · 4 revisions

setBusConversion(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 conversion attributes as specified below for the device given in "deviceNumber"; setting all devices if the "deviceNumber" parameter is omitted.

Measurement time for the bus 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.setBusConversion(6); // set conversion time 4.156ms or 240.6 per second
} // of setup

void loop() { uint16_t BusMillivolts = INA226.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