INA219 Problem

Hello ,
I have a new project that I ned to use the INA219 .

For this project I'm using the Arduino Ethernet (No POE).

I have connected the INA219 as it should
INA219 -- Arduino
VCC - 3.3V
Gnd - GND
Scl - SCL
Dsa - DSA

using this sample code I found online:

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

Adafruit_INA219 ina219;


void setup(void)
{
  Serial.begin(115200);
  while (!Serial) {
    // will pause Zero, Leonardo, etc until serial console opens
    delay(1);
  }

  uint32_t currentFrequency;

  Serial.println("Hello!");

  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  // you can call a setCalibration function to change this range (see comments).
  ina219.begin();
  // To use a slightly lower 32V, 1A range (higher precision on amps):
  ina219.setCalibration_32V_1A();
  // Or to use a lower 16V, 400mA range (higher precision on volts and amps):
  //ina219.setCalibration_16V_400mA();

  Serial.println("Measuring voltage and current with INA219 ...");
}

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

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  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.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");

  delay(2000);
}

but on the serial monitor I can't see nothing
only
"Hello!"

and I don't even get this line

Measuring voltage and current with INA219 ...

what could be the problem ?

I have try to use 3 more INA219 - in all of them I get the same resualt

I have also ise the i2c scanner code to see where is the problem

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, Dec 29, 2013
//    reduced size (RAM, Flash)
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void PrintAddress(byte addr)
{
  if ( addr < 16 )
  {
    Serial.print("0");
  };
  Serial.print(addr, HEX);
  Serial.print(" (");
  Serial.print(addr);
  Serial.println(")");
};

void setup()
{
  delay(2000); //wait for terminal to be open by user
  Wire.begin();
  Serial.begin(9600);
  Serial.println(F("\nI2C Scanner\n"));
};

void loop()
{
  byte error, address;
  int nDevices;

  Serial.println(F("Scanning...\n"));

  nDevices = 0;
  for ( address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if ( error == 0 )
    {
      Serial.print(F("I2C device found at address 0x"));
      PrintAddress(address);
      nDevices++;
    }
    else if ( error == 4 )
    {
      Serial.print(F("Unknown error at address 0x"));
      PrintAddress(address);
    };
  };
  if ( nDevices == 0 )
  {
    Serial.println(F("No I2C devices found\n"));
  }
  else
  {
    Serial.println("\nDone!\n");
  };
  delay(4000);           // wait 15 seconds for next scan
};

I don't see the devices at all

but ifI took the INA219 and connect it to the PI and run the scanner command

 sudo i2cdetect -y 1

I get a resualt :

 sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- 45 -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

how could it be ?
Thanks,

Fix your electrical problem until I2C scanner reports an address. Have you ever tried to connect a different I2C device?

What's the operating voltage of your Arduino? All devices on an I2C bus must be powered by the same voltage, else a level shifter is required.

Pullup resistors?

The unit has to have a load connection on the V out otherwise nothing will register.

yes , other devices work (i2c-lcd show address 0x27 )

well the next thing was very strange :

I connected the INA219 without the GND - and now I can see it in the scan

I2C device found at address 0x40 (64)

Done!

Scanning...

I2C device found at address 0x40 (64)

Done!

Scanning...

I2C device found at address 0x40 (64)

Done!

Scanning...

I2C device found at address 0x40 (64)

Done!

this is a brnad new INA219 - how could it be ?

do I need to connect something else to the GND ? or something before it?

because now it's wroking without GND (only 5V,SCL,SDA)

Strange no?

Hi,
Can you please post a picture of your project so we can see your component layout?

Thanks.. Tom... :slight_smile:

hope the image is clear and understanable :slight_smile:

Hi
OPs pic.


Thanks.. Tom... :slight_smile:

sorry ,
something is wrong in the picture?

david1234:
sorry ,
something is wrong in the picture?

No, it is just some platforms, like smartphones have problems showing attached files, so placing them in a post to view is more convenient.
Tom... :slight_smile:

something?

david1234:
something?

A song by George Harrison from the Abbey Road album, covered by other artists, including Shirley Bassey.

"If you have nothing to say - say nothing".

Mark Twain

Ah, that's why you keep secret the detail of your project that makes it fail!?

I told everything you (or any one else) ask for ,

if something is missing - let me know and I will upload \ publish

I want to understand what is not working ,

A circuit diagram were helpful. Double check that it matches your construction.

david1234:
because now it's wroking without GND (only 5V,SCL,SDA)

Strange no?

Yes, you must be doing something else wrong, because the INA219 chip doesn't get power without that ground.
You need four wires to the INA219, not three.

It seems you have connected SCL from the Arduino to GND of the INA,
and SDA of the Arduino to SCL of the INA.
Leo..

maybe the chip is not good?
because I have double check 5 times

when I look at the INA219(pins are at the lower end of the card - from left to right )
pin1 - VCC
pin2 - GND
pin3 - SCL
pin4 - SDA
pin5 - Vin-
pin6 - Vin+

VCC - 5V (White)
GND - GND
SCL - SCL (Gray)
SDA - SDA (Purpel)

you can see in the image I have upload , it might seem that the Gray is connected to GND , but no.

when I look at the datasheet
this is what I found (have upload an image)

maybe the factory made mistake?

because as you can see (if they put the wrong chip) GND and SDA pin6 are at the sample palce for the 2 version of the chip

can it be ?

Hi,
You don't show in your picture or respond to the query, do you have pullup resistors on the SDA and SCL lines?

4K7 between SDA and +5V, and 4K7 between +5V and SCL.

The 1NA219 breakout does not appear to have them fitted.
I think the Rasp Pi has these resistors fitted on its main PCB.
ina219-i2c-bi-directional-high-side-dc-current-power-monitor-sensor-module.jpg

Tom... :slight_smile:

ina219-i2c-bi-directional-high-side-dc-current-power-monitor-sensor-module.jpg

Hi,

I connected the INA219 without the GND - and now I can see it in the scan

Where in the load circuit are you placing the 1NA219?
In the negative lead or the positive lead of the power supply?

If it works when you disconnect the GND, it sounds like you are measuring gnd or negative lead current, instead of the positive lead current.

PLEASE post picture of a hand drawn circuit in jpg, png?
Include your power supplies and the load you are measuring the current through.

Tom... :slight_smile: