How to Use the INA780B Digital Power Monitor With Arduino

by Lopfi in Circuits > Arduino

36 Views, 0 Favorites, 0 Comments

How to Use the INA780B Digital Power Monitor With Arduino

Screenshot_2024-08-30_011019.png

The INA780B is a highly accurate digital power monitor from Texas Instruments, perfect for measuring bus voltage, shunt voltage, current, power, and temperature in high-current applications. In this guide, we'll walk you through how to use the INA780B with an Arduino to monitor these values, with the data being displayed on the Serial Monitor.


While working on a project that required measuring high currents at relatively high voltages, I wanted to avoid the hassle of building complicated circuits with ADCs, shunts, and voltage dividers. That’s when I discovered this nifty chip from Texas Instruments, the INA780B, which handles everything I needed and more—all in one package.

I'm also currently working on a development board for these chips, aiming to offer it at a price far below the $70 that TI charges. If you're interested, please let me know—I’m considering doing a small production run!

Supplies

  1. Arduino Board (e.g., Arduino Uno, Nano, or Mega)
  2. INA780B Module or breakout board
  3. Jumper wires
  4. Breadboard (optional)
  5. USB Cable for Arduino
  6. Computer with Arduino IDE installed

Wiring the INA780B to Your Arduino

First, let's connect the INA780B to your Arduino using the I2C interface.

  1. Connect VCC on the INA780B to 5V on the Arduino.
  2. Connect GND on the INA780B to GND on the Arduino.
  3. Connect SCL on the INA780B to A5 on the Arduino (for Uno).
  4. Connect SDA on the INA780B to A4 on the Arduino (for Uno).

If you're using a different Arduino board, make sure to check the corresponding SDA and SCL pins.

Install the INA780x Library

Before we can start coding, we need to install the INA780x library, which supports the entire INA780x family.

  1. Download the INA780x library from the GitHub repository.
  2. Open the Arduino IDE.
  3. Go to Sketch > Include Library > Add .ZIP Library....
  4. Select the downloaded .zip file to install the library.

Upload the Example Sketch

Let's get started with a basic example that reads and displays the bus voltage, current, power, and temperature.

#include <Wire.h>
#include <INA780x.h>

INA780x powerMonitor(0x44); // Replace 0x44 with the correct I2C address

void setup() {
Serial.begin(9600);
powerMonitor.begin();
if (powerMonitor.isConnected()) {
Serial.println("INA780x found and connected!");
delay(500);
} else {
Serial.println("INA780x not found!");
while (1); // Halt the program if the chip is not found
}

powerMonitor.reset();
// Configure ADC (example configuration)
//powerMonitor.setADCConfig(0x4120);
}

void loop() {
float busVoltage = powerMonitor.getBusVoltage();
float current = powerMonitor.getCurrent();
double power = powerMonitor.getPower();
double energy = powerMonitor.getEnergy();
float temperature = powerMonitor.getTemperature();
double charge = powerMonitor.getCharge();
uint16_t diagAlert = powerMonitor.getDiagAlert();

Serial.print("Bus Voltage: ");
Serial.print(busVoltage);
Serial.println(" V");
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
Serial.print("Power: ");
Serial.print(power);
Serial.println(" W");
Serial.print("Energy: ");
Serial.print(energy);
Serial.println(" J");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Charge: ");
Serial.print(charge);
Serial.println(" As");
Serial.print("Diag Alert: ");
Serial.println(diagAlert, BIN);
Serial.println("--------------------");

delay(2000);
}


Upload the Sketch

  1. Open the Arduino IDE and paste the code into a new sketch.
  2. Select the correct board and port from the Tools menu.
  3. Click the upload button to upload the sketch to your Arduino.

View the Data on the Serial Monitor

Once the sketch is uploaded, open the Serial Monitor (Tools > Serial Monitor) to see real-time data from the INA780B. You should see readings for the bus voltage, shunt voltage, current, power, and temperature, updating every second.

Conclusion

Congratulations! You’ve successfully set up the INA780B with an Arduino and are now able to monitor critical electrical parameters in your project. Whether you're working on a battery management system, power supply monitoring, or any high-current application, the INA780B offers precision and reliability.

If you have any questions or run into issues, feel free to comment below. Happy making!

Additional Resources

  1. INA780B Datasheet
  2. INA780x Arduino Library GitHub Repository