INA219 Current Sensor with ESP32 – Measure Voltage, Current, and Power
If you are building an IoT power monitoring project, battery system, or power bank device, measuring current, voltage, and power accurately is very important. The INA219 Current Sensor Module is one of the best sensors for this purpose. In this project, we will focus on using the INA219 with ESP32.
In this guide, you will learn how to interface the INA219 current sensor with ESP32, measure voltage and current, understand the circuit diagram, and run the complete Arduino code. This tutorial is perfect for electronics beginners, IoT developers, and embedded system engineers. The integration of INA219 with ESP32 provides excellent performance.
Table of Contents
- What is INA219 Current Sensor
- Features of INA219 Module
- Components Required
- INA219 Pinout
- ESP32 and INA219 Circuit Diagram
- Wiring Connection
- Installing Required Library
- Arduino Code for ESP32 INA219
- Output in Serial Monitor
- Advantages of INA219
- Disadvantages of INA219
- Precautions While Using INA219
- Applications of INA219
- Conclusion
What is INA219 Current Sensor
The INA219 is a high-side current sensor IC developed by Texas Instruments. It measures current, voltage, and power digitally using I2C communication.
Unlike traditional current sensors, INA219 allows measurement without interrupting the ground line, making it perfect for battery-powered and embedded systems.
The module can measure:
- Bus Voltage
- Shunt Voltage
- Current
- Power
This makes it very useful for power monitoring systems, battery management, and IoT devices.
Features of INA219 Module
Some important features of the INA219 module include:
- High-side current sensing
- I2C communication interface
- Measures voltage up to 32V
- Current measurement up to 3.2A
- Built-in ADC for digital output
- High accuracy measurements
- Compatible with Arduino, ESP32, ESP8266, Raspberry Pi
Components Required
To build this project you need the following components:
- ESP32 Development Board
- INA219 Current Sensor Module
- Jumper Wires
- Power Source / Battery
- Load (LED, motor, etc.)
INA219 Pinout
The INA219 module has the following pins:
| Pin | Function |
|---|---|
| VCC | Power supply (3.3V – 5V) |
| GND | Ground |
| SDA | I2C Data |
| SCL | I2C Clock |
| VIN+ | Input Voltage Positive |
| VIN- | Output to Load |
ESP32 and INA219 Circuit Diagram
I2C Wiring
| INA219 | ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | GPIO21 |
| SCL | GPIO22 |
Using INA219 with ESP32 for Accurate Power Monitoring
Power Source + → VIN+
VIN- → Load +
Load - → Ground
The sensor measures the current flowing through the shunt resistor between VIN+ and VIN-.
Installing Required Library
Before uploading the code, install the library:
- Open Arduino IDE
- Go to Library Manager
- Search for Adafruit INA219
- Install the library
Library name:
Adafruit INA219HOW TO CONNECT

ESP32 INA219 Arduino Code
Below is the complete code to measure voltage, current, and power using INA219 with ESP32.
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup(void)
{
Serial.begin(115200);
while (!Serial) {
delay(1);
}
Serial.println("Hello!");
if (! ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) { delay(10); }
}
ina219.setCalibration_16V_400mA();
Serial.println("Measuring voltage and current with INA219 ...");
}
void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
float power_mW = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");
delay(2000);
}
Serial Monitor Output
After uploading the code, open Serial Monitor (115200 baud).
Example output:
Bus Voltage: 5.02 V
Shunt Voltage: 10.45 mV
Load Voltage: 5.03 V
Current: 215.30 mA
Power: 1080.00 mW
This shows the real-time voltage, current, and power consumption of the connected load.
Advantages of INA219
- High accuracy current measurement
- Measures voltage, current, and power simultaneously
- Digital output via I2C communication
- Works with both 3.3V and 5V microcontrollers
- Ideal for battery monitoring and IoT projects
Disadvantages of INA219
- Limited current range compared to industrial sensors
- Requires I2C communication setup
- Slight voltage drop across shunt resistor
- Not suitable for very high current applications
Precautions While Using INA219
To ensure accurate and safe operation:
- Always connect VIN+ and VIN- correctly
- Do not exceed the maximum current rating
- Use proper wiring to avoid loose connections
- Ensure correct I2C pins for ESP32
- Avoid measuring high current loads beyond module limits
Applications of INA219
The INA219 sensor is widely used in many projects such as:
- Battery monitoring systems
- Power bank current monitoring
- Solar energy systems
- IoT energy monitoring
- Smart power meters
- Embedded system power analysis
Conclusion
The INA219 current sensor with ESP32 provides an easy and reliable way to measure voltage, current, and power digitally. With its I2C communication and high accuracy, it is perfect for IoT, battery monitoring, and smart energy projects.
By following this guide, you can quickly build a real-time power monitoring system using ESP32 and INA219.
This sensor is especially useful for developers building power bank devices, battery management systems, or energy monitoring solutions.

Leave a Reply
You must be logged in to post a comment.