Using the INA23x breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller, installing the Adafruit_INA237_INA238 library, and running the provided example code.
The INA237 and INA238 are completely code and hardware equivalent. The only difference is that the INA238 has better gain error and offset voltage than the INA237.
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 power monitor VIN.
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 Vin+ to highest project voltage (red 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 Vin+ to highest project voltage (red wire)
For low side monitoring, you'll need to cut the VBus jumper on the back of the breakout and use this wiring:
-
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)
Library Installation
You can install the Adafruit_INA237_INA238 library for Arduino using the Library Manager in the Arduino IDE.
Click the Manage Libraries ... menu item, search for Adafruit_INA237_INA238, and select the Adafruit INA237 INA238 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_INA237.h> Adafruit_INA237 ina237 = Adafruit_INA237(); void setup() { Serial.begin(115200); // Wait until serial port is opened while (!Serial) { delay(10); } Serial.println("Adafruit INA237 Test"); if (!ina237.begin()) { Serial.println("Couldn't find INA237 chip"); while (1) ; } Serial.println("Found INA237 chip"); // set shunt resistance and max current ina237.setShunt(0.015, 10.0); ina237.setAveragingCount(INA2XX_COUNT_16); uint16_t counts[] = {1, 4, 16, 64, 128, 256, 512, 1024}; Serial.print("Averaging counts: "); Serial.println(counts[ina237.getAveragingCount()]); // set the time over which to measure the current and bus voltage ina237.setVoltageConversionTime(INA2XX_TIME_150_us); Serial.print("Voltage conversion time: "); switch (ina237.getVoltageConversionTime()) { case INA2XX_TIME_50_us: Serial.print("50"); break; case INA2XX_TIME_84_us: Serial.print("84"); break; case INA2XX_TIME_150_us: Serial.print("150"); break; case INA2XX_TIME_280_us: Serial.print("280"); break; case INA2XX_TIME_540_us: Serial.print("540"); break; case INA2XX_TIME_1052_us: Serial.print("1052"); break; case INA2XX_TIME_2074_us: Serial.print("2074"); break; case INA2XX_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); ina237.setCurrentConversionTime(INA2XX_TIME_280_us); Serial.print("Current conversion time: "); switch (ina237.getCurrentConversionTime()) { case INA2XX_TIME_50_us: Serial.print("50"); break; case INA2XX_TIME_84_us: Serial.print("84"); break; case INA2XX_TIME_150_us: Serial.print("150"); break; case INA2XX_TIME_280_us: Serial.print("280"); break; case INA2XX_TIME_540_us: Serial.print("540"); break; case INA2XX_TIME_1052_us: Serial.print("1052"); break; case INA2XX_TIME_2074_us: Serial.print("2074"); break; case INA2XX_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); // default polarity for the alert is low on ready, but // it can be inverted! // ina237.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 // ina237.setMode(INA2XX_MODE_TRIGGERED); // while (!ina237.conversionReady()) // delay(1); Serial.print("Current: "); Serial.print(ina237.getCurrent_mA()); Serial.println(" mA"); Serial.print("Bus Voltage: "); Serial.print(ina237.getBusVoltage_V()); Serial.println(" V"); Serial.print("Shunt Voltage: "); Serial.print(ina237.getShuntVoltage_mV() * 1000.0); // Convert from mV to μV Serial.println(" uV"); Serial.print("Power: "); Serial.print(ina237.getPower_mW()); Serial.println(" mW"); Serial.print("Temperature: "); Serial.print(ina237.readDieTemp()); Serial.println(" *C"); Serial.println(); delay(1000); }
#include <Adafruit_INA238.h> // Note: The INA238 is functionally identical to the INA237. // This example demonstrates the INA238-specific class, but // all functionality is identical to the INA237 example. Adafruit_INA238 ina238 = Adafruit_INA238(); void setup() { Serial.begin(115200); // Wait until serial port is opened while (!Serial) { delay(10); } Serial.println("Adafruit INA238 Test"); if (!ina238.begin()) { Serial.println("Couldn't find INA238 chip"); while (1) ; } Serial.println("Found INA238 chip"); // set shunt resistance and max current ina238.setShunt(0.015, 10.0); ina238.setAveragingCount(INA2XX_COUNT_16); uint16_t counts[] = {1, 4, 16, 64, 128, 256, 512, 1024}; Serial.print("Averaging counts: "); Serial.println(counts[ina238.getAveragingCount()]); // set the time over which to measure the current and bus voltage ina238.setVoltageConversionTime(INA2XX_TIME_150_us); Serial.print("Voltage conversion time: "); switch (ina238.getVoltageConversionTime()) { case INA2XX_TIME_50_us: Serial.print("50"); break; case INA2XX_TIME_84_us: Serial.print("84"); break; case INA2XX_TIME_150_us: Serial.print("150"); break; case INA2XX_TIME_280_us: Serial.print("280"); break; case INA2XX_TIME_540_us: Serial.print("540"); break; case INA2XX_TIME_1052_us: Serial.print("1052"); break; case INA2XX_TIME_2074_us: Serial.print("2074"); break; case INA2XX_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); ina238.setCurrentConversionTime(INA2XX_TIME_280_us); Serial.print("Current conversion time: "); switch (ina238.getCurrentConversionTime()) { case INA2XX_TIME_50_us: Serial.print("50"); break; case INA2XX_TIME_84_us: Serial.print("84"); break; case INA2XX_TIME_150_us: Serial.print("150"); break; case INA2XX_TIME_280_us: Serial.print("280"); break; case INA2XX_TIME_540_us: Serial.print("540"); break; case INA2XX_TIME_1052_us: Serial.print("1052"); break; case INA2XX_TIME_2074_us: Serial.print("2074"); break; case INA2XX_TIME_4120_us: Serial.print("4120"); break; } Serial.println(" uS"); // default polarity for the alert is low on ready, but // it can be inverted! // ina238.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 // ina238.setMode(INA2XX_MODE_TRIGGERED); // while (!ina238.conversionReady()) // delay(1); Serial.print("Current: "); Serial.print(ina238.getCurrent_mA()); Serial.println(" mA"); Serial.print("Bus Voltage: "); Serial.print(ina238.getBusVoltage_V()); Serial.println(" V"); Serial.print("Shunt Voltage: "); Serial.print(ina238.getShuntVoltage_mV() * 1000.0); // Convert from mV to μV Serial.println(" uV"); Serial.print("Power: "); Serial.print(ina238.getPower_mW()); Serial.println(" mW"); Serial.print("Temperature: "); Serial.print(ina238.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 INA237 or INA238 recognized over I2C. Then, your connected project's current, bus voltage, shunt voltage and power are printed out every second, along with the INA23x's temperature reading in Celsius.
Page last edited June 11, 2025
Text editor powered by tinymce.