Releases: wollewald/INA226_WE
Red module with 2 mohms shunt included
setCorrectionFactor can now be used several times
If you applied a correction factor of let's say 0.9 and you did that twice, the resulting correction factor was 0.9 * 0.9 = 0.81. This is changed now.
Fixed example sketches
In the sketches using interrupts I forgot the digitalPinToInterrupt() function within the detachInterrupt() function. Fixed now.
Eliminated Range Setting
Setting the range to 0.8 or 0.4 amperes was not useful. Setting the 0.4 ampere range suggested an increased resolution. But the resolution is given by the shunt voltage register resolution.
Compatibility with INA219_WE
When I developed the library I did not choose the best enum names for the measure modes. E.g. "POWER_DOWN" is also used in INA219_WE. If you have problems then uncomment the line: #define INA226_WE_COMPATIBILITY_MODE_ in INA226_WE_config.h and use "INA226_POWER_DOWN" instead of "POWER_DOWN". Do the same for "CONTINUOUS" (-> INA226_CONTINUOUS) AND TRIGGERED (-> INA226_TRIGGERED).
Added a function to return the I2C error code
I added the function getI2cErrorCode() which return the return value of endTransmission. I updated the example sketches Trigger.ino and Continuous.ino to show how it works.
I have also added a timeout check for startSingleMeasurement() of 2 seconds to avoid that the program hangs forever in case of unavailability of the INA226.
Replaced defines by constexpr
Several changes:
- tidied constructors
- replaced #defines by constexpr
- replaced C-Cast by static_cast
- replace private by protected
- corrected typos in example sketches
Added comments about poor quality modules in readme
Added comments about poor quality modules in readme
Read performance increase
In the readRegister function, I have added a "false" in Wire.endTransmission() ---> Wire.endTransmission(false) before Wire.requestFrom(). This saves some microseconds.
TwoWire object can now be passed to the constructor
There are now new options to create your INA226 object:
- INA226_WE ina226 = INA226_WE() -> uses Wire / I2C Address = 0x40
- INA226_WE ina226 = INA226_WE(ICM20948_ADDR) -> uses Wire / I2C_ADDRESS
- INA226_WE ina226 = INA226_WE(&wire2) -> uses the TwoWire object wire2 / I2C_ADDRESS
- INA226_WE ina226 = INA226_WE(&wire2, I2C_ADDRESS) -> all together
This enables you to e.g. to use the two ESP32 I2C busses