Showing results for 
Search instead for 
Did you mean: 

Read Adafruit INA 219 in LabVIEW with Linx and I2C library.

Go to solution

I try to read voltage and current from an Adafruit INA 219 sensor with Arduino and I get the correct results. The problem is that I need the results for analyzing them and I need  (1) to read the sensor's values in LabVIEW or (2) to send the results from the Arduino to Labview.

1) For reading the results from Adafruit INA 219 in Labview I make a program using the I2C library and Linx but I don't receive the correct values. I don't think that the program is good and I don't understand the I2C communication type. The datasheet of INA 219 is here: and my program here:

2) I think that another method for getting the results in LabVIEW is to send the results from Arduino (which gives the correct results) to LabVIEW.

Can someone help me, please?


My Arduino code: 

#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;

void setup(void) 
  while (!Serial) {
      // will pause Zero, Leonardo, etc until serial console opens

  uint32_t currentFrequency;


  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  // you can call a setCalibration function to change this range (see comments).
  // To use a slightly lower 32V, 1A range (higher precision on amps):
  // Or to use a lower 16V, 400mA range (higher precision on volts and amps):

  Serial.println("Measuring voltage and current with INA219 ...");

void loop(void) 
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  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");



0 Kudos
Message 1 of 3

These are the results received by the current program and I don't understand the resultant string. The values are larger and without variations compared to the values provided by Arduino: 5...5.2 V, 5...5.2 V and 1.7...2.1 mA (for testing values 5V and 2A).   




0 Kudos
Message 2 of 3
Accepted by MihaelaP

Quickest way forget LINX and just use the Arduino code you have and VISA to read the values sent from the Arduino


Here's a couple hints...

  1. Use PrintLn and send all of your data in one line separated by commas (34.4,45,34,)
  2. PrintLn adds a CR or LF to the end, use that as the "Termination Character" in VISA serial setup.
  3. Set VISA read to read more bytes than you expect to receive.
  4. VISA read will then wait until the termination or times out.
  5. Parse the received string using "spreadsheet string to array" and you will have a nice array of numeric values.
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 3 of 3