Adafruit_INA219
Adafruit_INA219 copied to clipboard
Providing for custom shunt resistors
I had to de-solder 0.1 Ohm resistor and put 0.04 in. Now I need to change the code of the library to make it work. As alternative could you change assess modifier like so?:
protected:
Adafruit_I2CDevice *i2c_dev = NULL;
uint8_t ina219_i2caddr = -1;
uint32_t ina219_calValue;
// The following multipliers are used to convert raw current and power
// values to mA and mW, taking into account the current config settings
uint32_t ina219_currentDivider_mA;
float ina219_powerMultiplier_mW;
private:
void init();
int16_t getBusVoltage_raw();
int16_t getShuntVoltage_raw();
int16_t getCurrent_raw();
int16_t getPower_raw();
Protected fields are accessible in child class and thus I could use it like so:
class MyINA219 : public Adafruit_INA219 {
public:
void setCalibration_32_5A() {
...
ina219_calValue = 5012;
ina219_currentDivider_mA = 20;
ina219_powerMultiplier_mW = 4;
...
}
};
Note, that this allows to add custom calibration methods to accommodate any resistor values. This change will allow for more flexibility. I can add Pull Request should you accept this change.