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

getBusMilliVolts()

Arnd edited this page Jun 22, 2018 · 7 revisions

getBusMilliVolts(waitSwitch[,deviceNumber]);

‼️ This library is now deprecated and has been replaced by the INA library. All existing INA226 functionality and functions have been implemented ‼️

This function returns the bus voltage of the specified "deviceNumber" device, defaulting to device 0 when the parameter is not specified, in units of millivolts. The INA226 has an internal accuracy of 1.25 mV for the bus measurements. The bus voltage is returned as an unsigned 16-bit integer as the voltage cannot go below zero. The "waitSwitch" boolean parameter waits for any active conversion to complete when set to "true", otherwise takes the current value. If the system mode is set to triggered measurements rather than continuous ones (see setMode() for details) then the next measurement is triggered by this read.

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


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() {
  uint16_t BusMillivolts = INA226.getBusMillivolts(true,0); // 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