Skip to content

setI2CSpeed()

Arnd edited this page Oct 29, 2018 · 3 revisions

setI2CSpeed([I2CSpeed]);

The I2C bus defaults to the slowest speed, 100KHz. The INA devices allow for higher speeds and this call will change the bus speed, one of the following constants can be used:

Constant Speed
INA_I2C_STANDARD_MODE 100KHz
INA_I2C_FAST_MODE 400KHz
INA_I2C_FAST_MODE_PLUS 1MHz
INA_I2C_HIGH_SPEED_MODE 3.4MHz

Note that the I2C bus speed should be that of the slowest device attached to the bus.


Example:

INA_Class INA(); // Instantiate the class
void setup() {
  INA.begin(1,100000);  // 1A max current and a 0.1 Ohm shunt resistor 
                        // Note that a power resistor should be used 
                        // to dissipate sufficient generated heat, 
                        // Watts = Amps² x Resistance (0.1W in this case)
   INA.setI2CSpeed(INA_I2C_FAST_MODE_PLUS); // increase bus speed to 1MHz
} // of Setup

void loop() {
   /* ... */
} // of main loop