Skip to content

getBusMicroWatts()

Arnd edited this page May 5, 2020 · 3 revisions

getBusMicroWatts([deviceNumber]);

This function returns the watts on the bus in units of microwatts for "deviceNumber", defaulting to device 0 when the parameter is not specified. 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() 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() or getShuntMicroVolts().


Example:

INA_Class INA(); // Instantiate the class
void setup() {
  INA.begin(10,100000); // 10A and 0.1 Ohm shunt resistor generates 50mV max
} // of setup
void loop() {
  int64_t busMicroWatts= INA.getBusMicroWatts(0); // get microwatts from device 0, changed from 32bits at v1.0.11
  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