INA219 High-Side Current, Voltage and Power Sensor
A tiny I²C power meter that reads bus voltage, current and power up to 26 V and about 3.2 A, ready for battery, solar and load monitoring.
Wiring & code for
What is the INA219?
A multimeter tells you the voltage and, if you break the circuit and put it in series, the current. The INA219 does both continuously, with no breaking of probes, and sends the results to your microcontroller as digital numbers. It is Texas Instruments' small high-side current and power monitor: a chip that measures the voltage drop across a tiny shunt resistor in your supply line, measures the bus voltage at the same time and calculates power for you.
Most hobby boards carry the chip together with a 0.1 Ω shunt resistor and a pair of screw terminals, so the whole thing is a ready-made inline power meter. You connect VIN+ to the supply, VIN− to the load, wire four pins to your Arduino or ESP32, and you can read bus voltage, current in milliamps and power in milliwatts over I²C.
That makes it a favourite for battery monitors, solar charge logging, measuring how much current a project really draws, checking if a motor stalls, and building a lab-style power meter with a screen. This page explains how it works, why the shunt choice matters, how to wire it without making the classic mistakes, and gives you working code for the Arduino Uno and ESP32, including a milliamp-hour counter.
Warning
The INA219 can only handle a bus voltage up to 26 V, and the Adafruit library's "32 V" calibration names are a range setting, not a permission to connect 32 V. Never exceed 26 V on VIN+ or VIN−. The common board's shunt also limits continuous current to roughly 3 A, and it gets hot above that. For higher voltages use an INA226 or an INA260.
Specifications
- Measures
- Bus voltage, shunt voltage, current and power over I²C
- Bus voltage range
- 0 V to 26 V (the library's "32 V" setting is a range option, not a safe input level)
- Shunt voltage range
- ±40 mV, ±80 mV, ±160 mV or ±320 mV (programmable gain, default ±320 mV)
- Typical breakout shunt
- 0.1 Ω (R100), giving about ±3.2 A full scale
- ADC resolution
- 12-bit; shunt LSB 10 µV, bus voltage LSB 4 mV
- Current resolution (default)
- About 0.1 mA with a 0.1 Ω shunt and the library's 32 V / 2 A calibration
- Supply voltage (VCC)
- 3.0 V – 5.5 V, so it works on 3.3 V and 5 V boards
- Supply current
- About 1 mA while measuring
- Interface
- I²C / SMBus, up to 400 kHz on common boards (high-speed mode supported by the chip)
- I²C address
- 0x40 by default, 16 addresses (0x40–0x4F) using the A0 and A1 pads
- Conversion time
- About 84 µs to 68 ms per reading depending on resolution and averaging (about 532 µs in the default setup)
- Sensing type
- High-side: the shunt sits in the positive supply line
Pinout
| Pin | Name | Description |
|---|---|---|
| 1 | VIN+ | Positive side of the shunt. Connect to the power source (+) |
| 2 | VIN− | Other side of the shunt. Connect to the load (+). Bus voltage is measured here |
| 3 | VCC | Chip power, 3.0–5.5 V from your microcontroller |
| 4 | GND | Ground. Must be shared with the microcontroller and the measured circuit |
| 5 | SDA | I²C data |
| 6 | SCL | I²C clock |
Swipe sideways to see every column →
The two screw terminals VIN+ and VIN− are not power inputs for the chip. They are the two ends of the 0.1 Ω shunt resistor, and your load current flows through them, so the board must sit in series with the positive wire between the source and the load. The row of pins with VCC, GND, SDA and SCL is the I²C side that goes to your Arduino or ESP32. Some boards add pads labelled A0 and A1 to change the I²C address. On a 3.3 V ESP32, power VCC from 3.3 V. The measured circuit can be at a different voltage (up to 26 V), but its ground must be common with the microcontroller's ground.
Variants
| Variant | Bus voltage | ADC | Current range | Notes | Price |
|---|---|---|---|---|---|
| INA219 (this page) | 0–26 V | 12-bit | ±3.2 A (0.1 Ω shunt) | High-side, I²C, 16 addresses | ~$1–4 |
| INA226 | 0–36 V | 16-bit | ±~800 mA to several A (depends on shunt) | Better accuracy, alert pin, same I²C style | ~$2–6 |
| INA260 | 0–36 V | 16-bit | ±15 A | Built-in 2 mΩ shunt, no external resistor | ~$8–12 |
| INA3221 | 0–26 V | 13-bit | 3 channels, 0.1 Ω each | Monitors three rails with one chip | ~$4–8 |
| ACS712 (Hall effect) | Not measured | Analog | 5 A / 20 A / 30 A | Isolated, handles AC, noisy, needs ADC | ~$2–4 |
Swipe sideways to see every column →
The INA219 is the sweet spot for hobby power monitoring: it is cheap, easy and measures voltage, current and power in one chip. Choose the INA226 when you need better accuracy or a bus voltage above 26 V, and the INA260 when you want a high-current board with no shunt to solder. Use the ACS712 only when you need isolation or want to measure AC current.
How the INA219 measures current
The INA219 does not measure current directly. It measures a small voltage and Ohm's law does the rest. When your load current flows through a shunt resistor, a voltage appears across it equal to current multiplied by resistance. With the common 0.1 Ω shunt, 1 A creates 100 mV and 100 mA creates just 10 mV. The INA219's front end amplifies and digitises that tiny voltage with a 12-bit converter whose smallest step is 10 µV, which with 0.1 Ω works out to about 0.1 mA per step.
The chip actually reads two voltages:
- The shunt voltage, the difference between VIN+ and VIN−, which is proportional to the load current.
- The bus voltage, the voltage at VIN− relative to ground, which is what your load actually sees.
From those two, plus a value stored in its calibration register, the chip can report current and power directly. The calibration value tells it how to turn the shunt voltage into amps: Cal = 0.04096 / (Current_LSB × R_shunt). With a 0.1 Ω shunt and a current step of 0.1 mA, the result is 4096, which is exactly what the Adafruit library programs for its 32 V / 2 A setting. Power is then bus voltage multiplied by current, and the chip's power step is always 20 times the current step.
Because the chip senses on the positive side of the load (high-side), the load keeps a solid ground connection. That is important: if you put a shunt in the ground wire instead, the ground of your circuit floats up by the voltage drop and your microcontroller and sensors no longer share a true ground.
The shunt resistor: range and resolution
The shunt value is the single most important design choice. A larger shunt resistor produces a larger voltage for the same current, which gives you finer resolution on small currents, but it wastes more voltage and heat on large currents. A smaller shunt does the opposite.
| Shunt | Max current at ±320 mV | Current step (10 µV LSB) | Voltage drop at full scale | Best for |
|---|---|---|---|---|
| 1 Ω | 320 mA | 10 µA | 0.32 V | Small sensor nodes, low-power IoT |
| 0.1 Ω (standard board) | 3.2 A | 0.1 mA | 0.32 V | Motors, LED strips, battery projects |
| 0.01 Ω | 32 A | 1 mA | 0.32 V | High-current loads (needs a proper shunt) |
Three practical points follow from the table.
Burden voltage. The shunt steals voltage from your load. At 1 A through 0.1 Ω you lose 0.1 V, and at 3 A you lose 0.3 V. On a 12 V motor that does not matter. On a 3.3 V ESP32 it can push the supply below its brown-out threshold, so keep the current modest or use a smaller shunt.
Heat. Power in the resistor is I²R. At 3 A through 0.1 Ω that is 0.9 W, which a small surface-mount resistor on a hobby board can only handle with some airflow. Check the rating of your board's resistor and keep continuous current comfortably below the maximum.
Resolution is not accuracy. The chip's step is tiny, but offset error, noise and the tolerance of the shunt limit how precise a reading really is. The datasheet lists a shunt offset in the region of 100 µV maximum, which with 0.1 Ω is up to about 1 mA of error at zero load. For milliamp-scale accuracy you should measure and subtract the zero offset in software, and expect a percent or so of gain error.
To change the shunt, replace the resistor (a soldering iron and steady hands are needed) and recalculate the calibration value. Libraries such as INA219_WE and Rob Tillaart's INA219 let you set a custom shunt value and maximum current, which the Adafruit library does not.
Wiring: connect it in series with the positive line
The INA219 is wired like an ammeter: the circuit must pass through the board. Many beginners connect VIN+ and VIN− across the load, as they would a voltmeter, which shorts the supply through the shunt or reads nothing useful.
The correct connection is:
- Source (+) to VIN+
- VIN− to the load (+)
- Load (−) to source (−), as normal
- INA219 GND to the same ground, which is also the microcontroller's GND
- VCC to 3.3 V or 5 V from your microcontroller
- SDA and SCL to the board's I²C pins
On an Arduino Uno, SDA is A4 and SCL is A5. On an ESP32 DevKit, the default I²C pins are GPIO21 (SDA) and GPIO22 (SCL). Power the breakout's VCC from 3.3 V on the ESP32 so the I²C lines stay at 3.3 V.
The measured circuit can run at a different voltage from your microcontroller, for example a 12 V battery powering a pump. The INA219 handles that because VIN+ and VIN− are rated up to 26 V. The only requirement is that all grounds are shared.
If you need more than one INA219 on the same I²C bus, bridge the A0 and A1 solder pads. Bridging A0 gives address 0x41, A1 gives 0x44 and both give 0x45, which means up to 16 chips can share two wires.
- 1Open the Arduino IDE and go to Tools → Manage Libraries.
- 2Search for "Adafruit INA219" and install it, accepting the prompt to also install Adafruit BusIO.
- 3Wire VCC, GND, SDA and SCL to your board, and put the INA219 in series with the positive wire of the circuit you want to measure.
- 4Open File → Examples → Adafruit INA219 → getcurrent, or paste the sketch below.
- 5Select your board and port, upload the sketch and open the Serial Monitor at 115200 baud.
- 6Connect a known load, such as an LED with a resistor, and compare the current with a multimeter in series.
Reading the sensor, line by line
The Adafruit INA219 library takes care of the registers and the calibration. Adafruit_INA219 ina219; creates an object at the default address 0x40. In setup(), ina219.begin() starts I²C, resets the chip and returns false if nothing answers, which is the first thing to check when something is wrong.
ina219.setCalibration_32V_2A(); loads the default calibration, which is designed for a 0.1 Ω shunt, with a bus voltage range up to 32 V and a maximum current of about 3.2 A. The library also offers setCalibration_32V_1A(), which trades range for finer steps (about 40 µA instead of 100 µA), and setCalibration_16V_400mA(), which gives the finest resolution for small loads. Pick the smallest range that safely covers your maximum current. If your load can draw more than the range allows, the readings clip.
The four readings are then:
getBusVoltage_V()is the voltage at the load side of the shunt, in volts.getShuntVoltage_mV()is the voltage across the shunt, in millivolts.getCurrent_mA()is the load current in milliamps. The sign is positive when current flows from VIN+ to VIN−, and negative if the load is wired the wrong way round.getPower_mW()is the power in milliwatts.
The sketch also adds the shunt drop back to the bus voltage to estimate the source voltage at VIN+, because that is the voltage of your battery or supply before the shunt takes its share.
Counting milliamp-hours: a battery and solar logger
A real-time reading is useful, but the question most projects ask is "how much energy has been used?". That needs integration: multiply the current by the time it flowed, and keep adding. The unit most makers use is the milliamp-hour (mAh), and the watt-hour (Wh) for energy.
The sketch below measures how long a battery lasts under a load. It reads the current at a steady interval, adds current × time to a running mAh total, and does the same for watt-hours using the power reading. Run it on a discharging battery and you get a real capacity measurement, which is far more honest than the number printed on a cheap cell.
For this to work, the sketch must not miss time. It uses millis() to compute the exact time since the last reading instead of assuming a fixed delay, so a slow Serial print will not make the total drift.
Getting accurate readings
The INA219 is a good measurement chip, but a few habits separate a reading you can trust from one that is a few percent off.
Remove the zero offset. With nothing connected to the load, the reading should be 0.0 mA. If it shows a small steady value, such as 0.4 mA, that is offset error. Measure it once with the load disconnected and subtract it in your code. It matters most when you measure small currents.
Choose the right range. Using a 3.2 A range to measure a 20 mA sensor node wastes resolution, because the readings jump in 0.1 mA steps and noise looks relatively large. Switch to the 400 mA calibration or use a larger shunt for low-current work.
Average noisy loads. Motors, switching regulators and radios produce current spikes. The chip converts a sample in a fraction of a millisecond, so a single reading can land on a peak or a trough. Average several samples, or let the chip average for you by setting a longer conversion time with averaging.
Do not expect it to see sleep current. A deep-sleeping ESP32 draws about ten to a few hundred microamps depending on the board, and a 0.1 Ω shunt with 0.1 mA steps plus its offset cannot measure that reliably. Use a bigger shunt, a dedicated low-current monitor or a tool built for the job.
Keep the wires short and thick. Resistance in the wire adds to the shunt's, drops voltage and heats up. Use solid connections, with screw terminals tightened properly. A loose terminal is a classic cause of flickering readings.
Compare with a multimeter once. Put a trusted meter in series with the same circuit and compare at two or three currents. If the INA219 is consistently a percent or two off, apply a gain correction in the code.
Troubleshooting
Almost every INA219 problem is a connection, ground or I²C addressing issue.
| Symptom | Likely cause | Fix |
|---|---|---|
| "INA219 not found" | Wrong wiring, no VCC, wrong I²C pins or address | Check VCC, GND, SDA and SCL, and run an I²C scanner to see the address. Default is 0x40 |
| Current always reads 0 | Load not passing through the board, or VIN+ and VIN− connected across the load | Put the board in series with the positive wire, source to VIN+ and load to VIN− |
| Current is negative | Current flows from VIN− to VIN+ | Swap the two wires, or accept the sign if it is a charging current |
| Bus voltage reads 0 or very low | Ground not shared, or load not powered | Connect the INA219 GND to the circuit ground and to the microcontroller ground |
| Reads a few mA with nothing connected | Offset error of the shunt amplifier | Measure the zero reading and subtract it |
| Readings jump around | Noisy load, loose terminal or long wires | Average samples, tighten the terminals and shorten the wires |
| Current clips at the maximum | Load draws more than the calibration range | Use a larger range, a smaller shunt, or reduce the load |
| ESP32 resets when the load starts | The shunt's voltage drop pushes the 3.3 V rail down | Measure a higher-voltage rail, use a smaller shunt, or power the ESP32 separately |
| Board gets very hot | Current above the shunt's rating | Reduce the current or use a heavier shunt or an INA260 |
| Two INA219s clash on the bus | Same address on both | Bridge A0 or A1 on one board to change its address |
What to build with it
The INA219 makes a surprising number of projects possible:
- Battery capacity tester that discharges a cell and logs voltage, current and mAh.
- Solar charge monitor that records panel voltage and charging current across the day.
- Pocket USB power meter with an OLED that shows volts, amps and watts for chargers and cables.
- Smart plug for DC loads that cuts the relay if the current exceeds a limit.
- Motor stall detector that spots a jam by the jump in current.
- ESP32 energy dashboard that sends readings over MQTT to Home Assistant, Grafana or a cloud service.
Always think about the worst case before you wire it up. A short circuit, a stalled motor or a battery with no current limit can exceed the board's current rating in a fraction of a second, so add a fuse in line with your supply.
Frequently asked questions
What is the maximum voltage and current of the INA219? The bus voltage can go up to 26 V. With the common 0.1 Ω shunt the full-scale current is about 3.2 A, though the resistor's power rating limits how long you can run near that.
Can I use it with a 3.3 V board like the ESP32? Yes. Power VCC from 3.3 V and use the ESP32's I²C pins. The measured circuit can be at a different, higher voltage.
What does "high-side" mean? It means the sensing resistor sits in the positive supply line, not in the ground return. The load keeps its true ground, which is safer for microcontrollers and sensors.
Why does the library say "32V" if the chip only handles 26 V? The "32 V" refers to the full-scale range setting of the bus voltage converter. The absolute limit of the pins is 26 V, so never apply more than that.
Can I measure AC current with it? No. The INA219 measures DC, and the bus voltage is referenced to ground. For AC mains use an isolated sensor made for the job, and take proper safety precautions.
How do I use two or more INA219 boards? Give each a different address by bridging the A0 and A1 pads, and create one library object per address. Up to 16 chips can share a single I²C bus.
Is it accurate enough for measuring my battery's capacity? For hobby use, yes. After removing the zero offset, you can expect results within a few percent, which is more than good enough for comparing cells and spotting fakes.
What is the difference between the INA219 and the ACS712? The INA219 is a digital shunt monitor that reports voltage, current and power over I²C and is more accurate at low currents. The ACS712 is a Hall-effect sensor that gives an analog voltage, offers isolation and can measure AC, but it is noisier and has a large zero offset.
Sources This page is based on the Texas Instruments INA219 datasheet and the Adafruit INA219 library documentation. Validate the board's voltage, current and heating limits against your exact hardware before using it in a critical system.