INA219 MODULE FOR POWER MEASUREMENT

power meas

#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); // Calculate the Power

Serial.print(“Bus Voltage: “);

Serial.print(busVoltage);

Serial.print(” V “);

Serial.print(“Current: “);

Serial.print(current);

Serial.print(” mA “);

Serial.print(“Power: “);

Serial.print(power);

Serial.println(” mW”);

//Serial.println(“”);

delay(1000);

}

———————-OTHER SKET—————————-

#include <Wire.h>

#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;

void setup()

{

uint32_t currentFrequency;

Serial.begin(9600);

Serial.println(“Hello!”);

Serial.println(“Measuring voltage and current with INA219 …”);

ina219.begin();

pinMode(2,OUTPUT);

}

void loop()

{

digitalWrite(2,HIGH);

float shuntvoltage = 0;

float busvoltage = 0;

float current_mA = 0;

float loadvoltage = 0;

float power = 0;

shuntvoltage = ina219.getShuntVoltage_mV();

busvoltage = ina219.getBusVoltage_V();

current_mA = ina219.getCurrent_mA();

loadvoltage = busvoltage + (shuntvoltage / 1000);

power = current_mA * loadvoltage;

Serial.print(“Bus Voltage: “);

Serial.print(busvoltage);

Serial.print(” V “);

Serial.print(“Shunt Voltage: “);

Serial.print(shuntvoltage);

Serial.print(” mV “);

Serial.print(“Load Voltage: “);

Serial.print(loadvoltage);

Serial.print(” V “);

Serial.print(“Current: “);

Serial.print(current_mA);

Serial.print(” mA “);

Serial.print(“Power: “);

Serial.print(power);

Serial.print(” mW”);

Serial.println(“”);

delay(1000);

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s