Lithium ION
Published © GPL3+

Another Precision Wattmeter Module INA219

A small and easy to made project with Arduino. This project tell about voltage, current and power measuring.

IntermediateFull instructions provided1.5 hours841
Another Precision Wattmeter Module INA219

Things used in this project

Software apps and online services

PCBWAY
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

Gerber files

Schematics

circuit diagram

Code

Wattmeter code INA219

Arduino
#include <Wire.h>
#include "DFRobot_INA219.h"
#include <LiquidCrystal_I2C.h>
/**
   Change the position of slide switches according to the used address
 * @n INA219_I2C_ADDRESS1  0x40   A0 = 0  A1 = 0
 * @n INA219_I2C_ADDRESS2  0x41   A0 = 1  A1 = 0
 * @n INA219_I2C_ADDRESS3  0x44   A0 = 0  A1 = 1
 * @n INA219_I2C_ADDRESS4  0x45   A0 = 1  A1 = 1	 
 * These Four Address are available "check your using 12C scanner from Wire lib examples".
  */
  
DFRobot_INA219_IIC     ina219(&Wire, INA219_I2C_ADDRESS4);
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

// Revise the following two paramters according to actual reading of the INA219 and the multimeter
// for linearly calibration

float ina219Reading_mA = 1000;
float extMeterReading_mA = 1000;

void setup(void) 
{
    lcd.init();   // initialize the lcd 
    lcd.init();
    lcd.backlight();
    lcd.setCursor(3,0);
    lcd.print("Precision");
    lcd.setCursor(3,1);
    lcd.print("Wattmeter");
    delay(500);
    lcd.clear();
    
    Serial.begin(115200);
    //Open the serial port
    while(!Serial);
    
    Serial.println();
    //Initialize the sensor
    while(ina219.begin() != true) {
        Serial.println("INA219 begin failed");
        delay(2000);
    }
    //Linear calibration
    ina219.linearCalibrate(/*The measured current before calibration*/ina219Reading_mA, /*The current measured by other current testers*/extMeterReading_mA);
    Serial.println();
}

void loop(void)
{
    Serial.print("BusVoltage:   ");
    lcd.setCursor(0,0); // Voltage 
    lcd.print("V:");
    Serial.print(ina219.getBusVoltage_V(), 2);
    lcd.setCursor(2,0); // Voltage 
    lcd.print(ina219.getBusVoltage_V(), 2);
    Serial.println("V");
    
    Serial.print("ShuntVoltage: ");
    Serial.print(ina219.getShuntVoltage_mV(), 3);
    Serial.println("mV");
    
    Serial.print("I:");
    lcd.setCursor(8,0); // Current
    lcd.print("I:");
    Serial.print(ina219.getCurrent_mA(), 1);
    lcd.setCursor(10,0); // Voltage 
    lcd.print(ina219.getCurrent_mA(), 1);
    Serial.println("mA");
    
    Serial.print("Power:        ");
    lcd.setCursor(2,1); // Power
    lcd.print("Power:");
    Serial.print(ina219.getPower_mW(), 1);
    Serial.println("mW");
    Serial.println("");
    lcd.setCursor(8,1); // Power
    lcd.print(ina219.getPower_mW(),1);
    delay(1000);
}

Credits

Lithium ION

Lithium ION

50 projects • 33 followers
A passionate electronics DIY boy. Currently improving in Embedded systems, soldering and programming.

Comments