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 to read the sensor's values in LabVIEW or to send the results from the Arduino to Labview.
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);
}
Currently your values are being read by the Arduino and sent as strings to the Serial port.
If you want to use that format to communicate with LabVIEW, then you don't need to use the LINX toolkit - you can just use the Serial port via the VISA nodes.
You'd then need to convert the strings to numeric values to be able to do something 'useful' with them probably. You could try using something like Match Pattern or Match Regular Expression.
Something like this is probably what you're looking for:
As an aside, although I like StackOverflow in general, for LabVIEW related questions you'll probably get a faster response on forums.ni.com (and less likely to be closed as discussion-related, or duplicate).