Interfacing INA219 Current Sensor Module with Arduino

Table of Contents

INA219 Current Sensor Module Features

The INA219 module is used to measure both current and voltage at the same time. This module uses I2C communication to transfer the voltage and current data.

Other features:

  • Measurement accuracy: 1%
  • Maximum measured voltage: 26V
  • Maximum measured current: 3.2A.
Note

Pay attention to inductive loads switching. Its instantaneous voltages may damage the circuit.

Download the Datasheet of this sensor here.

INA219 Current Sensor Module Pinout

This Module has 6 pins:

  • VCC: Module power supply
  • GND: Ground
  • SDA: I2C Data
  • SCL: I2C Clock
  • Vin-: Load terminal pin
  • Vin+: Source terminal pin

You can see the pinout of this module in the image below.

Required Material

Hardware component

Arduino UNO R3 × 1
INA219 DC CURRENT SENSOR × 1
Male to Male jumper wire × 1
SYB-170 Mini Small Bread Board × 1

Software Apps

Arduino IDE
Note

Apart from the components above, you also need an LED and a 220ohm resistor for this tutorial.

Interfacing INA219 Current Sensor Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to INA219 sensor. Connect wires accordingly.

Note

The orange wire (3.3 volts) is called the Bus voltage and the blue wire is called the Load voltage.

Shunt voltage is the potential difference between the Load voltage and the Bus voltage.

Step 2: Library

Go to Library manager, search for INA219 and install the Adafruit INA219 library.

Note

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to Arduino.

 /*
  DC-Current-Voltage-Sensor-Module
  made on 06 Feb 2021
  
Home
based on Adafruit Example */ #include <Wire.h> #include <Adafruit_INA219.h> Adafruit_INA219 ina219; void setup(void) { Serial.begin(115200); while (!Serial) { // will pause Zero, Leonardo, etc until serial console opens delay(1); } uint32_t currentFrequency; Serial.println("Hello!"); if (! ina219.begin()) { Serial.println("Failed to find INA219 chip"); while (1) { delay(10); } } Serial.println("Measuring voltage and current with INA219 ..."); } void loop(void) { float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; float loadvoltage = 0; float power_mW = 0; shuntvoltage = ina219.getShuntVoltage_mV(); busvoltage = ina219.getBusVoltage_V(); current_mA = ina219.getCurrent_mA(); power_mW = ina219.getPower_mW(); loadvoltage = busvoltage + (shuntvoltage / 1000); 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(""); delay(2000); }

This code is for measuring both voltage and current. We want to find the source voltage and the voltage and current of the load. The source voltage is 3.3V and the load voltage is actually the LED voltage. The current passing through LED is also calculated using the shunt voltage. The shunt resistance creates a very small potential difference called the shunt voltage.

These parameters will be displayed on the Serial Monitor: Bus, Shunt and Load voltage, current and power:

Liked What you see?

Get updates and learn from the best

More To Explore

Comments (2)

  • Rob Davidowitz Reply

    I have followed your instruction to the letter and get the following error message
    Failed to find INA219 chip”

    June 20, 2022 at 2:49 pm
    • Mehran Maleki Reply

      Hi.
      First check the wiring to make sure all pins are correctly connected to each other. Especially SDA and SCL which must be connected to pins A4 and A5 respectively. If those 2 pins are not properly connected you might get an error like the one you’ve got now. Also, you can use the i2c_scanner in Arduino IDE File -> Examples -> Wire -> i2c_scanner to see if any I2C devices are found. If you still get no I2C scanner, there might be something wrong with the INA219 module itself.

      July 10, 2022 at 11:27 am

Leave a Reply

Your email address will not be published. Required fields are marked *