INA260 with fluctuating bus voltage readings

I have an INA260, in high-side configuration, measuring the power consumption of a 12v lightbulb (at the moment). The bulb is being powered from a regulated 12v adapter, whereas the INA260 is powered from the arduino USB (MKR1000). I’m using the Adafruit INA260 library.

The current reading seems pretty stable but the voltage (and therefore power) reading is fluctuating wildly. From 0.0mV to, say 4000mV and everything in between.

I’ve been following this example - but using a bulb instead of an LED strip: Arduino | Adafruit INA260 Current + Voltage + Power Sensor Breakout | Adafruit Learning System

I’ve tried all sorts (including buying the regulated power supply) but it’s such a simple circuit I’m out of ideas how it could be wrong. The only thing I can think of is that the sampling or averaging count is wrong, but I’m not familiar with the library and I’ve based it on the example from github (Adafruit_INA260/ina260_tuning.ino at master · adafruit/Adafruit_INA260 · GitHub)

Disclaimer: this is my first electronics project in a while, although I am a software engineer, I’m trying to experiment with IoT and power metering. I am happy to provide more information, and am prepared that I have made naive errors.

Code:

#include <Adafruit_INA260.h> 

Adafruit_INA260 ina260 = Adafruit_INA260();

void setup() { 
  Serial.begin(115200);
  
  while (!Serial); 
  delay(2000); 
 
  if (!ina260.begin()) {
    Serial.println("Couldn't find INA260 chip");
    while (1);
  }
  ina260.setAveragingCount(INA260_COUNT_16);
  ina260.setVoltageConversionTime(INA260_TIME_140_us);
  ina260.setCurrentConversionTime(INA260_TIME_140_us);
}

void loop() { 
  get_power_consumption();
  delay(20000);  //set to 20secs because i'm actually sending the output to a API for plotting on a graph
} 

float get_power_consumption() {
//  int reading = analogRead(powerSensorPin);
  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);
}

Output:

Current: 391.25 mA
Bus Voltage: 2358.75 mV
Power: 400.00 mW

Current: 427.50 mA
Bus Voltage: 506.25 mV
Power: 200.00 mW

Current: 391.25 mA
Bus Voltage: 0.00 mV
Power: 60.00 mW

Current: 391.25 mA
Bus Voltage: 791.25 mV
Power: 1510.00 mW

I’ve attached a circuit diagram and a picture of the real life setup (for idiot detection)

12volt supply ground and Arduino ground must be shared.
Leo..

As a side note, breadboards aren't really designed for high current circuits. 400mA is fine, but once you get into the amps range then those thin leads and breadboard contacts can get hot enough to melt the surrounding plastic.

Even cheap crocodile test leads aren't that great for high current loads. Checkout the wiring and connectors used for RC models. These can handle kinds of currents you find in automotive applications.

Hi Wawa. Thank you so much for your reply! I was tearing my hair out.

Practically how do I do that - is it as simple as connecting the ground rail of the two breadboards?

mikb55, genuine thanks for looking out for my safety. I promise I checked the safe range of the components i'm using, and after i've prototyped the circuit I promise I'll be switching to safer components. I havn't heard of RC model components - what does RC stand for (eg. what's my search engine search term)?

RC = radio controlled (model)
Search for XT60 connectors and associated cables. These are good for 60 amps.

moncheery:
Practically how do I do that - is it as simple as connecting the ground rail of the two breadboards?

Yes.

Grounds of the supply and the INA must be shared with shunt measurement (the INA family).
Not needed for Hall measurements (the ACS family).
Leo..