Skip to content

getBusMicroAmps()

Arnd edited this page Jun 19, 2018 · 2 revisions

getBusMicroAmps([deviceNumber]);

This function returns the amps on the bus for "deviceNumber" in units of microamps, 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); // 10Amp Maximum current, 0.1 Ohm shunt resistor (generates 50mV max)
} // of setup
void loop() {
  int32_t busMicroAmps= INA.getBusMicroAmps();
  Serial.print("Bus amperage is ");
  Serial.print((float)busMicroAmps/1000,3);
  Serial.print(" mA\n");
  delay(5000); // wait 5 seconds before next measurement        
} // of main loop