The INA226 is a high-side current shunt monitor with an integrated I2C interface, designed for accurate current and voltage sensing in power management applications. It features a 16-bit analog-to-digital converter (ADC) for precise measurements, making it ideal for monitoring power consumption in systems such as servers, telecommunications equipment, and battery-powered devices. The INA226 supports a wide supply voltage range, making it versatile for various applications.
The INA226 is available in an 8-pin package. Below is the pinout and description:
Pin Number | Pin Name | Description |
---|---|---|
1 | VIN+ | Positive input for the differential voltage across the shunt resistor. |
2 | VIN- | Negative input for the differential voltage across the shunt resistor. |
3 | GND | Ground reference for the device. |
4 | SDA | Serial data line for I2C communication. |
5 | SCL | Serial clock line for I2C communication. |
6 | A0 | Address selection pin (LSB of I2C address). |
7 | A1 | Address selection pin (MSB of I2C address). |
8 | VCC | Power supply input (2.7V to 5.5V). |
Below is an example of how to use the INA226 with an Arduino UNO to measure current and voltage:
#include <Wire.h>
// INA226 I2C address (default: 0x40 if A0 and A1 are grounded)
#define INA226_ADDRESS 0x40
// INA226 register addresses
#define REG_CONFIG 0x00
#define REG_SHUNT_VOLTAGE 0x01
#define REG_BUS_VOLTAGE 0x02
void setup() {
Wire.begin(); // Initialize I2C communication
Serial.begin(9600); // Initialize serial communication for debugging
// Configure the INA226 (default configuration)
Wire.beginTransmission(INA226_ADDRESS);
Wire.write(REG_CONFIG); // Point to the configuration register
Wire.write(0x45); // MSB: Set averaging and conversion times
Wire.write(0x27); // LSB: Enable shunt and bus voltage measurements
Wire.endTransmission();
}
void loop() {
float shuntVoltage = readShuntVoltage(); // Read shunt voltage in mV
float busVoltage = readBusVoltage(); // Read bus voltage in V
Serial.print("Shunt Voltage (mV): ");
Serial.println(shuntVoltage);
Serial.print("Bus Voltage (V): ");
Serial.println(busVoltage);
delay(1000); // Wait 1 second before the next reading
}
float readShuntVoltage() {
int16_t rawValue = readRegister(REG_SHUNT_VOLTAGE);
return rawValue * 0.0025; // Convert to mV (LSB = 2.5µV)
}
float readBusVoltage() {
int16_t rawValue = readRegister(REG_BUS_VOLTAGE);
return rawValue * 0.00125; // Convert to V (LSB = 1.25mV)
}
int16_t readRegister(uint8_t reg) {
Wire.beginTransmission(INA226_ADDRESS);
Wire.write(reg); // Point to the desired register
Wire.endTransmission();
Wire.requestFrom(INA226_ADDRESS, 2); // Request 2 bytes
int16_t value = (Wire.read() << 8) | Wire.read(); // Combine MSB and LSB
return value;
}
No I2C Communication:
Incorrect Current or Voltage Readings:
Device Not Responding:
Q: Can the INA226 measure negative currents?
A: Yes, the INA226 can measure bidirectional currents if configured properly. Ensure the shunt voltage stays within the ±81.92mV range.
Q: What is the maximum sampling rate of the INA226?
A: The sampling rate depends on the averaging and conversion time settings. At the fastest configuration, it can achieve up to 2.1kHz.
Q: Can I use the INA226 with a 3.3V microcontroller?
A: Yes, the INA226 is compatible with 3.3V systems as long as the VCC pin is supplied with a voltage between 2.7V and 5.5V.
Q: How do I calculate power using the INA226?
A: Power can be calculated by multiplying the bus voltage and the current (derived from the shunt voltage and resistor value).