#include "Wire.h" // try if it is a INA219 #include Adafruit_INA219 ina219(0x40); // default 0x40 (0x41)... // and that uses wire.h float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; float loadvoltage = 0; float power_mW = 0; void setup() { delay(500); Serial.begin(115200); delay(500); while ( !Serial ); Wire.begin(); Serial.println(); Serial.println("___ WIRE TEST with default pin "); if (! ina219.begin()) { Serial.println("Failed to find INA219 chip"); } else { Serial.println("Measuring voltage, current, and power with INA219 board"); } } void loop() { byte error, address; int nDevices = 0; delay(5000); Serial.println(); Serial.println("Arduino IDE 2.3.4 test I2C linked devices on pin: "); Serial.print("SDA :"); Serial.println(SDA); Serial.print("SCL :"); Serial.println(SCL); Serial.println("Scanning for I2C devices ..."); for (address = 0x01; address < 0x7f; address++) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.printf("I2C device found at address 0x%02X\n", address); nDevices++; if_found(); } else if (error != 2) { Serial.printf("Error %d at address 0x%02X\n", error, address); } } if (nDevices == 0) { Serial.println("No I2C devices found"); } } void if_found() { Serial.println("??? if it is a INA219 try it: "); shuntvoltage = ina219.getShuntVoltage_mV(); busvoltage = ina219.getBusVoltage_V(); current_mA = ina219.getCurrent_mA(); //power_mW = ina219.getPower_mW(); loadvoltage = busvoltage + (shuntvoltage / 1000); power_mW = loadvoltage * current_mA; // calc NOT measure if ( true ) { 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(""); } } /* _____________________________________________________________________________ for ESP32S3 see: ___ WIRE TEST with default pin Measuring voltage, current, and power with INA219 board Arduino IDE 2.3.4 test I2C linked devices on pin: SDA :8 SCL :9 Scanning for I2C devices ... I2C device found at address 0x40 ??? if it is a INA219 try it: Bus Voltage: 0.88 V Shunt Voltage: -0.05 mV Load Voltage: 0.88 V Current: -0.20 mA _____________________________________________________________________________ for PICO W see: __ WIRE TEST with default pin Measuring voltage, current, and power with INA219 board Arduino IDE 2.3.4 test I2C linked devices on pin: SDA :4 SCL :5 Scanning for I2C devices ... I2C device found at address 0x40 ??? if it is a INA219 try it: Bus Voltage: 0.89 V Shunt Voltage: -0.04 mV Load Voltage: 0.89 V Current: -0.20 mA _____________________________________________________________________________ */