Go Down

Topic: How can I read Serial Data from Arduino in LabVIEW? (Read 1 time) previous topic - next topic

MihaelaP

May 29, 2020, 10:01 am Last Edit: May 31, 2020, 02:17 pm by MihaelaP
Hi!
I have an Arduino project in which I read the voltage and current with the Adafruit INA 219 sensor and I would like to get the values from Arduino to LabVIEW.
How can I read Serial Data from Arduino using LabVIEW Linx?

TheMemberFormerlyKnownAsAWOL

The Adafruit tutorial for the sensor has Arduino code.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

MihaelaP

I have the correct code for Arduino and it shows my values well but I need to take the values to LabVIEW. I tried with Linx but it doesn't work.

TheMemberFormerlyKnownAsAWOL

Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

finola_marsaili

#4
May 29, 2020, 11:55 am Last Edit: May 29, 2020, 11:56 am by finola_marsaili
What's labVIEW expecting? If you know that, describe it here, and perhaps someone could say "aha, to do <that> do <this>".

Right now, it's not clear what <that> is....

PS, what's an "Arduino file"?


ieee488

Hi!
I have an Arduino project in which I read the voltage and current with the Adafruit INA 219 sensor and I would like to get the values from Arduino to LabVIEW.
How can I do that?
Serial since the Arduino shows up as a com port on the PC.

The best way is to have the LabVIEW program continuously query the Arduino and the Arduino responds with the sensor's values.

All very easy to do.

.

MihaelaP

What's labVIEW expecting? If you know that, describe it here, and perhaps someone could say "aha, to do <that> do <this>".

Right now, it's not clear what <that> is....

PS, what's an "Arduino file"?


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 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: http://www.ti.com/lit/ds/symlink/ina219.pdf?ts=1590937044729 and my program here: https://imgur.com/nSi2IPr.

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?

Arduino code:
#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!");

 // 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).
 ina219.begin();
 // To use a slightly lower 32V, 1A range (higher precision on amps):
 //ina219.setCalibration_32V_1A();
 // Or to use a lower 16V, 400mA range (higher precision on volts and amps):
 //ina219.setCalibration_16V_400mA();

 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");
 Serial.println("");

 delay(500);
}

ieee488

Can you tell me how, please?

For reading the results from Adafruit INA 219 in Labview I make a program using 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: http://www.ti.com/lit/ds/symlink/ina219.pdf?ts=1590937044729 and my program here: https://imgur.com/nSi2IPr.
Can you see what is wrong here?
Sorry, not interested.

.

Go Up