-
Notifications
You must be signed in to change notification settings - Fork 9
begin()
This function will set up all INA226s found with the appropriate internal calibration setting so that the output readings for amps and watts are correct when called without specifying a device number, otherwise just the device number (starting at 0) is initialized to the expected Amps and shunt resistance. If the settings are entered incorrectly the readings for bus voltage and shunt voltage will remain correct, but the internal computations to derive power will be incorrect.
The INA226 uses the industry standard I2C protocol for communications. Each I²C device has a unique address and this is selectable on the INA226 by setting certain pins high, low or shorting them with other pins. The datasheet describes the possible address settings on page 18. The INA226 library will search the I²C bus for all matching devices. Each device uses 96 bytes of EEPROM memory and once the available EEPROM memory capacity is exhausted the routine stop looking for additional devices.
Parameter | Units | Description |
---|---|---|
Maximum Shunt Amperage | Amps | This value is determined using Ohm's law from maximum voltage and resistance of the shunt. Typically the value is given on the shunt, e.g. "Maximum 75mOhm at 10A". Correct setting of this value is important to correctly scale the readings. |
Resistance | microOhms | The resistance of the shunt is the key factor in determining the amps and watts measured by the INA226. Since the library does not use floating point and many shunts for high-power applications have a resistance of 0.00025Ω (Ohm), so the value of the resistor in ohm needs to be multiplied by 1000 to convert from Ohms to miliohms and once more by 1000 to convert to microOhms and allow entering the correct value without loss of precision. |
I have a 200Amp / 50mV shunt which is initialized with begin(200,50000);
INA226_Class INA226(); // Instantiate the class
void setup() {
INA226.begin(200,50000); // 5V bus with maximum current of 500mA
// A 0.1 Ohm shunt resistor generates 50mV max
// Note that a power resistor should be used
// to dissipate any heat,
// Watts = Amps² x Resistance (0.025W in this case)
} // of setup