I tried using the standard Serial but it didn’t work for me.
Below is code that I am using that does enable me to get GPS data but I need to find a way to parse the GPS data string for the Longitude and Latitude values. When I debug it with Serial.println() (not in example below this bit) it messes up the GPS data I can see in the debugging window.
Maarten, your gprmc_distance_to function is just what I need but I can’t get it to work 
// include the SoftwareSerial library
#include <SoftwareSerial.h>
// Constants
#define rxPin 9
#define txPin 8
// set up the serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
// variables
byte byteGPS = 0;
int i = 0;
int indices[13];
int cont = 0;
int conta = 0;
char inBuffer[300] = “”;
int k = 0;
void setup(){
//setup for mySerial port
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(4800);
//setup for Serial port
Serial.begin(19200);
// setup the GPS module
Serial.println(“Configurando GPS…”);
delay(1000);
mySerial.println("$PSTMNMEACONFIG,0,4800,1,1"); // configure NMEA sentences to show only GGA sentence
delay(100);
// command for setting time and position
mySerial.println("$PSTMINITGPS,4140.000,N,00053.000,W,0197,22,10,2007,11,40,00");
// “4140.000,N” means: Latitude 41º40’00.0" North
// “00053.000,W” means: Longitude 0º53’00.0" West
// “0197” means 197 m elevation
// “22,10,2007,11,40,00” means date and time (October 22, 2.007 - 11h 40min 00sec UTC time)
}
void loop(){
byteGPS = 0;
i = 0;
while(byteGPS != 42){ // read the GGA sentence
byteGPS = mySerial.read();
inBuffer[i]=byteGPS;
i++;
}
k = 1;
while(inBuffer[k] != 42){
Serial.print(inBuffer[k]); // write the GGA sentence
k++;
}
Serial.println();
delay(3000);
}
Thanks in advance for any help anyone can give me.
The gprmc_distance_to function does work on my Arduino. But without Software Serial.
I had also big problems getting the SoftSerial working. Go using the “AFSoftSerial” liabary and this code which does work
for my GPS:
See next post: