Hello everybody
I have problem with my project: i’m using INA219 to measure current, voltage and battery consumption, i connect INA219 with arduino and open Serial monitor, but the result not true. i uploaded image and my code. Please help me !!!
#include <INA219.h>
#include <Wire.h>
#include <Adafruit_INA219.h> // You will need to download this library
Adafruit_INA219 sensor219; // Declare and instance of INA219
void setup(void)
{
Serial.begin(9600);
sensor219.begin();
}
void loop(void)
{
float busVoltage = 0;
float current = 0; // Measure in milli amps
float power = 0;
busVoltage = sensor219.getBusVoltage_V();
current = sensor219.getCurrent_mA();
power = busVoltage * (current/1000); // Calculate the Power
Serial.print("Bus Voltage: ");
Serial.print(busVoltage);
Serial.println(" V");
Serial.print("Current: ");
Serial.print(current);
Serial.println(" mA");
Serial.print("Power: ");
Serial.print(power);
Serial.println(" W");
Serial.println("");
delay(2000);
}