Adafruit INA219 current sensor strange readings

Hello all,

I was wondering if anyone could point me in the right direction please. I’m using this nice Adafruit board to sense current coming from a thermoelectric generator I’ve built - about 13v DC at 300mA.

The code compiles fine but readings coming back over the Serial Monitor look a bit like this:

1/4 o and various other interesting characters.

  • I’ve attached a screenshot.

Pins are

Adafruit Arduino
Vcc 5V
GND GND
Sc1 Analogue pin 5
SDA Analogue Pin 4

I’m using the example code from Github to get me going

#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;

void setup(void)
{
uint32_t currentFrequency;

Serial.begin(115200);
Serial.println(“Hello!”);

Serial.println(“Measuring voltage and current with INA219 …”);
ina219.begin();
}

void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;

shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);

Serial.print(“Bus Voltage: “); Serial.print(busvoltage); Serial.println(” V”);
Serial.print(“Shunt Voltage: “); Serial.print(shuntvoltage); Serial.println(” mV”);
Serial.print(“Load Voltage: “); Serial.print(loadvoltage); Serial.println(” V”);
Serial.print(“Current: “); Serial.print(current_mA); Serial.println(” mA”);
Serial.println("");

delay(2000);
}

And the header file for the board is here: Adafruit_INA219/Adafruit_INA219.h at master · adafruit/Adafruit_INA219 · GitHub

Any advice, help or pointers would be much appreciated - many thanks in advance if you can help.

Hi neilyneil

The device connects via I2C bus judging by those pin connections..

Search this site for I2C scanner program. If you run that, it will show if the Arduino detects a connected device, and help narrow down the problem.

Regards

Ray

Also, do you have serial monitor speed set to 115200 to match program?

AHA!

many thanks indeed - I feel very silly now, I'd had it set to 9600 for something that was on the end of a phonemally long USB. Have knocked it back up to 115200 and I have voltages and currents coming in nicely.

Thansk ever so much - I didn't think it would be something so simple

I know this thread has been silent for quite some time, but do you remember the circuit that you had to monitor the voltage and current generated by your thermoelectric module with the INA219? I'm trying to build a similar circuit but am having trouble figuring it out. Thank you in advance!