The INA3221 is a high-precision, low-power, bidirectional current and power monitoring integrated circuit (IC) with an I2C-compatible interface. It is designed to monitor voltage, current, and power on up to three separate power rails with high accuracy. This makes it an ideal choice for applications such as battery chargers, power supplies, and energy management systems where multiple channels are required.
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground reference for the IC |
2 | SDA | I2C Data Line |
3 | SCL | I2C Clock Line |
4 | A0 | Address pin to set I2C address |
5 | A1 | Address pin to set I2C address |
6 | V_S+ | Power supply input |
7-9 | IN+ | Input pins for voltage sensing (channels 1-3) |
10-12 | IN- | Input pins for return current sensing (channels 1-3) |
13 | ALERT | Alert output pin |
14 | V_Bus | Bus voltage input |
#include <Wire.h>
#include <INA3221.h>
INA3221 powerMonitor;
void setup() {
Wire.begin(); // Start I2C bus
Serial.begin(9600); // Start serial communication at 9600 baud
powerMonitor.begin(); // Initialize INA3221
powerMonitor.setShuntResistor(0, 0.1); // Set shunt resistor value for channel 1
// Repeat for other channels as needed
}
void loop() {
float shuntVoltage = powerMonitor.getShuntVoltage(0); // Read shunt voltage on channel 1
float busVoltage = powerMonitor.getBusVoltage(0); // Read bus voltage on channel 1
float current = powerMonitor.getCurrent(0); // Read current on channel 1
// Output the measurements
Serial.print("Shunt Voltage: "); Serial.print(shuntVoltage); Serial.println(" mV");
Serial.print("Bus Voltage: "); Serial.print(busVoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current); Serial.println(" mA");
delay(1000); // Wait for 1 second before next reading
}
Q: Can the INA3221 measure negative current? A: Yes, the INA3221 can measure bidirectional current flow through the shunt resistor.
Q: What is the purpose of the ALERT pin? A: The ALERT pin can be configured to trigger an interrupt on the microcontroller when a certain threshold is exceeded, such as overvoltage or overcurrent conditions.
Q: How do I change the I2C address of the INA3221? A: The I2C address can be changed by setting the A0 and A1 pins to either GND or V_S+ according to the datasheet's address configuration table.