The INA219, manufactured by Adafruit (Part ID: INA219), is a high-side current shunt monitor that measures both current and voltage, providing a digital output via the I2C interface. This versatile sensor is designed for high-voltage applications, capable of measuring up to 26 volts and 3.2 amps. Its compact design and high accuracy make it ideal for battery management systems, power monitoring, and energy optimization in various electronic projects.
The INA219 sensor offers precise current and voltage measurements with a digital I2C interface. Below are its key technical details:
Parameter | Value |
---|---|
Operating Voltage | 3.0V to 5.5V |
Measurable Voltage Range | 0V to 26V |
Measurable Current Range | ±3.2A (with default shunt) |
Shunt Resistor | 0.1Ω (default, 1% tolerance) |
Communication Protocol | I2C |
I2C Address (Default) | 0x40 |
Resolution | 12-bit |
Accuracy | ±1% |
Operating Temperature | -40°C to +125°C |
The INA219 module has the following pin layout:
Pin Name | Description |
---|---|
VIN+ | Positive input for the voltage to be measured (connect to load's positive) |
VIN- | Negative input for the voltage to be measured (connect to load's negative) |
VCC | Power supply input (3.0V to 5.5V) |
GND | Ground connection |
SDA | I2C data line |
SCL | I2C clock line |
The INA219 is straightforward to use in a circuit, especially with microcontrollers like the Arduino UNO. Below are the steps to integrate and use the sensor:
VCC
pin to the 5V or 3.3V pin of your microcontroller and the GND
pin to the ground.VIN+
pin to the positive terminal of the power source.VIN-
pin to the positive terminal of the load.SDA
pin to the Arduino's A4
pin (on an UNO) or the corresponding SDA pin on other boards.SCL
pin to the Arduino's A5
pin (on an UNO) or the corresponding SCL pin on other boards.Below is an example Arduino sketch to read current and voltage using the INA219:
#include <Wire.h>
#include <Adafruit_INA219.h>
// Create an instance of the INA219 sensor
Adafruit_INA219 ina219;
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
while (!Serial) {
delay(10); // Wait for the serial monitor to open
}
// Initialize the INA219 sensor
if (!ina219.begin()) {
Serial.println("Failed to find INA219 chip");
while (1) {
delay(10); // Halt execution if the sensor is not found
}
}
Serial.println("INA219 sensor initialized");
}
void loop() {
float shuntVoltage = 0.0; // Variable to store shunt voltage
float busVoltage = 0.0; // Variable to store bus voltage
float current_mA = 0.0; // Variable to store current in milliamps
float power_mW = 0.0; // Variable to store power in milliwatts
// Read values from the INA219 sensor
shuntVoltage = ina219.getShuntVoltage_mV();
busVoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
power_mW = ina219.getPower_mW();
// Print the readings to the serial monitor
Serial.print("Bus Voltage: "); Serial.print(busVoltage); Serial.println(" V");
Serial.print("Shunt Voltage: "); Serial.print(shuntVoltage); Serial.println(" mV");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW");
Serial.println("");
delay(1000); // Wait 1 second before taking the next reading
}
0x40
. If multiple INA219 sensors are used, configure their addresses by adjusting the A0 and A1 pins.No Data Output:
VCC
and GND
connections).0x40
).Incorrect Readings:
VIN+
and VIN-
.Sensor Not Detected:
Q: Can the INA219 measure negative currents?
A: Yes, the INA219 can measure bidirectional currents. Ensure the configuration matches your application.
Q: How do I change the I2C address?
A: Adjust the A0 and A1 pins on the module to set a new I2C address. Refer to the datasheet for address configuration.
Q: Can I use the INA219 with a 3.3V microcontroller?
A: Yes, the INA219 operates with both 3.3V and 5V logic levels, making it compatible with most microcontrollers.
Q: What is the maximum current the INA219 can measure?
A: With the default 0.1Ω shunt resistor, the maximum measurable current is ±3.2A. For higher currents, use a lower resistance shunt.
By following this documentation, you can effectively integrate the INA219 into your projects for accurate current and voltage monitoring.