{"id":10483,"date":"2021-01-02T20:26:27","date_gmt":"2021-01-02T20:26:27","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/ina219-current-and-power-sensor"},"modified":"2025-09-28T19:11:28","modified_gmt":"2025-09-28T19:11:28","slug":"ina219-current-and-power-sensor","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor","title":{"rendered":"INA219 Current and Power Sensor"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About this Post<\/h2>\n\n<p>In this article I would like to introduce the INA219 current and power sensor module and my associated library <a href=\"https:\/\/github.com\/wollewald\/INA219_WE\" target=\"_blank\" rel=\"noopener noreferrer\">INA219_WE.<\/a><\/p>\n<p>In addition to the INA219, I tried out various other current sensor modules such as the ACS712 or the MAXIM471. However, I liked the INA219 best because it reliably detects currents of a few milliamperes. In addition to the current, the module also determines the power and voltage drop across the system to be measured. I will deal with the INA226, so to speak the brother of INA219, in another article.<\/p>\n<p>Libraries for the INA219 already existed, but I wasn&#8217;t pleased with any. Either I lacked certain options such as the trigger mode or I found the functions a bit unwieldy to use. But the tastes are different. If you want to try alternative libraries, you can find some of them in the Arduino Library Manager at GitHub (under search term INA219).<\/p>\n\n<h2 class=\"wp-block-heading\">Measuring principle of the INA219<\/h2>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-1024x430.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"430\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-1024x430.jpg\" alt=\"INA219 modules from different sources\" class=\"wp-image-6601\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-1024x430.jpg 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-300x126.jpg 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-768x322.jpg 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-1536x645.jpg 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module-1320x554.jpg 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Module.jpg 1703w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Various INA219 modules<\/figcaption><\/figure>\n\n<p>The measuring principle of the INA219 is simply based on Ohm&#8217;s law. The current to be measured is passed through a resistor and the voltage dropping across it is determined. Since one wants to interfere as little as possible with the system to be measured, the resistance is tiny. Such a current measuring resistor is called a <a href=\"https:\/\/de.wikipedia.org\/wiki\/Shunt_(Elektrotechnik)\" target=\"_blank\" rel=\"noopener noreferrer\">shunt<\/a>. In the case of the INA219 module, the shunt has a size of 0.1 Ohm (R100). <\/p>\n<p>The INA219&#8217;s shunt is integrated into the consumer&#8217;s circuit as shown below. To calculate the size of the current, you basically just have to multiply the voltage drop across the shunt by 10. Why do you need something as complex as the INA219? Well, on the one hand, the voltage to be measured is small. So, you need an amplifier and &#8211; that&#8217;s anyway &#8211; an A\/D converter. On the other hand, the INA219 can measure a little more than just the current.<\/p>\n<p>In addition to the shunt voltage, the INA219 also determines the voltage drop across the consumer (&#8220;bus&#8221;) between VIN and GND. From this and from the size of the current, the INA219 calculates the power consumption of the consumer.<\/p>\n<p>The circuit of shunt and consumer is separated from the supply current of the INA219. It is important, however, that the two have a common GND. <\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/INA219_scheme-1024x539.png\"><img decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/INA219_scheme-1024x539.png\" alt=\"How to integrate the INA219 into the circuit to be measured\" class=\"wp-image-6620\"\/><\/a><figcaption class=\"wp-element-caption\">How to integrate the INA219 into the circuit to be measured<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\">Typical circuit<\/h3>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-1024x572.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"572\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-1024x572.png\" alt=\"Typical circuit for the INA219\" class=\"wp-image-6607\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-1024x572.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-300x168.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-768x429.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring-1320x737.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/INA219_Wiring.png 1499w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Typical circuit for the INA219<\/figcaption><\/figure>\n\n<p>The INA219, more precisely the shunt, must be inserted into the circuit <strong>before <\/strong>the consumer, otherwise the measurement of the bus voltage will not work. This setup is called high-side.<\/p>\n<p>The connection is simple. It doesn&#8217;t matter if you use the terminals or the pins for VIN+ and VIN-.<\/p>\n<p>By the way, if you swap VIN- and VIN+ in the circuit shown above, you get negative values for the current and the shunt voltage.<\/p>\n\n<h2 class=\"wp-block-heading\">Some technical data of the INA219 module<\/h2>\n\n<p>Here are the most important data of the INA219 module:<\/p>\n<ul>\n<li>Bus voltage: 0 &#8211; 26 volts<\/li>\n<li>maximum bus current: 3.2 amps (with 0.1 Ohm shunt)<\/li>\n<li>Supply voltage: 3 &#8211; 5.5 volts<\/li>\n<li>Power consumption (self-determined):\n<ul>\n<li>Continuous mode: 0.7 mA <\/li>\n<li>Power-Down mode: 9.5 \u00b5A <\/li>\n<\/ul>\n<\/li>\n<li>4 gain levels (1-, 2-, 4-, 8-fold)<\/li>\n<li>Measurement modes: continuous or on-demand (&#8220;triggered&#8221;);<\/li>\n<li>Data registers:\n<ul>\n<li>Shunt voltage register<\/li>\n<li>Bus voltage register<\/li>\n<li>Current register<\/li>\n<li>Power register<\/li>\n<\/ul>\n<\/li>\n<li>Communication via I\u00b2C, 4 addresses can be set:\n<ul>\n<li><strong>0x40<\/strong>: A0, A1 open<\/li>\n<li><strong>0x41<\/strong>: A0 closed, A1 open<\/li>\n<li><strong>0x44<\/strong>: A0 open, A1 closed<\/li>\n<li><strong>0x45<\/strong>: A0, A1 closed<\/li>\n<li>A further 12 addresses can be set (somewhat inconveniently) by connecting A0 or A1 with SDA or SCL (see data sheet). <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>If you want to check the I\u00b2C address, you can use my <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/i2c-scanner\" target=\"_blank\" rel=\"noopener noreferrer\">I\u00b2C scanner<\/a>.<\/p>\n<p>Further technical information can be found in the <a href=\"https:\/\/www.ti.com\/lit\/ds\/symlink\/ina219.pdf?ts=1591384147001&amp;ref_url=https:\/\/www.ti.com\/product\/INA219ttps:\/\/www.google.de\/\" target=\"_blank\" rel=\"noopener noreferrer\">data sheet<\/a> of the INA219. <\/p>\n<p>You get the INA219 for a few euros in most online electronics stores, e.g. <a href=\"https:\/\/smile.amazon.de\/s?k=INA219&amp;__mk_de_DE=%C3%85M%C3%85%C5%BD%C3%95%C3%91&amp;ref=nb_sb_noss_2\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> at Amazon. More expensive are modules from <a href=\"https:\/\/learn.adafruit.com\/adafruit-ina219-current-sensor-breakout\" target=\"_blank\" rel=\"noopener noreferrer\">Adafruit<\/a>. I cannot judge whether the price difference is reflected in better quality.<\/p>\n\n<h2 class=\"wp-block-heading\">Use of the INA219_WE library<\/h2>\n\n<p>You either install the library using the Arduino library manager, or you can download it from GitHub <a href=\"https:\/\/github.com\/wollewald\/INA219_WE\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.&nbsp;<\/p>\n\n<h3 class=\"wp-block-heading\">Continuous mode <\/h3>\n\n<p>Build your circuit as shown above. Then upload the sample sketch &#8220;Continuous.ino&#8221;:&nbsp;<\/p>\n<\/p>\n<div class=\"scroll-paragraph\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"Continuous.ino\" data-enlighter-title=\"Continuous.ino\">#include &lt;Wire.h&gt;\n#include &lt;INA219_WE.h&gt;\n#define I2C_ADDRESS 0x40\n\n\/* There are several ways to create your INA219 object:\n * INA219_WE ina219 = INA219_WE(); -&gt; uses Wire \/ I2C Address = 0x40\n * INA219_WE ina219 = INA219_WE(I2C_ADDRESS); -&gt; uses Wire \/ I2C_ADDRESS\n * INA219_WE ina219 = INA219_WE(&amp;Wire); -&gt; you can pass any TwoWire object\n * INA219_WE ina219 = INA219_WE(&amp;Wire, I2C_ADDRESS); -&gt; all together\n *\/\nINA219_WE ina219 = INA219_WE(I2C_ADDRESS);\n\nvoid setup() {\n  Serial.begin(115200);\n  Wire.begin();\n  if(!ina219.init()){\n    Serial.println(\"INA219 not connected!\");\n    while(1);\n  }\n\n  \/* Set ADC Mode for Bus and ShuntVoltage\n    * Mode *                 * Res \/ Samples *       * Conversion Time *\n    INA219_BIT_MODE_9        9 Bit Resolution             84 \u00b5s\n    INA219_BIT_MODE_10       10 Bit Resolution            148 \u00b5s  \n    INA219_BIT_MODE_11       11 Bit Resolution            276 \u00b5s\n    INA219_BIT_MODE_12       12 Bit Resolution            532 \u00b5s  (DEFAULT)\n    INA219_SAMPLE_MODE_2     Mean Value 2 samples         1.06 ms\n    INA219_SAMPLE_MODE_4     Mean Value 4 samples         2.13 ms\n    INA219_SAMPLE_MODE_8     Mean Value 8 samples         4.26 ms\n    INA219_SAMPLE_MODE_16    Mean Value 16 samples        8.51 ms     \n    INA219_SAMPLE_MODE_32    Mean Value 32 samples        17.02 ms\n    INA219_SAMPLE_MODE_64    Mean Value 64 samples        34.05 ms\n    INA219_SAMPLE_MODE_128   Mean Value 128 samples       68.10 ms\n    \n    If you measure both current and bus voltage (which is the default), the conversion time doubles.\n  *\/\n  \/\/ina219.setADCMode(INA219_SAMPLE_MODE_128); \/\/ choose mode and uncomment for change of default\n  \n  \/* Set measure mode\n    INA219_POWER_DOWN              - INA219 switched off\n    INA219_TRIGGERED               - measurement on demand, current and bus\n    INA219_TRIGGERED_CURRENT_ONLY  - on demand, current only\n    INA219_TRIGGERED_BUS_ONLY      - on demand, bus voltage only\n    INA219_ADC_OFF                 - analog\/digital converter switched off\n    INA219_CONTINUOUS              - continuous measurements (DEFAULT)\n    INA219_CONTINUOUS_CURRENT_ONLY - continuous, current only\n    INA219_CONTINUOUS_BUS_ONLY     - continuous, bus voltage only\n  *\/\n  \/\/ ina219.setMeasureMode(INA219_CONTINUOUS); \/\/ choose mode and uncomment for change of default\n  \n  \/* Set PGain\n     * Gain *     * Shunt Voltage Range *   * Max Current (if shunt is 0.1 ohms) *\n    INA219_PG_40         40 mV                    0.4 A\n    INA219_PG_80         80 mV                    0.8 A\n    INA219_PG_160        160 mV                   1.6 A\n    INA219_PG_320        320 mV                   3.2 A (DEFAULT)\n  *\/\n  \/\/ ina219.setPGain(INA219_PG_320); \/\/ choose gain and uncomment for change of default\n  \n  \/* Set Bus Voltage Range\n    INA219_BRNG_16   -&gt; 16 V\n    INA219_BRNG_32   -&gt; 32 V (DEFAULT)\n  *\/\n  \/\/ ina219.setBusRange(INA219_BRNG_32); \/\/ choose range and uncomment for change of default\n\n  Serial.println(\"INA219 Current Sensor Example Sketch - Continuous\");\n\n  \/* If the current values delivered by the INA219 differ by a constant factor\n    from values obtained with calibrated equipment you can define a correction factor.\n    Correction factor = current delivered from calibrated equipment \/ current delivered by INA219\n  *\/\n  \/\/ ina219.setCorrectionFactor(0.98); \/\/ insert your correction factor if necessary\n  \n  \/* If you experience a shunt voltage offset, that means you detect a shunt voltage which is not \n    zero, although the current should be zero, you can apply a correction. For this, uncomment the \n    following function and apply the offset you have detected.   \n  *\/\n  \/\/ ina219.setShuntVoltOffset_mV(0.5); \/\/ insert the shunt voltage (millivolts) you detect at zero current\n\n  \/* If you use a shunt different from 0.1 ohms (R100), you can change the shunt size using the\n    function below.\n  *\/\n  \/\/ina219.setShuntSizeInOhms(0.01); \n}\n\nvoid loop() {\n  float shuntVoltage_mV = 0.0;\n  float loadVoltage_V = 0.0;\n  float busVoltage_V = 0.0;\n  float current_mA = 0.0;\n  float power_mW = 0.0; \n  bool ina219_overflow = false;\n  \n  shuntVoltage_mV = ina219.getShuntVoltage_mV();\n  busVoltage_V = ina219.getBusVoltage_V();\n  current_mA = ina219.getCurrent_mA();\n  power_mW = ina219.getBusPower();\n  loadVoltage_V  = busVoltage_V + (shuntVoltage_mV\/1000);\n  ina219_overflow = ina219.getOverflow();\n  \n  Serial.print(\"Shunt Voltage [mV]: \"); Serial.println(shuntVoltage_mV);\n  Serial.print(\"Bus Voltage [V]: \"); Serial.println(busVoltage_V);\n  Serial.print(\"Load Voltage [V]: \"); Serial.println(loadVoltage_V);\n  Serial.print(\"Current[mA]: \"); Serial.println(current_mA);\n  Serial.print(\"Bus Power [mW]: \"); Serial.println(power_mW);\n  if(!ina219_overflow){\n    Serial.println(\"Values OK - no overflow\");\n  }\n  else{\n    Serial.println(\"Overflow! Choose higher shunt voltage range or a smaller shunt.\");\n  }\n  Serial.println();\n  \n  delay(3000);\n}<\/pre>\n<p>\u00a0<\/p>\n<\/div>\n<p>\n\n<h4 class=\"wp-block-heading\">Parameter setting using the continuous.ino Sketch example<\/h4>\n\n<p>In this example, I would like to explain not only the continuous mode itself, but also the general setting parameters.<\/p>\n<p><code>INA219_WE ina219 = INA219_WE()<\/code> creates your INA219 object. I have implemented various options. You can pass a wire object and use the two I2C buses of an ESP32, for example.  &nbsp;<\/p>\n<p>The function <code>init()<\/code> ensures that the INA219 is activated with the default values. To change these basic settings, you can modify parameters in the setup:<\/p>\n<ol>\n<li>ADC mode for shunt and bus voltage conversion ( <code>setADCMode()<\/code> ):\n<ul>\n<li>INA219_BIT_MODE_X: Single measurements with X bit resolution.<\/li>\n<li>INA219_SAMPLE_MODE_X: Average value from X measurements.<\/li>\n<li>Default setting: INA219_BIT_MODE_12.<\/li>\n<li>The times for the A\/D conversion are specified in the sketch. Note that two conversions take place per measurement cycle, one for the shunt and one for the bus voltage.<\/li>\n<\/ul>\n<\/li>\n<li>Measuring mode ( <code>setMeasureMode()<\/code> )\n<ul>\n<li>INA219_CONTINUOUS &#8211; continuous: this is the default setting used here.<\/li>\n<li>INA219_TRIGGERED &#8211; &#8220;on request&#8221;: this is explained in the next example.<\/li>\n<li>You can also decide for CONTINUOUS and TRIGGERED whether you only want to determine the current or the bus voltage.<\/li>\n<li>INA219_ADC_OFF &#8211; Switch off the A\/D converter.<\/li>\n<li>INA219_POWER_DOWN &#8211; switches the INA219 off. But better use the more comfortable <code>powerDown()<\/code> function, which is explained below.<\/li>\n<\/ul>\n<\/li>\n<li>Gain factor ( <code>setPGain()<\/code> )\n<ul>\n<li>INA219_PG_X: The &#8220;X&#8221; indicates the limit for the shunt voltage. E.g.: PG_40 &#8211;&gt; &gt; 40 mV &#8211;&gt; corresponds to a maximum current of 400 mA.<\/li>\n<li>INA219_PG_40: Gain = 1, INA219_PG_80: Gain = 1\/2, INA219_PG_160: Gain = 1\/4, INA219_PG_320: Gain = 1\/8.<\/li>\n<\/ul>\n<\/li>\n<li>Bus voltage range ( <code>setBusRange()<\/code> )\n<ul>\n<li>16 or 32 volts<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>You can also change the settings at any time later, i.e. outside the setup function.<\/p>\n<p>With <code>setCorrectionFactor(factor)<\/code> you can introduce a correction factor if the current values determined with the INA219 should differ from those determined with calibrated measuring instruments. The factor is the quotient of the &#8220;correct&#8221; and the INA219 value. For me, all INA219 modules matched my multimeter well.<\/p>\n<p>Apparently some INA219 modules show shunt voltage offsets. This means that although no current is flowing (load switched off), a shunt voltage is displayed and a resulting current. You can compensate for this with <code>setShuntVoltOffset()<\/code>. Enter the shunt voltage that you measure without current as a parameter in millivolts.   &nbsp;&nbsp;<\/p>\n<p>The function <code>getOverflow()<\/code> checks whether one of the data registers is overflowed. If this is the case, select a different gain factor.<\/p>\n<p>The functions for reading the measurement results, such as <code>getShuntVoltage_mV()<\/code>, are self-explanatory.<\/p>\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Coninous.png\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"349\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Coninous.png\" alt=\"Output of the continuous sketch for the INA219\" class=\"wp-image-6626\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Coninous.png 716w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Coninous-300x146.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of the continuous sketch for the INA219<\/figcaption><\/figure>\n\n<p>Attentive readers may ask why &#8220;Current&#8221; in this output example does not exactly match ten times the shunt voltage (R<sub>Shunt<\/sub> was 0.1 Ohm). This is because the registers can be read at any time. The current conversion is not being waited for. The contents of the shunt and the current register can therefore originate from different measurement cycles. Another consequence is that the values can be up to 68.1 ms &#8220;old&#8221; (this would be the upper limit in SAMPLE_MODE_128). In continuous mode, however, this should not be a problem. In triggered mode, on the other hand, the system waits for the current conversion to complete after starting the measurement. <\/p>\n\n<h2 class=\"wp-block-heading\">Triggered (&#8220;on request&#8221;) mode<\/h2>\n\n<p>The example sketch for triggered mode differs from the continuous sketch in only two lines. The mode is activated in line 49. In line 94, <code>startSingleMeasurement()<\/code> starts the measurement.  Only when the measurement is completed, the output takes place.<\/p>\n<\/p>\n<div class=\"scroll-paragraph\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"Triggered.ino\" data-enlighter-title=\"Triggered.ino\">#include &lt;Wire.h&gt;\n#include &lt;INA219_WE.h&gt;\n#define I2C_ADDRESS 0x40\n\n\/* There are several ways to create your INA219 object:\n * INA219_WE ina219 = INA219_WE(); -&gt; uses Wire \/ I2C Address = 0x40\n * INA219_WE ina219 = INA219_WE(I2C_ADDRESS); -&gt; uses Wire \/ I2C_ADDRESS\n * INA219_WE ina219 = INA219_WE(&amp;Wire); -&gt; you can pass any TwoWire object\n * INA219_WE ina219 = INA219_WE(&amp;Wire, I2C_ADDRESS); -&gt; all together\n *\/\nINA219_WE ina219 = INA219_WE(I2C_ADDRESS);\n\nvoid setup() {\n  Serial.begin(115200);\n  Wire.begin();\n  if(!ina219.init()){\n    Serial.println(\"INA219 not connected!\");\n    while(1);\n}\n\n  \/* Set ADC Mode for Bus and ShuntVoltage\n    * Mode *                 * Res \/ Samples *        * Conversion Time *\n    INA219_BIT_MODE_9        9 Bit Resolution             84 \u00b5s\n    INA219_BIT_MODE_10       10 Bit Resolution            148 \u00b5s  \n    INA219_BIT_MODE_11       11 Bit Resolution            276 \u00b5s\n    INA219_BIT_MODE_12       12 Bit Resolution            532 \u00b5s  (DEFAULT)\n    INA219_SAMPLE_MODE_2     Mean Value 2 samples         1.06 ms\n    INA219_SAMPLE_MODE_4     Mean Value 4 samples         2.13 ms\n    INA219_SAMPLE_MODE_8     Mean Value 8 samples         4.26 ms\n    INA219_SAMPLE_MODE_16    Mean Value 16 samples        8.51 ms     \n    INA219_SAMPLE_MODE_32    Mean Value 32 samples        17.02 ms\n    INA219_SAMPLE_MODE_64    Mean Value 64 samples        34.05 ms\n    INA219_SAMPLE_MODE_128   Mean Value 128 samples       68.10 ms\n    \n    If you measure both current and bus voltage (which is the default), the conversion time doubles.\n  *\/\n  \/\/ina219.setADCMode(INA219_SAMPLE_MODE_128); \/\/ choose mode and uncomment for change of default\n  \n  \/* Set measure mode\n    INA219_POWER_DOWN              - INA219 switched off\n    INA219_TRIGGERED               - measurement on demand, current and bus\n    INA219_TRIGGERED_CURRENT_ONLY  - on demand, current only\n    INA219_TRIGGERED_BUS_ONLY      - on demand, bus voltage only\n    INA219_ADC_OFF                 - analog\/digital converter switched off\n    INA219_CONTINUOUS              - continuous measurements (DEFAULT)\n    INA219_CONTINUOUS_CURRENT_ONLY - continuous, current only\n    INA219_CONTINUOUS_BUS_ONLY     - continuous, bus voltage only\n  *\/\n  ina219.setMeasureMode(INA219_TRIGGERED); \/\/ Triggered measurements for this example\n  \n  \/* Set PGain\n      * Gain *      * Shunt Voltage Range *   * Max Current (if shunt is 0.1 ohms) *\n    INA219_PG_40          40 mV                   0.4 A\n    INA219_PG_80          80 mV                   0.8 A\n    INA219_PG_160         160 mV                  1.6 A\n    INA219_PG_320         320 mV                  3.2 A (DEFAULT)\n  *\/\n  \/\/ ina219.setPGain(INA219_PG_320); \/\/ choose gain and uncomment for change of default\n  \n  \/* Set Bus Voltage Range\n    INA219_BRNG_16   -&gt; 16 V\n    INA219_BRNG_32   -&gt; 32 V (DEFAULT)\n  *\/\n  \/\/ ina219.setBusRange(INA219_BRNG_32); \/\/ choose range and uncomment for change of default\n\n  \/* If the current values delivered by the INA219 differ by a constant factor\n    from values obtained with calibrated equipment you can define a correction factor.\n    Correction factor = current delivered from calibrated equipment \/ current delivered by INA219\n  *\/\n  \/\/ ina219.setCorrectionFactor(0.98); \/\/ insert your correction factor if necessary\n\n  \/* If you experience a shunt voltage offset, that means you detect a shunt voltage which is not \n    zero, although the current should be zero, you can apply a correction. For this, uncomment the \n    following function and apply the offset you have detected.   \n  *\/\n  \/\/ ina219.setShuntVoltOffset_mV(0.0); \/\/ insert the shunt voltage (millivolts) you detect at zero current\n\n  \/* If you use a shunt different from 0.1 ohms (R100), you can change the shunt size using the\n    function below.\n  *\/\n  \/\/ina219.setShuntSizeInOhms(0.01); \n  \n  Serial.println(\"INA219 Current Sensor Example Sketch - Triggered Mode\");\n}\n\nvoid loop() {\n  float shuntVoltage_mV = 0.0;\n  float loadVoltage_V = 0.0;\n  float busVoltage_V = 0.0;\n  float current_mA = 0.0;\n  float power_mW = 0.0; \n  bool ina219_overflow = false;\n  \n  ina219.startSingleMeasurement(); \/\/ triggers single-shot measurement and waits until completed\n  shuntVoltage_mV = ina219.getShuntVoltage_mV();\n  busVoltage_V = ina219.getBusVoltage_V();\n  current_mA = ina219.getCurrent_mA();\n  power_mW = ina219.getBusPower();\n  loadVoltage_V  = busVoltage_V + (shuntVoltage_mV\/1000);\n  ina219_overflow = ina219.getOverflow();\n  \n  Serial.print(\"Shunt Voltage [mV]: \"); Serial.println(shuntVoltage_mV);\n  Serial.print(\"Bus Voltage [V]: \"); Serial.println(busVoltage_V);\n  Serial.print(\"Load Voltage [V]: \"); Serial.println(loadVoltage_V);\n  Serial.print(\"Current[mA]: \"); Serial.println(current_mA);\n  Serial.print(\"Bus Power [mW]: \"); Serial.println(power_mW);\n  if(!ina219_overflow){\n    Serial.println(\"Values OK - no overflow\");\n  }\n  else{\n    Serial.println(\"Overflow! Choose higher shunt voltage range or a smaller shunt.\");\n  }\n  Serial.println();\n  \n  delay(3000);\n} <\/pre>\n<p>\u00a0<\/p>\n<\/div>\n<p>\n\n<p>In triggered mode, all output values belong to one measurement cycle:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Triggered.png\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"349\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Triggered.png\" alt=\"Output of the triggered sketch for the INA219\" class=\"wp-image-6629\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Triggered.png 716w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Ausgabe_Triggered-300x146.png 300w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/a><figcaption class=\"wp-element-caption\">Output of the triggered sketch for the INA219<\/figcaption><\/figure>\n\n<h3 class=\"wp-block-heading\">Triggered -non-blocking<\/h3>\n\n<p>The Triggered.ino sketch waits after startSingleMeasurement() until a measurement value is available and thus blocks the sketch. This may not be desired. I have implemented <code>startSingleMeasurementNoWait()<\/code> for this purpose. You can use <code>getConversionReady()<\/code> to check whether a measured value is available. The following sketch illustrates how this works:    <\/p>\n<\/p>\n<div class=\"scroll-paragraph\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"Triggered_non_blocking.ino\" data-enlighter-title=\"Triggered_non_blocking.ino\">#include &lt;Wire.h&gt;\n#include &lt;INA219_WE.h&gt;\n#define I2C_ADDRESS 0x40\n\n\/* There are several ways to create your INA219 object:\n * INA219_WE ina219 = INA219_WE(); -&gt; uses Wire \/ I2C Address = 0x40\n * INA219_WE ina219 = INA219_WE(I2C_ADDRESS); -&gt; uses Wire \/ I2C_ADDRESS\n * INA219_WE ina219 = INA219_WE(&amp;Wire); -&gt; you can pass any TwoWire object\n * INA219_WE ina219 = INA219_WE(&amp;Wire, I2C_ADDRESS); -&gt; all together\n *\/\nINA219_WE ina219 = INA219_WE(I2C_ADDRESS);\n\nvoid setup() {\n  Serial.begin(115200);\n  Wire.begin();\n  if(!ina219.init()){\n    Serial.println(\"INA219 not connected!\");\n    while(1);\n}\n\n  \/* Set ADC Mode for Bus and ShuntVoltage\n    * Mode *                 * Res \/ Samples *        * Conversion Time *\n    INA219_BIT_MODE_9        9 Bit Resolution             84 \u00b5s\n    INA219_BIT_MODE_10       10 Bit Resolution            148 \u00b5s  \n    INA219_BIT_MODE_11       11 Bit Resolution            276 \u00b5s\n    INA219_BIT_MODE_12       12 Bit Resolution            532 \u00b5s  (DEFAULT)\n    INA219_SAMPLE_MODE_2     Mean Value 2 samples         1.06 ms\n    INA219_SAMPLE_MODE_4     Mean Value 4 samples         2.13 ms\n    INA219_SAMPLE_MODE_8     Mean Value 8 samples         4.26 ms\n    INA219_SAMPLE_MODE_16    Mean Value 16 samples        8.51 ms     \n    INA219_SAMPLE_MODE_32    Mean Value 32 samples        17.02 ms\n    INA219_SAMPLE_MODE_64    Mean Value 64 samples        34.05 ms\n    INA219_SAMPLE_MODE_128   Mean Value 128 samples       68.10 ms\n    \n    If you measure both current and bus voltage (which is the default), the conversion time doubles.\n  *\/\n  ina219.setADCMode(INA219_SAMPLE_MODE_128); \n  \n  \/* Set measure mode\n    INA219_POWER_DOWN              - INA219 switched off\n    INA219_TRIGGERED               - measurement on demand, current and bus\n    INA219_TRIGGERED_CURRENT_ONLY  - on demand, current only\n    INA219_TRIGGERED_BUS_ONLY      - on demand, bus voltage only\n    INA219_ADC_OFF                 - analog\/digital converter switched off\n    INA219_CONTINUOUS              - continuous measurements (DEFAULT)\n    INA219_CONTINUOUS_CURRENT_ONLY - continuous, current only\n    INA219_CONTINUOUS_BUS_ONLY     - continuous, bus voltage only\n  *\/\n  ina219.setMeasureMode(INA219_TRIGGERED); \/\/ Triggered measurements for this example\n  \n  \/* Set PGain\n     * Gain *      * Shunt Voltage Range *   * Max Current (if shunt is 0.1 ohms) *\n    INA219_PG_40          40 mV                   0.4 A\n    INA219_PG_80          80 mV                   0.8 A\n    INA219_PG_160         160 mV                  1.6 A\n    INA219_PG_320         320 mV                  3.2 A (DEFAULT)\n  *\/\n  \/\/ ina219.setPGain(INA219_PG_320); \/\/ choose gain and uncomment for change of default\n  \n  \/* Set Bus Voltage Range\n    INA219_BRNG_16   -&gt; 16 V\n    INA219_BRNG_32   -&gt; 32 V (DEFAULT)\n  *\/\n  \/\/ ina219.setBusRange(INA219_BRNG_32); \/\/ choose range and uncomment for change of default\n\n  \/* If the current values delivered by the INA219 differ by a constant factor\n    from values obtained with calibrated equipment you can define a correction factor.\n    Correction factor = current delivered from calibrated equipment \/ current delivered by INA219\n  *\/\n  \/\/ ina219.setCorrectionFactor(0.98); \/\/ insert your correction factor if necessary\n\n  \/* If you experience a shunt voltage offset, that means you detect a shunt voltage which is not \n    zero, although the current should be zero, you can apply a correction. For this, uncomment the \n    following function and apply the offset you have detected.   \n  *\/\n  \/\/ ina219.setShuntVoltOffset_mV(0.0); \/\/ insert the shunt voltage (millivolts) you detect at zero current\n\n  \/* If you use a shunt different from 0.1 ohms (R100), you can change the shunt size using the\n    function below.\n  *\/\n  \/\/ina219.setShuntSizeInOhms(0.01); \n  \n  Serial.println(\"INA219 Current Sensor Example Sketch - Triggered Mode, non-blocking\");\n  ina219.startSingleMeasurementNoWait(); \/\/ triggers single-shot measurement without waiting\n}\n\nvoid loop() {\n  static unsigned int counter = 0;\n  if(ina219.getConversionReady()){\n    counter++;\n    if(counter == 9) {  \/\/ display only every 10th conversion, just to slow down the output\n      displayResults(); \/\/ with the current settings, the output period is ~1.28 s\n      counter = 0;\n    }\n    ina219.startSingleMeasurementNoWait();\n  }  \n} \n\nvoid displayResults() {\n  float shuntVoltage_mV = 0.0;\n  float loadVoltage_V = 0.0;\n  float busVoltage_V = 0.0;\n  float current_mA = 0.0;\n  float power_mW = 0.0; \n  bool ina219_overflow = false;\n  \n  shuntVoltage_mV = ina219.getShuntVoltage_mV();\n  busVoltage_V = ina219.getBusVoltage_V();\n  current_mA = ina219.getCurrent_mA();\n  power_mW = ina219.getBusPower();\n  loadVoltage_V  = busVoltage_V + (shuntVoltage_mV\/1000);\n  ina219_overflow = ina219.getOverflow();\n  \n  Serial.print(\"Shunt Voltage [mV]: \"); Serial.println(shuntVoltage_mV);\n  Serial.print(\"Bus Voltage [V]: \"); Serial.println(busVoltage_V);\n  Serial.print(\"Load Voltage [V]: \"); Serial.println(loadVoltage_V);\n  Serial.print(\"Current[mA]: \"); Serial.println(current_mA);\n  Serial.print(\"Bus Power [mW]: \"); Serial.println(power_mW);\n  if(!ina219_overflow){\n    Serial.println(\"Values OK - no overflow\");\n  }\n  else{\n    Serial.println(\"Overflow! Choose higher shunt voltage range or a smaller shunt.\");\n  }\n  Serial.println();\n}<\/pre>\n<p>\u00a0<\/p>\n<\/div>\n<p>\n\n<h2 class=\"wp-block-heading\">Power-Down Mode<\/h2>\n\n<p>With the Power-Down mode, you can reduce the current consumption of the INA219 from approx. 0.7 mA to less than 10&nbsp;\u00b5A (own measurements). 0.7 mA is already a fairly small value, but that&#8217;s still more than 6000&nbsp;mAh per year.  This is relevant for battery-powered projects.<\/p>\n<p>The following example sketch shows the power-down mode in action. The sketch initializes the INA219 with the default parameters. Five sets of measurements are output every three seconds. The function <code>powerDown()<\/code> then backs up the content of the configuration register and switches off the INA219. The function <code>powerUp()<\/code> writes back the copy of the configuration register. On the one hand, this write operation wakes up the INA219, and on the other hand, it ensures that the INA219 returns to the previously selected mode (here: continuous).<\/p>\n<\/p>\n<div class=\"scroll-paragraph-long\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-group=\"PowerDown.ino\" data-enlighter-title=\"PowerDown.ino\">#include &lt;Wire.h&gt;\n#include &lt;INA219_WE.h&gt;\n#define I2C_ADDRESS 0x40\n\n\/* There are several ways to create your INA219 object:\n * INA219_WE ina219 = INA219_WE(); -&gt; uses Wire \/ I2C Address = 0x40\n * INA219_WE ina219 = INA219_WE(I2C_ADDRESS); -&gt; uses Wire \/ I2C_ADDRESS\n * INA219_WE ina219 = INA219_WE(&amp;Wire); -&gt; you can pass any TwoWire object\n * INA219_WE ina219 = INA219_WE(&amp;Wire, I2C_ADDRESS); -&gt; all together\n *\/\nINA219_WE ina219 = INA219_WE(I2C_ADDRESS);\n\nvoid setup() {\n  Serial.begin(115200);\n  Wire.begin();\n  \/\/ default parameters are set - for change check the other examples\n  if(!ina219.init()){\n    Serial.println(\"INA219 not connected!\");\n    while(1);\n  }\n  Serial.println(\"INA219 Current Sensor Example Sketch - PowerDown\");\n  Serial.println(\"Continuous Sampling starts\");\n  Serial.println();\n}\n\nvoid loop() {\n  for(int i=0; i&lt;5; i++){\n    continuousSampling();\n    delay(3000);\n  }\n  \n  Serial.println(\"Power down for 10s\");\n  ina219.powerDown();\n  for(int i=0; i&lt;10; i++){\n    Serial.print(\".\");\n    delay(1000);\n  }\n  \n  Serial.println(\"Power up!\");\n  Serial.println(\"\");\n  ina219.powerUp(); \/\/ requires 40 \u00b5s\n}\n\nvoid continuousSampling(){\n  float shuntVoltage_mV = 0.0;\n  float loadVoltage_V = 0.0;\n  float busVoltage_V = 0.0;\n  float current_mA = 0.0;\n  float power_mW = 0.0; \n  bool ina219_overflow = false;\n  \n  shuntVoltage_mV = ina219.getShuntVoltage_mV();\n  busVoltage_V = ina219.getBusVoltage_V();\n  current_mA = ina219.getCurrent_mA();\n  power_mW = ina219.getBusPower();\n  loadVoltage_V  = busVoltage_V + (shuntVoltage_mV\/1000);\n  ina219_overflow = ina219.getOverflow();\n  \n  Serial.print(\"Shunt Voltage [mV]: \"); Serial.println(shuntVoltage_mV);\n  Serial.print(\"Bus Voltage [V]: \"); Serial.println(busVoltage_V);\n  Serial.print(\"Load Voltage [V]: \"); Serial.println(loadVoltage_V);\n  Serial.print(\"Current[mA]: \"); Serial.println(current_mA);\n  Serial.print(\"Bus Power [mW]: \"); Serial.println(power_mW);\n  if(!ina219_overflow){\n    Serial.println(\"Values OK - no overflow\");\n  }\n  else{\n    Serial.println(\"Overflow! Choose higher shunt voltage range or a smaller shunt.\");\n  }\n  Serial.println();\n}<\/pre>\n<p>\u00a0<\/p>\n<\/div>\n<p>\n\n<h2 class=\"wp-block-heading\">Changing the shunt<\/h2>\n<div class=\"wp-block-image\">\n<figure class=\"alignright size-large is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/07\/INA219_new_shunt.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"916\" height=\"938\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/07\/INA219_new_shunt.jpg\" alt=\"\" class=\"wp-image-12021\" style=\"width:229px;height:235px\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/07\/INA219_new_shunt.jpg 916w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/07\/INA219_new_shunt-293x300.jpg 293w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/07\/INA219_new_shunt-768x786.jpg 768w\" sizes=\"auto, (max-width: 916px) 100vw, 916px\" \/><\/a><\/figure>\n<\/div>\n<p>Despite an intensive search, I have only found modules with a 0.1 ohm shunt. This limits you to a current of 3.2 amperes. If you want to measure larger currents, you have three options:  <\/p>\n<ol>\n<li>Do not use a module, but the bare INA219 chip.<\/li>\n<li>You desolder the R100 shunt and replace it. However, this is not trivial with just one soldering iron. &nbsp;<\/li>\n<li>Pragmatic solution: simply solder a second shunt onto the first shunt (sandwich-like).<\/li>\n<\/ol>\n<p>I have tried way 3 (see right). Two parallel shunts of 0.1 and 0.05 ohm result in a total shunt of 0.0333 ohm. It worked wonderfully.  &nbsp;<\/p>\n<p>Use <code>setShuntSizeInOhms()<\/code> to define the shunt. <code>setPGain()<\/code> also works with the changed shunt. When using PG_<em>Value<\/em> and a shunt with resistance R, the maximum current is I:  &nbsp;<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-9fd76a6876fbe280164327470311daf8_l3.png\" height=\"39\" width=\"159\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#73;&#95;&#123;&#92;&#116;&#101;&#120;&#116;&#123;&#109;&#97;&#120;&#125;&#125;&#92;&#59;&#92;&#116;&#101;&#120;&#116;&#123;&#091;&#65;&#093;&#125;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#86;&#97;&#108;&#117;&#101;&#125;&#123;&#82;&#92;&#99;&#100;&#111;&#116;&#32;&#49;&#48;&#48;&#48;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<h3 class=\"wp-block-heading\">Overview of all functions of the library<\/h3>\n\n<p>And here is an overview of all the functions. It is part of my documentation on GitHub.&nbsp;<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE-781x1024.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"1024\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE-781x1024.webp\" alt=\"\" class=\"wp-image-24926\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE-781x1024.webp 781w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE-229x300.webp 229w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE-768x1007.webp 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/List_of_public_functions_INA219_WE.webp 852w\" sizes=\"auto, (max-width: 781px) 100vw, 781px\" \/><\/a><figcaption class=\"wp-element-caption\"> List of functions of the INA219_WE library <\/figcaption><\/figure>\n\n<h2 class=\"wp-block-heading\">Details of the library and the registers<\/h2>\n\n<p>This part is only for those who want to go into the details of the INA219_WE library or to better understand the internal processes in INA219.&nbsp;<\/p>\n\n<h3 class=\"wp-block-heading\">The registers of INA219<\/h3>\n\n<p>The INA219 has six 16-bit registers. You can only write to the configuration and calibration registers. The other registers provide the measured or calculated data and are read-only accordingly.<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register-1024x318.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"318\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register-1024x318.png\" alt=\"Register of the INA219\" class=\"wp-image-6639\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register-1024x318.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register-300x93.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register-768x238.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Register.png 1122w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Register of the INA219<\/figcaption><\/figure>\n\n<p>The basic settings are made in the configuration register:<\/p>\n\n<h4 class=\"wp-block-heading\">The configuration register<\/h4>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-1024x78.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"78\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-1024x78.png\" alt=\"Configuration register of the INA219\" class=\"wp-image-6680\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-1024x78.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-300x23.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-768x58.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG-1320x100.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/CONFIG_REG.png 1519w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Configuration register of the INA219<\/figcaption><\/figure>\n\n<ul>\n<li><strong>RST<\/strong>: Setting the RST bit triggers a reset. The register contents are reset to default.<\/li>\n<li><strong>BRNG<\/strong>: Bus Range determines the range of the bus voltage, i.e. 16 or 32 volts.<\/li>\n<li><strong>PG<em>X<\/em><\/strong>: The two bits determine PGAIN<\/li>\n<li><strong>BADC<em>X <\/em>\/ SADC<em>X<\/em><\/strong>: These bits determine the resolution or the number of measurements per measurement cycle for the bus and shunt voltage (see table). In my library, no different values can be written in BADC and SADC. I had decided not to make the operation too complex.<\/li>\n<li><strong>MODE<em>X<\/em><\/strong>: The three mode bits set the operating mode (see table). Again, I haven&#8217;t implemented everything that&#8217;s possible. Only the modes highlighted in green are available.&nbsp;<\/li>\n<\/ul>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/ADC_Settings_engl-1024x506.png\"><img decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/ADC_Settings_engl-1024x506.png\" alt=\"ADC Settings - apply to shunt and bus voltage conversion\" class=\"wp-image-6970\"\/><\/a><figcaption class=\"wp-element-caption\">ADC Settings &#8211; apply to shunt and bus voltage conversion<\/figcaption><\/figure>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1-1024x367.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"367\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1-1024x367.png\" alt=\"\" class=\"wp-image-24928\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1-1024x367.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1-300x107.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1-768x275.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Mode_Setting_INA219_eng-1.png 1086w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Modes of the INA219<\/figcaption><\/figure>\n\n<h4 class=\"wp-block-heading\">The other registers<\/h4>\n\n<p>The shunt and the current register are not particularly exciting. It should be noted, however, that both have sign bits, i.e. they can take values between +32767 and -32767. The Bus Voltage and the Power Register are not signed.<\/p>\n<p>Regarding the Bus Voltage Register, only 13 bits are available for the bus voltage (BD0 &#8211; BD12). Bit No. 2 is unused, bit No. 1 is CNVR (Conversion Ready). It is set when (fresh) data are available in the registers, i.e. all measurements and calculations for a cycle are complete. Reading the Power Register deletes the bit. Bit 0 is OVF (overflow) and indicates whether one of the data registers has overflowed. To calculate the bus voltage, the content of the bus voltage register must be shifted 3 bits to the right.<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-1024x81.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"81\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-1024x81.png\" alt=\"Bus voltage register of the INA219\" class=\"wp-image-6641\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-1024x81.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-300x24.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-768x61.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-1536x121.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG-1320x104.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/BUS_VOLTAGE_REG.png 1570w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">  <\/figcaption><\/figure>\n\n<p>The Calibration Register contains the 15 bit calibration factor &#8220;Cal&#8221;. The register is 16 bits, but bit 0 is reserved. We&#8217;ll get to what the calibration factor is all about. But, to avoid misunderstandings, I should point out that the calibration factor has nothing to do with the correction factor ( <code>setCorrectionFactor()<\/code> ).<\/p>\n\n<h3 class=\"wp-block-heading\">INA219 &#8211; internal calculations<\/h3>\n\n<p>I found the explanations of the calculations in the data sheet very confusing. I had to read it several times before I understood it. But actually it&#8217;s not that bad.<\/p>\n<p>To determine the calibration factor, first consider the maximum expected current (maxExpectedCurrent). This must fit in the Current Register. Since the Current Register has a value range of +\/- 2<sup>15<\/sup>, the Current_LSB (ampere per bit) therefore is:<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-f7dd5e8967cf5d12f16e22ee0da697dc_l3.png\" height=\"39\" width=\"329\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#67;&#117;&#114;&#114;&#101;&#110;&#116;&#92;&#95;&#76;&#83;&#66;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#109;&#97;&#120;&#69;&#120;&#112;&#101;&#99;&#116;&#101;&#100;&#67;&#117;&#114;&#114;&#101;&#110;&#116;&#125;&#123;&#50;&#94;&#123;&#49;&#53;&#125;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>The equation usually results in a &#8220;crooked&#8221; value. You round it up so that in the next step you get a straight value for the calibration factor Cal. You calculate Cal according to the following formula:<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 45px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-d096a8f564b1cf28662e31da199e7c16_l3.png\" height=\"45\" width=\"319\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#67;&#97;&#108;&#32;&#61;&#32;&#116;&#114;&#117;&#110;&#99;&#92;&#108;&#101;&#102;&#116;&#40;&#92;&#102;&#114;&#97;&#99;&#123;&#48;&#44;&#92;&#33;&#48;&#52;&#48;&#57;&#54;&#125;&#123;&#67;&#117;&#114;&#114;&#101;&#110;&#116;&#92;&#95;&#76;&#83;&#66;&#92;&#99;&#100;&#111;&#116;&#32;&#82;&#95;&#123;&#83;&#104;&#117;&#110;&#116;&#125;&#125;&#92;&#114;&#105;&#103;&#104;&#116;&#41; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>0.04096 is an internally defined value, which ensures a reasonable scaling, i.e. that the values make good use of the register width.<\/p>\n\n<p>The Shunt Voltage Register contains the shunt voltage in 10 \u00b5V \/ bit. Since it is a signed register, the maximum is 2<sup>15<\/sup>-1. This results in a maximum shunt voltage of 0.32767 volts. More does not fit in the register. As the shunt resistance is 0.1 ohm, this theoretically results in a maximum current of approx. 3.2 amperes.<\/p>\n\n<p>The Current Register is calculated according to the following formula (but we don&#8217;t have to worry about that):<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-c5aac7bd6f8f449b014308b441a9ea6c_l3.png\" height=\"39\" width=\"395\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#99;&#117;&#114;&#114;&#101;&#110;&#116;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#115;&#104;&#117;&#110;&#116;&#86;&#111;&#108;&#116;&#97;&#103;&#101;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#67;&#97;&#108;&#125;&#123;&#52;&#48;&#57;&#54;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>Power_LSB, i.e. the power per bit (watt\/bit), is 20 times the Current_LSB. This is a fixed internal setting.<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 13px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-00ff86118bef1b864e8222fec3435579_l3.png\" height=\"13\" width=\"277\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#80;&#111;&#119;&#101;&#114;&#92;&#95;&#76;&#83;&#66;&#32;&#61;&#32;&#50;&#48;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#67;&#117;&#114;&#114;&#101;&#110;&#116;&#92;&#95;&#76;&#83;&#66; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>The content of the Power Register can be calculated from the content of the Current Register and the Bus Voltage Register. But we don&#8217;t have to worry about that either because the INA219 calculates that internally.<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-75f09e58c052b112065406f7c6d9b6a6_l3.png\" height=\"39\" width=\"467\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#112;&#111;&#119;&#101;&#114;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#99;&#117;&#114;&#114;&#101;&#110;&#116;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#98;&#117;&#115;&#86;&#111;&#108;&#116;&#97;&#103;&#101;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#125;&#123;&#53;&#48;&#48;&#48;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>The Bus Voltage Register has a fixed LSB of 4 mV\/bit.<\/p>\n\n<h3 class=\"wp-block-heading\">Calculations by the library<\/h3>\n\n<p>Basically, you could just read the Shunt and Bus Voltage Register and calculate the rest. But we let the INA219 work for us.<\/p>\n\n<p>Nevertheless, the values read from the registers still need to be converted:<\/p>\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2-1024x195.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"195\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2-1024x195.png\" alt=\"Conversion of register contents\" class=\"wp-image-6760\" style=\"width:512px;height:98px\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2-1024x195.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2-300x57.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2-768x146.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Berechnung_2.png 1099w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Conversion of register contents<\/figcaption><\/figure>\n\n<p>To get more convenient values, I introduced a Current Divider and a Power Multiplier:<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-6bd89d8474456d8a93e94f0b7004ed29_l3.png\" height=\"39\" width=\"274\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#99;&#117;&#114;&#114;&#101;&#110;&#116;&#92;&#32;&#92;&#116;&#101;&#120;&#116;&#123;&#091;&#109;&#65;&#093;&#125;&#61;&#92;&#102;&#114;&#97;&#99;&#123;&#99;&#117;&#114;&#114;&#101;&#110;&#116;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#125;&#123;&#99;&#117;&#114;&#114;&#101;&#110;&#116;&#68;&#105;&#118;&#105;&#100;&#101;&#114;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 39px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-a2c96ed7725803a2d2b485001469d6d2_l3.png\" height=\"39\" width=\"431\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#92;&#116;&#101;&#120;&#116;&#123;&#109;&#105;&#116;&#32;&#47;&#32;&#119;&#105;&#116;&#104;&#125;&#92;&#32;&#92;&#32;&#92;&#32;&#99;&#117;&#114;&#114;&#101;&#110;&#116;&#68;&#105;&#118;&#105;&#100;&#101;&#114;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#49;&#125;&#123;&#67;&#117;&#114;&#114;&#101;&#110;&#116;&#92;&#95;&#76;&#83;&#66;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#49;&#48;&#48;&#48;&#125; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<p>and<\/p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-ae4166ab8c6aebfdcd78489f3b70e779_l3.png\" height=\"19\" width=\"402\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#112;&#111;&#119;&#101;&#114;&#92;&#32;&#92;&#116;&#101;&#120;&#116;&#123;&#091;&#109;&#87;&#093;&#125;&#32;&#61;&#32;&#112;&#111;&#119;&#101;&#114;&#82;&#101;&#103;&#105;&#115;&#116;&#101;&#114;&#92;&#99;&#100;&#111;&#116;&#32;&#112;&#111;&#119;&#101;&#114;&#77;&#92;&#33;&#117;&#108;&#116;&#105;&#112;&#108;&#105;&#101;&#114; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n<\/p>\n<p class=\"ql-center-displayed-equation\" style=\"line-height: 19px;\"><span class=\"ql-right-eqno\"> &nbsp; <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/ql-cache\/quicklatex.com-bb77a40f99953cca8571168c3915b75b_l3.png\" height=\"19\" width=\"420\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#091; &#92;&#116;&#101;&#120;&#116;&#123;&#109;&#105;&#116;&#32;&#47;&#32;&#119;&#105;&#116;&#104;&#125;&#92;&#32;&#92;&#32;&#92;&#32;&#112;&#111;&#119;&#101;&#114;&#77;&#92;&#33;&#117;&#108;&#116;&#105;&#112;&#108;&#105;&#101;&#114;&#32;&#61;&#32;&#80;&#111;&#119;&#101;&#114;&#92;&#95;&#76;&#83;&#66;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#49;&#48;&#48;&#48; &#92;&#093;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>\n\n<h3 class=\"wp-block-heading\">Measuring ranges implemented in the library<\/h3>\n\n<p>The maximum resolution for the current results from the LSB of the shunt voltage register (10 \u00b5V) and the shunt size (0.1 \u03a9). I<sub>min<\/sub> = U<sub>min<\/sub>\/R = 100 \u00b5A&nbsp; = 0.1 mA. In the following table, I have calculated the measurement ranges implemented in the library and the resulting LSBs for current and power.   <\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/Res_vs_PGAIN-1024x336.png\"><img decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/01\/Res_vs_PGAIN-1024x336.png\" alt=\"Measuring ranges, resolution and conversion factors for the INA219\" class=\"wp-image-6670\"\/><\/a><figcaption class=\"wp-element-caption\">Measuring ranges, resolution and conversion factors<\/figcaption><\/figure>\n\n<p>The calculated Current LSBs are smaller than the actual possible resolution, except for PG_320. So don&#8217;t be misled by the values. You would only achieve advantages in resolution with larger shunts.   <\/p>\n\n<h2 class=\"wp-block-heading\">Acknowledgement<\/h2>\n\n<p>I took the INA219 Fritzing component from the <a href=\"https:\/\/github.com\/adafruit\/Fritzing-Library\/tree\/master\/parts\" target=\"_blank\" rel=\"noopener noreferrer\">Adafruit Fritzing Part<\/a> collection on GitHub.<\/p>\n<p>The post image is from the <a href=\"https:\/\/pixabay.com\/photos\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=691809\" target=\"_blank\" rel=\"noopener noreferrer\">Free-Photos<\/a> on Pixabay and was slightly modified by me.<\/p>\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library INA219_WE. <\/p>\n","protected":false},"author":1,"featured_media":8591,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[574,572],"tags":[556,1225,1222,1221,1223,558,1093,1224],"class_list":["post-10483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-current-voltage","category-sensors","tag-arduino-en-2","tag-continuous","tag-current-sensor","tag-ina219-en","tag-leistungssensor-en","tag-library-en-2","tag-power-down-en-2","tag-triggered-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-02T20:26:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-28T19:11:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1300\" \/>\n\t<meta property=\"og:image:height\" content=\"1300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"24 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"INA219 Current and Power Sensor\",\"datePublished\":\"2021-01-02T20:26:27+00:00\",\"dateModified\":\"2025-09-28T19:11:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor\"},\"wordCount\":2580,\"commentCount\":72,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Beitragsbild.jpg\",\"keywords\":[\"Arduino\",\"continuous\",\"current sensor\",\"INA219\",\"Leistungssensor\",\"Library\",\"power-down\",\"triggered\"],\"articleSection\":[\"Current, voltage\",\"Sensors\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor\",\"name\":\"INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Beitragsbild.jpg\",\"datePublished\":\"2021-01-02T20:26:27+00:00\",\"dateModified\":\"2025-09-28T19:11:28+00:00\",\"description\":\"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Beitragsbild.jpg\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/Beitragsbild.jpg\",\"width\":1300,\"height\":1300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/ina219-current-and-power-sensor#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"INA219 Current and Power Sensor\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste","description":"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor","og_locale":"en_US","og_type":"article","og_title":"INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste","og_description":"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor","og_site_name":"Wolles Elektronikkiste","article_published_time":"2021-01-02T20:26:27+00:00","article_modified_time":"2025-09-28T19:11:28+00:00","og_image":[{"width":1300,"height":1300,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg","type":"image\/jpeg"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"24 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"INA219 Current and Power Sensor","datePublished":"2021-01-02T20:26:27+00:00","dateModified":"2025-09-28T19:11:28+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor"},"wordCount":2580,"commentCount":72,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg","keywords":["Arduino","continuous","current sensor","INA219","Leistungssensor","Library","power-down","triggered"],"articleSection":["Current, voltage","Sensors"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor","url":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor","name":"INA219 Current and Power Sensor &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg","datePublished":"2021-01-02T20:26:27+00:00","dateModified":"2025-09-28T19:11:28+00:00","description":"With the INA219 module, you can measure currents and power conveniently and reliably. I explain how this works and introduce my library.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2020\/06\/Beitragsbild.jpg","width":1300,"height":1300},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/ina219-current-and-power-sensor#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"INA219 Current and Power Sensor"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=10483"}],"version-history":[{"count":4,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10483\/revisions"}],"predecessor-version":[{"id":24942,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/10483\/revisions\/24942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/8591"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=10483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=10483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=10483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}