Go Down

Topic: ina219 can't read 2nd sensor (Read 335 times) previous topic - next topic

reich

hello.. i'm working with two ina219 sensors for my final assigment at college. i soldered one sensor A0 bridge so i can get different address. now i got 0x40 and 0x41. when i try to read the sensors without load, one sensor (0x40) seems working but the other (0x41) whenever i try to connect with load or not its always read 0 to all variable. i dont understand how to use wire library, if it must use that to get the data from sensor B. can someone help me?

here is my code
Code: [Select]

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

Adafruit_INA219 ina219_A;
Adafruit_INA219 ina219_B(0x41);

void setup()
{
  Serial.begin(9600);
  Serial.println("Measuring voltage and current with INA219 ...");
  ina219_A.begin();
  ina219_B.begin();
 
}

void loop()
{
  float shuntvoltage_A = 0;
  float busvoltage_A = 0;
  float current_mA_A = 0;
  float loadvoltage_A = 0;
  float power_A = 0;
 
  float shuntvoltage_B = 0;
  float busvoltage_B = 0;
  float current_mA_B = 0;
  float loadvoltage_B = 0;
  float power_B = 0;

  shuntvoltage_A = ina219_A.getShuntVoltage_mV();
  busvoltage_A = ina219_A.getBusVoltage_V();
  current_mA_A = ina219_A.getCurrent_mA();
  loadvoltage_A = busvoltage_A + (shuntvoltage_A / 1000);
  power_A = current_mA_A * loadvoltage_A;

  shuntvoltage_B = ina219_B.getShuntVoltage_mV();
  busvoltage_B = ina219_B.getBusVoltage_V();
  current_mA_B = ina219_B.getCurrent_mA();
  loadvoltage_B = busvoltage_B + (shuntvoltage_B / 1000);
  power_B = current_mA_B * loadvoltage_B;
 
  Serial.print("Bus Voltage_A: "); Serial.print(busvoltage_A); Serial.println(" V");
  Serial.print("Shunt Voltage_A: "); Serial.print(shuntvoltage_A); Serial.println(" mV");
  Serial.print("Load Voltage_A: "); Serial.print(loadvoltage_A); Serial.println(" V");
  Serial.print("Current_A: "); Serial.print(current_mA_A); Serial.println(" mA");
  Serial.print("Power_A: "); Serial.print(power_A); Serial.println(" mW");
  Serial.println("***********************************************");
 
  Serial.print("Bus Voltage_B: "); Serial.print(busvoltage_B); Serial.println(" V");
  Serial.print("Shunt Voltage_B: "); Serial.print(shuntvoltage_B); Serial.println(" mV");
  Serial.print("Load Voltage_B: "); Serial.print(loadvoltage_B); Serial.println(" V");
  Serial.print("Current_B: "); Serial.print(current_mA_B); Serial.println(" mA");
  Serial.print("Power_B: "); Serial.print(power_B); Serial.println(" mW");
  Serial.println("***********************************************");
 
  delay(1000);
}



pylon

Quote
i soldered one sensor A0 bridge so i can get different address.
You failed to provide a link to your breakout board. The INA219 has no soldering bridges as it's simply a chip. If your board has bridges for selecting the address you most probably have to cut another connection as for the default address the A0 and A1 pins must be connected to GND. With the schematics of your board we cannot tell what address the second board is listening to. Have you tried an I2C scanner?

Go Up