Using the INA228 breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_INA228 library, and running the provided example code.
Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the sensor VIN.
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector for low side monitoring:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout Vin- to GND (black wire)
- Breakout VBus to highest potential voltage (red wire)
- Breakout Vin+ to load's lowest potential (yellow wire)
Here is an Adafruit Metro wired up to the breakout using the STEMMA QT connector for high side monitoring:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout Vin- to load's highest potential (yellow wire)
- Breakout VBus to breakout Vin+ (red wire)
- Breakout Vin+ to highest project voltage (red wire)
Here is an Adafruit Metro wired up using a solderless breadboard for low side monitoring:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout VIN- to GND (black wire)
- Breakout VBUS to highest potential voltage (red wire)
- Breakout VIN+ to load's lowest potential (yellow wire)
Here is an Adafruit Metro wired up using a solderless breadboard for high side monitoring:
-
Board 5V to breakout VIN (red wire)
-
Board GND to breakout GND (black wire)
-
Board SCL to breakout SCL (yellow wire)
- Board SDA to breakout SDA (blue wire)
- Breakout VIN- to load's highest potential (yellow wire)
- Breakout VBUS to breakout VIN+ (red wire)
- Breakout VIN+ to highest project voltage (red wire)
For high side monitoring, you can solder the VBus jumper closed on the back of the breakout to simplify your wiring.
Library Installation
You can install the Adafruit_INA228 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_INA228, and select the Adafruit INA228 library:
If asked about dependencies, click "Install all".
If the "Dependencies" window does not come up, then you already have the dependencies installed.
If the dependencies are already installed, you must make sure you update them through the Arduino Library Manager before loading the example!
#include <Adafruit_INA228.h> Adafruit_INA228 ina228 = Adafruit_INA228(); void setup() { Serial.begin(115200); // Wait until serial port is opened while (!Serial) { delay(10); } Serial.println("Adafruit INA228 Test"); if (!ina228.begin()) { Serial.println("Couldn't find INA228 chip"); while (1) ; } Serial.println("Found INA228 chip"); // set shunt resistance and max current ina228.setShunt(0.015, 10.0); ina228.setAveragingCount(INA228_COUNT_16); uint16_t counts[] = {1, 4, 16, 64, 128, 256, 512, 1024}; Serial.print("Averaging counts: "); Serial.println(counts[ina228.getAveragingCount()]); // set the time over which to measure the current and bus voltage ina228.setVoltageConversionTime(INA228_TIME_150_us); Serial.print("Voltage conversion time: "); switch (ina228.getVoltageConversionTime()) { case INA228_TIME_50_us: Serial.print("50"); break; case INA228_TIME_84_us: Serial.print("84"); break; case INA228_TIME_150_us: Serial.print("150"); break; case INA228_TIME_280_us: Serial.print("280"); break; case INA228_TIME_540_us: Serial.print("540"); break; case INA228_TIME_1052_us: Serial.print("1052"); break; case INA228_TIME_2074_us: Serial.print("2074"); break; case INA228_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); ina228.setCurrentConversionTime(INA228_TIME_280_us); Serial.print("Current conversion time: "); switch (ina228.getCurrentConversionTime()) { case INA228_TIME_50_us: Serial.print("50"); break; case INA228_TIME_84_us: Serial.print("84"); break; case INA228_TIME_150_us: Serial.print("150"); break; case INA228_TIME_280_us: Serial.print("280"); break; case INA228_TIME_540_us: Serial.print("540"); break; case INA228_TIME_1052_us: Serial.print("1052"); break; case INA228_TIME_2074_us: Serial.print("2074"); break; case INA228_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); // default polarity for the alert is low on ready, but // it can be inverted! // ina228.setAlertPolarity(1); } void loop() { // by default the sensor does continuous reading, but // we can set to triggered mode. to do that, we have to set // the mode to trigger a new reading, then wait for a conversion // either by checking the ALERT pin or reading the ready register // ina228.setMode(INA228_MODE_TRIGGERED); // while (!ina228.conversionReady()) // delay(1); Serial.print("Current: "); Serial.print(ina228.readCurrent()); Serial.println(" mA"); Serial.print("Bus Voltage: "); Serial.print(ina228.readBusVoltage()); Serial.println(" mV"); Serial.print("Shunt Voltage: "); Serial.print(ina228.readShuntVoltage()); Serial.println(" mV"); Serial.print("Power: "); Serial.print(ina228.readPower()); Serial.println(" mW"); Serial.print("Energy: "); Serial.print(ina228.readEnergy()); Serial.println(" J"); Serial.print("Temperature: "); Serial.print(ina228.readDieTemp()); Serial.println(" *C"); Serial.println(); delay(1000); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You'll see the INA228 recognized over I2C. Then, your connected project's current, bus voltage, shunt voltage, power and energy measurements are printed out every second, along with the INA228's temperature reading in Celsius.
Page last edited January 28, 2025
Text editor powered by tinymce.