Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing for custom shunt resistors #43

Open
Bogdancev opened this issue Aug 4, 2020 · 1 comment
Open

Providing for custom shunt resistors #43

Bogdancev opened this issue Aug 4, 2020 · 1 comment

Comments

@Bogdancev
Copy link

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.

@xitonghan
Copy link

I=u/r
ShuntVoltage you can get R you know
so I is easy
and W=UI so ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants