Arduino

Wiring

Connecting the INA260 to your Feather or Arduino is easy:

  • If you are running a Feather (3.3V), connect Feather 3V to board VIN
  • If you are running a 5V Arduino (Uno, etc.), connect Arduino 5Vto board VIN
  • Connect Feather or Arduino GND to board GND
  • Connect Feather or Arduino SCL to board SCL
  • Connect Feather or Arduino SDA to board SDA
  • Connect Vin+ to supply for high side current sensing or to load ground for low side sensing.
  • Connect Vin- to load for high side current sensing or to board ground for low side sensing

The final results should resemble the illustration above, showing an Adafruit Metro development board.

Install Adafruit_INA260 library

To begin reading sensor data, you will need to install the Adafruit_INA260 library (code on our github repository). It is available from the Arduino library manager so we recommend using that.

From the IDE open up the library manager...

Click the Manage Libraries ... menu item, search for Adafruit INA260, and select the Adafruit INA260 library and click Install:

Then follow the same process for the Adafruit BusIO library.

Example Code

The following example code is part of the standard library, but illustrates how you can retrieve sensor data from the INA260 for the Current, Voltage, and Power.

Load Demo

Open up File->Examples->Adafruit_INA260 Library->ina260_test and upload to your Arduino wired up to the sensor.

Additionally you will want to add code to turn the neopixel strip on so that there is some current to measure! If you're not familiar with using the NeoPixel library, please consult the excellent NeoPixel Überguide page on the subject.

Upload the sketch to your board and open up the Serial Monitor (Tools->Serial Monitor). You should see the the values for Current, Voltage, and Power.

#include <Adafruit_INA260.h>

Adafruit_INA260 ina260 = Adafruit_INA260();

void setup() {
  Serial.begin(115200);
  // Wait until serial port is opened
  while (!Serial) { delay(10); }

  Serial.println("Adafruit INA260 Test");

  if (!ina260.begin()) {
    Serial.println("Couldn't find INA260 chip");
    while (1);
  }
  Serial.println("Found INA260 chip");
}

void loop() {
  Serial.print("Current: ");
  Serial.print(ina260.readCurrent());
  Serial.println(" mA");

  Serial.print("Bus Voltage: ");
  Serial.print(ina260.readBusVoltage());
  Serial.println(" mV");

  Serial.print("Power: ");
  Serial.print(ina260.readPower());
  Serial.println(" mW");

  Serial.println();
  delay(1000);
}

You should get something resembling the following output when you open the Serial Monitor at 9600 baud:

Arduino Usage

Here we'll explain the different calls to the INA260 library and their use

First we include the  library and create an Adafruit_INA260 object to use in the rest of the sketch.

Download: file
#include <Adafruit_INA260.h>

Adafruit_INA260 ina260 = Adafruit_INA260();

Next, in the setup we call the INA260 object's begin function to initialize the driver and prepare it to read measurements from the sensor.

The begin function will return false if it is unable to make a connection to an INA260 sensor. If this happens, double check your power and I2C wiring.

Download: file
  if (!ina260.begin()) {
    Serial.println("Couldn't find INA260 chip");
    while (1);
  }

Finally we can take some readings! readCurrent, readBusVoltage, and readPower all read and return the given measurements in milliamps, millivolts, and milliwatts respectively.

Download: file
  Serial.print("Current: ");
  Serial.print(ina260.readCurrent());
  Serial.println(" mA");

  Serial.print("Bus Voltage: ");
  Serial.print(ina260.readBusVoltage());
  Serial.println(" mV");

  Serial.print("Power: ");
  Serial.print(ina260.readPower());
  Serial.println(" mW");
By default power and voltage measurements are only accurate for high side current sensing

To get accurate measurements when calling readVoltage and readPower you will need to cut the VB jumper on the right side of the breakout and connect the VBus pin to your bus.

This guide was first published on May 01, 2019. It was last updated on May 01, 2019. This page (Arduino) was last updated on Aug 18, 2019.