Hi,
I've got 3 INA219 sensors at three different address 0x40, 0x41, 0x42. This data will be displayed on my tft screen (I've omitted the code for this bit for now to focus on the INA219 sensors). I'm still getting the same reading for 0x40 and 0x41 (I haven't tried with the third sensor yet) but it shouldn't be giving the same reading according to my PSU.
I'm using a Metro M0 Express, a RA8875 driver board, a few other sensors and 3x INA219 chips.
This is what my code looks like -
If any obvious errors can be spotted, please do let me know.
#include <Wire.h>
#include <Adafruit_INA219.h>
// #include <SPI.h>
// #include "Adafruit_GFX.h"
// #include "Adafruit_RA8875.h"
#define INA219_5 0x40
#define INA219_12 0x41
#define INA219_24 0x42
Adafruit_INA219 ina219_5;
Adafruit_INA219 ina219_12;
Adafruit_INA219 ina219_24;
void setup() {
Serial.begin(9600);
Wire.begin();
// Initialise the 4th sensor
if (! ina219_5.begin()) {
Serial.println("Failed to find INA219 5V chip");
while (1) { delay(10); }
}
Serial.println("INA219 5V Found!");
// Initialise the 5th sensor
if (! ina219_12.begin()) {
Serial.println("Failed to find INA219 12V chip");
while (1) { delay(10); }
}
Serial.println("INA219 12V Found!");
// Initialise the 6th sensor
if (! ina219_24.begin()) {
Serial.println("Failed to find INA219 24V chip");
while (1) { delay(10); }
}
Serial.println("INA219 24V Found!");
}
void loop() {
float current_mA_5V = 0;
current_mA_5V = ina219_5.getCurrent_mA();
float shuntvoltage_5 = 0;
float busvoltage_5 = 0;
float current_mA_5 = 0;
float loadvoltage_5 = 0;
float power_mW_5 = 0;
current_mA_5 = ina219_5.getCurrent_mA();
// tft.textSetCursor(400, 160);tft.textColor(CYAN, RA8875_BLACK);tft.textEnlarge(2);tft.textEnlarge(1);tft.print(current_mA_5);
float current_mA_12V = 0;
current_mA_12V = ina219_12.getCurrent_mA();
float shuntvoltage_12 = 0;
float busvoltage_12 = 0;
float current_mA_12 = 0;
float loadvoltage_12 = 0;
float power_mW_12 = 0;
current_mA_12 = ina219_12.getCurrent_mA();
// tft.textSetCursor(400, 260);tft.textColor(CYAN, RA8875_BLACK);tft.textEnlarge(2);tft.textEnlarge(1);tft.print(current_mA_12);
float current_mA_24V = 0;
current_mA_24V = ina219_24.getCurrent_mA();
float shuntvoltage_24 = 0;
float busvoltage_24 = 0;
float current_mA_24 = 0;
float loadvoltage_24 = 0;
float power_mW_24 = 0;
current_mA_24 = ina219_24.getCurrent_mA();
// tft.textSetCursor(400, 350);tft.textColor(CYAN, RA8875_BLACK);tft.textEnlarge(2);tft.textEnlarge(1);tft.print(current_mA_24);
delay(1000);
}
Thank you