-
Notifications
You must be signed in to change notification settings - Fork 40
waitForConversion()
waits for conversion to complete as specified below for the device specified in "deviceNumber"; performing a wait for all devices if the "deviceNumber" parameter is omitted.
The last measurement for bus voltage, shunt voltage, computed amps and computed watts is always available, the new value is being computed by the INA2xx in the background, either continuously or triggered by an explicit call. The INA2xx sets an internal flag when the currently running conversion has completed, and this function will not return until the computation has completed. It also resets the flag so that it can be set by the next conversion.
INA_Class INA(); // Instantiate the class
void setup() {
INA.begin(10,100000); // Max 10A and a 0.1 Ohm shunt resistor
INA.setMode(INA_MODE_CONTINUOUS_BUS); // only compute bus values
INA.setBusConversion(7); // set bus conversion time 8.2446ms
INA.setShuntConversion(7); // set shunt conversion time 8.2446ms
INA.setAveraging(1024); // set to 1024 samples
} // of setup
void loop() {
INA.waitForConversion(); // conversion takes 1024*8.2446ms = 8.44 seconds on a INA226
uint16_t BusMicroAmps = INA.getBusMicroAmps();
Serial.print("Bus amperage is ");
Serial.print((float)BusMicroAmps/1000,3);
Serial.print(" mVolts\n");
} // of main loop
Overview
Installation
Class Instantiation
begin()
setI2CSpeed()
getBusMilliVolts()
getBusRaw()
getShuntMicroVolts()
getShuntRaw()
getBusMicroAmps()
getBusMicroWatts()
getDeviceAddress()
getDeviceName()
setMode()
setAveraging()
setBusConversion()
setShuntConversion()
reset()
waitForConversion()
conversionFinished()
alertOnConversion()
alertOnShuntOverVoltage()
alertOnShuntUnderVoltage()
alertOnBusOverVoltage()
alertOnBusUnderVoltage()
alertOnPowerOverLimit()