From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic Labview VI to read continuous GPS data from Arduino?

Hello,

 

I currently have an Arduino Uno with a Sparkfun GP-20U7 GPS Receiver, running the program provided below. I was wondering if anyone could provide a basic Labview VI that could read and display the GPS data in real-time, similar to this (https://github.com/rrichards7/GPS-Control)?

#include <SoftwareSerial.h>

SoftwareSerial soft(10, 11); // Rx, Tx

// Globals
String utc = ""; // hhmmss.00
String lat = ""; // DDMM.MMMM N/S
String lon = ""; // DDMM.MMMM E/W
String alt = ""; // x meters

void setup() {
Serial.begin(9600);
soft.begin(9600);
}

void loop() {

// Poll GPS for data
getGPS();

// Print out time and the 'tudes
Serial.print("Time: ");
Serial.println(utc);
Serial.print("Latitude: ");
Serial.println(lat);
Serial.print("Longitude: ");
Serial.println(lon);
Serial.print("Altitude: ");
Serial.println(alt);
Serial.println();
}

void getGPS() {

int index;

// Look for $GPGGA
if ( soft.find("$GPGGA,") ) {

// Parse message for time and position
utc = soft.readStringUntil(',');
lat = soft.readStringUntil(',');
lat.concat(soft.readStringUntil(','));
lon = soft.readStringUntil(',');
lon.concat(soft.readStringUntil(','));

// Flush data up until altitude
for ( int i = 0; i < 3; i++ ) {
soft.readStringUntil(',');
}

// Parse altitude data
alt = soft.readStringUntil(',');
alt.concat(soft.readStringUntil(','));

// Flush rest of message
soft.readStringUntil('\r');
}
}

 

0 Kudos
Message 1 of 2
(2,347 Views)

If that GPS follows the NMEA standards then it will be constantly sending out NMEA "Sentences" that are pure ASCII text (strings). You don't poll a GPS for information it is always talking.

 

The first "word" tells you what that sentence contains. 

 

So read the first word in the string as it arrives and if it contains information you want then parse the rest of the string, if not then ignore the rest.

 

Here is a good website on decoding the NMEA Sentences to get you started

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 2
(2,305 Views)