Skip to content

getBusMilliVolts()

Arnd edited this page Dec 12, 2020 · 4 revisions

getBusMilliVolts([deviceNumber]);

This function returns the bus voltage in millivolts of the specified "deviceNumber" device, defaulting to device 0 when the parameter is not specified. Each INA2xx has a defined LSB for bus accuracy, typically 1.25 mV. The bus voltage is returned as an unsigned 16-bit integer as the voltage cannot go below zero. If the system mode is set to triggered measurements rather than continuous ones (see setMode() for details) then the next measurement cycle is triggered by this read.

This value is directly read from the INA2xx registers and is not affected by the settings for calibration given in the begin() function call.


Example:

INA_Class INA(); // Instantiate the class
void setup() {
  uint8_t deviceCount = INA.begin(10,100000); // 10 Amp Maximum bus with a shunt resistor of 0.1 Ohm
  Serial.print("Found ");
  Serial.print(deviceCount); 
  Serial.print(" INA2xx devices, displaying data for device 0, a \"");
  Serial.print(INA.getDeviceName());
  Serial.println("\".");
} // of setup
void loop() {
  uint16_t BusMillivolts = INA.getBusMilliVolts(); // wait for conversion on device 0 to complete
  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