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

getBusMicroWatts()

Arnd edited this page Jan 10, 2017 · 4 revisions

getBusMicroWatts();

This function returns the watts on the bus in units of microwatts. The measurements are not done directly but are computed from the main bus voltage as well as the shunt voltage, so the settings specified in the [begin()](https://github.com/SV-Zanshin/INA226/wiki/begin() function call are very important; errors in those settings will result in incorrect amperage and wattage values. Since the possible range of amps is so large, a signed 4-byte 32-bit integer value is used. The accuracy of the result remains at 15-bits of precision so the result can be reduced to the appropriate 2-byte integer value depending upon the scale.

If the system mode is set to triggered measurements rather than continuous ones (see setMode() for details) then the next measurement is not triggered by this read, that needs to be done with a call to [getBusMilliVolts()](https://github.com/SV-Zanshin/INA226/wiki/getBusMilliVolts() or [getShuntMicroVolts()](https://github.com/SV-Zanshin/INA226/wiki/getShuntMicroVolts().


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
} // of setup
void loop() {
  int32_t busMicroWatts= INA226.getBusMicroWatts();
  Serial.print("Bus wattage is ");
  Serial.print((float)busMicroWatts/1000,3);
  Serial.print(" mW\n");
  delay(5000); // wait 5 seconds before next measurement        
} // of main loop