Skip to content

alertOnBusOverVoltage()

Arnd edited this page Sep 29, 2021 · 3 revisions

alertOnBusOverVoltage(State, millivolts [, deviceNumber]);

This call is ignored for devices such as the INA219 which have no "ALERT" pin. It will Set, or UnSet, the alert pin functionality depending upon the setting of the "State" boolean Switch for the device given in "deviceNumber"; setting all devices which have an alert pin if the optional "deviceNumber" parameter is omitted.

This function accepts a boolean argument which activates changing state detection on the ALERT pin and a threshold value in millivolts for the bus voltage. The pin is open drain so should be pulled high with either an external resistor or by using the Arduino call "pinMode(,INPUT_PULLUP);". When the bus voltage exeeds the amount specified in the "millivolts" Parameter the INA2xx will pull this pin down to ground. The state will remain set until the voltage on the shunt goes below the threshold limit.


Example:

(Show Fritzing example layout here)

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("\".");
  INA.alertOnBusOverVoltage(true,5000); // Set Alarm Pin when voltage is 5V and bus amperage exceeds 5A
                                        // Ohm's Law : .5V / .1 Ohm
} // of setup
void loop() {
  uint16_t ShuntMillivolts = INA.getShuntMilliVolts(); 
  Serial.print("Shunt voltage is ");
  Serial.print(ShuntMillivolts);
  Serial.print(" milliVolts\n");
  delay(5000); // wait 5 seconds before next measurement        
} // of main loop