title: Adafruit INA219 module, shunt voltage values and calibration
body: <p>I'm using the Adafruit INA219 module to measure voltage and current to a linear actuator, and I have a question about how to best calibrate the module to my situation.</p>
  <p>I have a 12V power supply (similar looking to a power brick for a laptop) that has a max current rating of 10A.  The actuator is rated for 12V @ 5A maximum, delivering a force of 35lbs.  I'm using the MegaMoto driver shield to drive the actuator, and an Arduino Nano as the controller.</p>
  <p>The default calibration for the INA219 module seems to be for 32V @ 2A, and it has some other settings available via function calls <a href="https://github.com/adafruit/Adafruit_INA219/blob/master/Adafruit_INA219.cpp" rel="nofollow noreferrer">here</a>, but I don't see anything that fits with a 12V @ 5A situation, and am not sure what to use for the various values if I was to write a new function to calibrate the INA219.  Anybody know what I can use?</p>
  <p>I was hoping I'd have accurate readings out of the box on this module for what I needed, but instead I'm getting some pretty wide value swings and some odd(?) shunt voltage values (or very possibly, I just don't understand them).  For example, when moving the actuator, I'm reading the values from the module every 1ms for 15ms, then averaging out the power usage and using that as a way to filter out the highs and lows to see what the general power usage is.  I'm using the equations from the example code:</p>
  <pre><code>shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  power = current_mA * loadvoltage;
  </code></pre>
  <p>Here's an example of a reading:</p>
  <blockquote>
  <p>shuntvoltage: -31.76
  busvoltage: 12.16
  current_mA: -258.60
  loadvoltage: 12.13
  power: -3137.40</p>
  <p>shuntvoltage: -59.12
  busvoltage: 12.16
  current_mA: -548.50
  loadvoltage: 12.10
  power: -6637.33</p>
  <p>shuntvoltage: -52.00
  busvoltage: 12.18
  current_mA: -691.30
  loadvoltage: 12.12
  power: -8381.32</p>
  <p>shuntvoltage: -32.09
  busvoltage: 12.12
  current_mA: -936.60
  loadvoltage: 12.09
  power: -11321.54</p>
  <p>shuntvoltage: -27.42
  busvoltage: 12.11
  current_mA: -286.00
  loadvoltage: 12.08
  power: -3455.05</p>
  <p>shuntvoltage: -86.82
  busvoltage: 12.11
  current_mA: -338.90
  loadvoltage: 12.03
  power: -4075.33</p>
  <p>shuntvoltage: -67.63
  busvoltage: 12.16
  current_mA: -620.90
  loadvoltage: 12.09
  power: -7508.15</p>
  <p>shuntvoltage: -30.81
  busvoltage: 12.18
  current_mA: -874.60
  loadvoltage: 12.15
  power: -10625.68</p>
  <p>shuntvoltage: -30.31
  busvoltage: 12.11
  current_mA: -346.90
  loadvoltage: 12.08
  power: -4189.75</p>
  <p>shuntvoltage: -71.75
  busvoltage: 12.16
  current_mA: -557.00
  loadvoltage: 12.09
  power: -6733.16</p>
  <p>shuntvoltage: -48.03
  busvoltage: 12.18
  current_mA: -668.70
  loadvoltage: 12.13
  power: -8112.65</p>
  <p>shuntvoltage: -31.90
  busvoltage: 12.18
  current_mA: -938.20
  loadvoltage: 12.15
  power: -11397.35</p>
  <p>shuntvoltage: -30.14
  busvoltage: 12.12
  current_mA: -627.20
  loadvoltage: 12.09
  power: -7580.25</p>
  <p>shuntvoltage: -31.42
  busvoltage: 12.14
  current_mA: -430.20
  loadvoltage: 12.10
  power: -5207.39</p>
  <p>shuntvoltage: -66.28
  busvoltage: 12.17
  current_mA: -643.70
  loadvoltage: 12.10
  power: -7789.88</p>
  <p>shuntvoltage: -30.93
  busvoltage: 12.18
  current_mA: -880.00
  loadvoltage: 12.15
  power: -10694.70</p>
  </blockquote>
  <p>Why are the shunt voltage values negatives? And the current values?  Maybe I just need to reverse the polarity.</p>
  <p>Here's the specs on the actuator: <a href="http://www.progressiveautomations.com/media/catalog/pdf/Linear_Actuator_with_Potentiometer_PA-14P.pdf" rel="nofollow noreferrer">http://www.progressiveautomations.com/media/catalog/pdf/Linear_Actuator_with_Potentiometer_PA-14P.pdf</a></p>