Introduction: The Definitive Guide to Precision Power: Mastering the INA219 & INA226

In the world of DIY electronics, knowing exactly how much power your project consumes is the difference between a battery that lasts months and one that dies in hours. I’ve built countless robots, solar chargers, and IoT devices, and I always ran into the same problem: How do I measure current accurately without spending a fortune on lab equipment?

While you can use a multimeter for spot checks, you can't embed one into a robot. That's why I fell in love with the INA219 and INA226 current sensing chips. They are precise, they talk over I2C, and they do the heavy math for you.

In this guide, I will take you on a deep dive into the hardware architecture of these chips, explain the math behind the measurements, and finally, show you why I designed my own custom PCB to fix the flaws found in generic modules.

Step 1: Deep Dive – the Hardware Architecture

The Contenders (INA219 vs. INA226)

Both chips operate on the same principle: they measure the voltage drop across a small resistor (shunt) to calculate current (I = V/R) and measure the bus voltage to calculate power (P = V * I). However, they are built for different levels of precision.


INA219 (The Generalist)

The INA219 is the "workhorse" sensor. It is great for general-purpose monitoring where extreme precision isn't critical.

  1. Resolution: 12-bit ADC. 2^12 = 4096 steps.
  2. Bus Voltage: 0V to 26V.
  3. Shunt Voltage Range: ±320mV.
  4. Use Case: Perfect for general 5V or 12V hobby projects, motor monitoring, and general power tracking.


INA226 (The Precision King)

The INA226 is the "pro" version. It has 16 times better resolution and can handle higher voltages.

  1. Resolution: 16-bit ADC, 2^16 = 65,536 steps. (This is a massive jump; it is 16x more precise than the 219).
  2. Bus Voltage: 0V to 36V.
  3. Shunt Voltage Range: ±81.92mV (Note: It is more sensitive, so it handles less voltage drop across the shunt).
  4. Averaging Engine: The INA226 has a built-in "DSP" (Digital Signal Processor) that can average up to 1024 samples automatically before sending you the result. This smooths out noisy signals from PWM dimmers or motors.
  5. Alert Pin: Programmable! You can tell the chip, "If current goes over 2A, send a signal to this pin."
  6. Use Case: Battery capacity grading, ultra-low power sleep tracking, and 24V industrial systems.

Step 2: The Critical Physics of Shunt Resistors

This is the most critical concept to master. These chips do not actually measure current directly; they measure the voltage drop across a tiny resistor known as a Shunt.

Most breakout boards come with a generic R100 (0.1Ω) resistor. This is a "jack of all trades, master of none" value.

The Trade-Off

  1. High Resistance (1.0Ω): Great for small currents (uA/mA) because it creates a larger, easier-to-read voltage drop. Bad for high current (too much voltage loss).
  2. Low Resistance (0.001Ω): Great for massive currents (50A+) because it creates very little heat and voltage loss. Bad for small currents (the signal is too weak to read).


The "R100" Problem

Most generic modules come with a resistor labeled R100. This means $0.1\Omega$.

  1. For Low Current (100mA): V = 0.1A * 0.1Ω = 0.01V (10mV). The signal is strong; the sensor reads it easily.
  2. For High Current (10A): V = 10A * 0.1Ω = 1V drop.
  3. FAIL 1: The INA226 can only read up to ±0.081V. The chip will flatline (saturate).
  4. FAIL 2: Power dissipated is 10 Watts (P = I² × R = 10² × 0.1 = 10 W ). The resistor will physically burn up and desolder itself.

Step 3: Wiring (High-Side Vs. Low-Side)

The Golden Rule: Use High-Side Sensing

The INA modules are designed primarily for High-Side Sensing. This means you place the sensor on the positive wire (between the Battery Positive and the Load Positive).

Why not Low-Side? If you place the sensor on the Ground wire (Low-Side), the ground of your load will be slightly higher than the actual system ground (due to the resistor). This can cause communication errors or "ground loops" if you connect USB cables or other sensors.

Note on "Common Ground": Even though the sensor is on the "High Side," the GND pin of the INA module must still connect to the ground of the battery being measured and the Arduino.

Step 4: Limitations (Read Before You Build)

  1. Thermal Drift (The Heat Problem): Resistors change their value when they get hot. If you push 2A through the tiny onboard resistor, it will heat up, its resistance will change, and your readings will drift.
  2. Solution: Keep your continuous current under 2A for the stock modules, or use an external shunt that is rated for high wattage.


  1. Common Mode Voltage: The INA219 will die if the Bus Voltage exceeds 26V. The INA226 will die over 36V. This is an absolute hardware limit.
  2. Warning: Inductive loads (like big motors) can create "flyback" voltage spikes that exceed these limits for a split second, killing the chip. Always use a Flyback Diode across motors when monitoring them!


  1. Aliasing: Since these are digital sensors, they take "snapshots" of current. If your current is pulsing very fast (like PWM for an LED dimmer), the sensor might take a snapshot when the LED is off and report 0mA, or when it is on and report max current.
  2. Solution: Both chips have "Averaging" settings in their registers. Turn this up to average out PWM signals.


Step 5: Going Pro : the Custom "EasyElectronics" PCB

If standard breakout boards limit your project (due to overheating or fixed addresses), building a custom PCB is the next logical step. Below, we analyze the EasyElectronics INA226 Module. This design is a perfect example of how to bridge the gap between a "theoretical" schematic and a "production-grade" hardware solution.

Let's break down exactly why this design is superior to generic modules, using it as a learning case for your own designs.

1. User Experience (UX) & Silkscreen

A board is only as good as its usability. This design features production-quality labeling that prevents wiring errors before they happen.

  1. Perfect Labeling: The front labels (VIN+, VIN-, SDA, SCL, GND, 5V) are aligned, readable, and use a logical pin order that matches the schematic.
  2. Double-Sided Visibility: This is a feature rarely seen even in commercial boards. The headers are labeled on the Front for clean usage during operation, and on the Back for easy reference during soldering or troubleshooting.
  3. Readability: The white text on the blue mask provides high contrast. The spacing is deliberately managed so text won't smear during fabrication, ensuring the A0 jumper and I2C signals are always legible.


2. Mechanical Robustness

The physical design is built to survive the real world, not just a breadboard.

  1. Mounting: The mounting holes are perfectly aligned with proper annular rings and consistent spacing, making it easy to install on standoffs or inside an enclosure.
  2. Clean Outline: The board has a clean outline with proper clearance from copper to edge, preventing accidental shorts if the board touches a metal chassis.
  3. Reinforced Connector Area: The CN1 area (where the high current enters) is mechanically reinforced with vias and copper blocking, ensuring the connector doesn't peel off the board under physical stress.


3. The "Holy Grail" of Layout: Analog/Digital/Power Separation

This is the most critical technical achievement of this design. It follows Texas Instruments' recommended layout guidelines to the letter, partitioning the board into three distinct zones:

  1. Left Side (Digital & Power): Contains clean I2C and 5V trace routing with a solid Ground plane underneath.
  2. Middle (Precision Analog Sense): This is the sensitive zone. Capacitor C3 is placed very close to the VIN pins, and resistors R6/R7 are positioned perfectly to filter noise.
  3. Right (High-Current): Dedicated solely to the massive current path.

Why this matters:

  1. No Contamination: Digital switching noise from the I2C lines does not contaminate the sensitive analog sensing side.
  2. No Current Vortices: The ground reference remains stable because high current paths don't cross the logic ground.
  3. Safety: There are no accidental vias connecting the sensitive sense lines to the high-current path.


4. High-Current & Shunt Optimization

Handling high amps requires more than just a big wire; it requires thermal management and physics.

  1. Kelvin Connection: The design uses "Kelvin pads" that are isolated from the main current path. This ensures the chip measures the voltage only across the resistor, ignoring the resistance of the solder and copper traces.


  1. Dual Parallel Shunts (R1 & R2): Unlike standard boards that use a single resistor, this PCB features footprints for two large (2728 size) resistors in parallel.
  2. Benefit: Splits the current load, reducing heat by 50% per resistor. This prevents "Thermal Drift" (where resistance changes as the resistor gets hot), ensuring accuracy at high currents (10A+).


  1. High-Current Connector (CN1): A dedicated footprint for a heavy-duty terminal block or XT60 connector ensures low resistance connections, which is critical when measuring high amps.


  1. Input Filtering (R4, R5, C1): The traces from the shunt resistors do not go straight to the chip. They pass through R4/R5 and C1. This forms a Differential Filter that removes noise from motors or switching power supplies before it reaches the INA226.


  1. Thermal Mass: The exposed copper area is massive. This acts as a heatsink, allowing the board to dissipate heat efficiently, thus effective to negate any drifting issues.


  1. Copper Stitching: The uniform distribution of vias (stitching) ties the top and bottom copper layers together thus is mechanically reinforced, doubling the current-carrying capacity and reducing resistance.


  1. Robustness: The exposed copper on the high-current side is designed to be "tinned" (coated with extra solder), which further increases the current rating of the board.


  1. Bottom Layer: Note the solder jumpers (A0, A1) for address selection.

Step 6: Sponsor

Project Fabrication: Made Possible by JLCPCB

This project became a reality thanks to a collaboration with JLCPCB, one of the most popular and reliable names in electronics manufacturing. We used their services to fabricate the custom Printed Circuit Boards (PCBs) designed for this build, and we want to share our experience with them.

If you have been in the electronics hobbyist or engineering space for any amount of time, you’ve likely heard of JLCPCB. They are a worldwide leading PCB prototype enterprise, specializing in quick-turn prototypes and small-batch production.


Why We Chose JLCPCB

For this project, we needed boards that were reliable, professionally made, and delivered quickly so we could start testing. JLCPCB delivered on all fronts.

What truly sets JLCPCB apart, and why they are a go-to for makers and engineers globally, is their pricing structure. They have made professional-grade hardware accessible to everyone, famously offering standard 1–4 layer PCBs starting at just $2 for five boards.

Despite the low cost, the quality is excellent. The boards we received for this project featured sharp silkscreens, perfectly aligned solder masks, and clean drill hits.


Beyond Basic PCBs

While we used their standard FR-4 PCB service for this specific build, it is worth noting that JLCPCB has evolved into a massive one-stop-shop for prototyping. Their capabilities now include:

  1. Advanced PCBs: High-frequency boards, flexible PCBs, and rigid-flex boards.
  2. SMT Assembly: You can upload your BOM and Pick & Place files and receive your boards pre-assembled with components, saving hours of soldering.
  3. 3D Printing & CNC: They offer industrial-grade SLA, SLS, and MJF 3D printing, along with CNC machining for mechanical parts and enclosures.


We are thrilled with the results of this collaboration. The boards worked perfectly on the first try, making the assembly process smooth.

If you are looking to bring your own electronics designs to life without breaking the bank, we highly recommend checking out JLCPCB.com.


How to Order This PCB

If you want to replicate this project, ordering the PCB is straightforward. You don’t need to be a professional engineer to get professional boards made. Here is the step-by-step process we used:

Step 1: Get the Design Files Download the Gerber Files for this project from our repository (look for the .zip file labeled Gerber_ProjectName).

Step 2: Upload to JLCPCB Go to JLCPCB.com and click the "Instant Quote" button. Simply drag and drop the Gerber ZIP file into the upload box. Their system automatically analyzes the file to detect the board dimensions and layers.

Step 3: Choose Your Settings Once uploaded, you will see a preview of the board. You can leave most settings at their defaults, but here are the key options we selected:

  1. Layers: 2 Layers (Standard for most hobby projects)
  2. Dimensions: (Auto-populated from the file)
  3. PCB Color: Green (Standard and fastest shipping), though they offer Red, Blue, Black, and White for free.
  4. PCB Quantity: 5 (The minimum order, which starts at just $2).

Step 4: Review and Checkout Click "Gerber Viewer" to see a render of exactly how the board will look. If everything matches the photos in this guide, click "Save to Cart" and proceed to checkout.

Step 5: Delivery After entering your shipping address and payment details, JLCPCB will manufacture the boards. In our experience, production often finishes in as little as 24 hours, and the boards arrive at your doorstep in just a few days depending on the shipping method chosen.

Step 7: Implementation

Wiring it Up

  1. VCC: 5V or 3.3V
  2. GND: Common Ground (Critical!)
  3. SDA/SCL: To your microcontroller.
  4. VIN+: To Battery Positive.
  5. VIN-: To Load Positive.

Libraries and Software

You do not need to write raw register code. Excellent open-source libraries exist that handle the I2C communication and math.

For INA219:

  1. Library: Adafruit_INA219
  2. Usage: This library is very standard but is optimized for the standard 0.1 Ohm resistor. If you change the resistor, you will need to manually adjust the calibration values in the library functions.

For INA226:

  1. Library: INA226_WE (by Wolfgang Ewald) or RobTillaart/INA226
  2. Usage:
  3. To set the resistor value in the INA226_WE library, you can use a specific function called setResistorRange() where you simply type in your custom resistor value (e.g., 0.005 Ohms) and your maximum expected current (e.g., 15 Amps). The library automatically calculates the calibration factor for you.
ina226.setResistorRange(shuntResistance, maxCurrent);
  1. To set the resistor value in the RobTillaart/INA226 library, you use the setMaxCurrentShunt() function.
  2. maxCurrent: The maximum current you expect to measure (in Amps).
  3. shuntResistance: The value of your resistor (in Ohms).
ina.setMaxCurrentShunt(maxCurrent, shuntResistance);

Software Logic

When writing your code, the flow should be:

  1. Initialize I2C: Start the wire connection.
  2. Set Calibration: Pass your custom resistor value (R) and max current (I) to the library.
  3. Read: Loop through the read functions to get Voltage (V), Current (I), and Power (P).


Step 8: Conclusion

The INA226 is an incredible tool, but it is only as good as the hardware around it. By understanding the physics of shunt resistors—specifically the power and voltage drop limits—and using a proper PCB layout like the EasyElectronics module, you can achieve laboratory-grade precision in your DIY projects.

If you decide to fabricate this board, let me know in the comments how you used it!

Happy Making!


Step 9: Links and Reference Tables

Attached Media:

  1. Address selection chart
  2. voltage drop Vs resistance
  3. Shunt Resistor Vs max current

Github Repo

Hackaday.io

Downloads

Gerber File

Schematic (coming soon)

PCB Design (coming soon)

INA226 Datasheet

INA219 Datasheet