Problem with Gps Neo and SIM 800L

Hi everybody
I´ve this problem. Im working with GPS Neo and sim800l . My idea is that when I enter a letter in serial monitor it show me the latitude and longitude from my GPS , (but only when i press the key ) and after this I take this data and send it with the SIM800l to a cellphone. I dont get that my program receive the data from the GPS neo when i press in this case the letter 'R'. Can you help me. Thank you :slight_smile:

#include <SoftwareSerial.h>
SoftwareSerial sim800(7,8);
SoftwareSerial GPS(9,10);
 char sms1=0;
String entradaGPS="";
String coordenadas ="";
String signal="$GPGLL";

void setup() {
 
  sim800.begin(9600);
  GPS.begin(9600);
  Serial.begin(115200);
  Serial.println("Inicitializing");
}

void loop() {
 

  if (Serial.available() > 0) {
    char sms1 = Serial.read();
    Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R') {
      

     GPS.listen();
      while (GPS.available() > 0) {
      coordenadas = GPS.read();
        String entradaGPS = coordenadas.substring(0, 6);
        if (entradaGPS == signal) {
            String LAT = entradaGPS.substring(7, 17);
            int LATPUNTO = LAT.indexOf('.');
            int LATCERO = LAT.indexOf('0');
            if (LATCERO == 0) {
                LAT = LAT.substring(1);
            }

            String LON = entradaGPS.substring(20, 31);
            int LONPUNTO = LON.indexOf('.');
            int LONTCERO = LON.indexOf('0');
            if (LONTCERO == 0) {
                LON = LON.substring(1);
            }

            Serial.println(LAT);
            Serial.println(LON);
       
           /* String maps ="https://maps.google.com/maps?q=";
            String ubicacion= maps + LAT+ "+" + LON;
            Serial.println(ubicacion);
            sim800.println("AT+CMGF=1");
            
            delay(5000);
           // sim800.print("AT+CMGS=\"+TELEPHONENUMBER\"");
         
            delay(5000);
            
            //sim800.println(ubicacion);
            delay(1000);*/

I dont get that my program receive the data from the GPS neo when i press in this case the letter 'R'.

You mean that you don't get data when you press 'R'?

As far as I know, GPS.read returns a character, not a String. I suggest that you print to serial monitor first what you receive from the GPS.

Something like

void loop() {


  if (Serial.available() > 0)
  {
    char sms1 = Serial.read();
    Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R')
    {
      GPS.listen();
      while (GPS.available() > 0)
      {
        Serial.print("Received: ");
        Serial.write(GPS.read();
        Serial.println();
      }
    }
  }
}

Not tested.

Note 1)
Your sketch is incomplete. Please post complete sketch or trimmed down version that exhibits the behaviour.
Note 2)
Don't use String (capital S); one day it will bite you due to memory issues.

Sterretje , thank you for your help.

Well I test this code and I got this (IMAGE1):

//variables  GLOBALES

#include <SoftwareSerial.h>
//SoftwareSerial sim800(7,8);
SoftwareSerial GPS(9,10);
 char sms1=0;



void setup() {
 
 
  GPS.begin(9600);
  Serial.begin(9600);
  Serial.println("Iniciando...");


  }

void loop() {



  if (Serial.available() > 0)
  {
    char sms1 = Serial.read();
    Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R')
    {
      GPS.listen();
      while (GPS.available() > 0)
      {
        Serial.print("Received: ");
        Serial.write(GPS.read());
        Serial.println();
      }
    }}}

After this I found a TinyGps++ library that gives you the latitude and longitud directly , without all the prevous code , I tested it and i got it this . (iImage2) :smiley:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial ss(9,10);
TinyGPSPlus gps;
void setup() {
  // put your setup code here, to run once:

    Serial.begin(9600);
  ss.begin(9600);


}

void loop() {


  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}
///

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);

    String link = "www.google.com/maps/place/" + String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6) ;
    Serial.println(link);
    Serial.println();
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

but when I added the part of receive the letter by serial it doesnt works (imagenarduino3) :confused: :confused:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial ss(9,10);
TinyGPSPlus gps;
void setup() {
  // put your setup code here, to run once:

    Serial.begin(9600);
  ss.begin(9600);


}

void loop() {
if (Serial.available() > 0)
  {
    char sms1 = Serial.read();
    Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R')
    {
      ss.listen();
      Serial.write(ss.read());
  // put your main code here, to run repeatedly:



  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}
  }}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);

    String link = "www.google.com/maps/place/" + String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6) ;
    Serial.println(link);
    Serial.println();
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

Thank you!

iIMAGE2.png

imagenarduino3.png

Compare

  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

with

      ss.listen();
      Serial.write(ss.read());
      // put your main code here, to run repeatedly:



      while (ss.available() > 0)
        if (gps.encode(ss.read()))
          displayInfo();

In the second part:
1)
You do an additional ss.read() before the while; this will take a character out of the GPS and next the gps.encode() function might not understand what it is getting. Take Serial.write(ss.read()); out and test again.
2)
You do a ss.listen() which might interfere; I suggest that you temporarily disable that if (1) on its own does not help.

PS
Please do not post screenshots of the text; you can copy from the serial monitor and paste here using code tags.

sterretje Thanks it worked .I removed the lines that you tell me

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial ss(9,10);
TinyGPSPlus gps;
void setup() {
  // put your setup code here, to run once:

    Serial.begin(9600);
  ss.begin(9600);


}
void loop() {
if (Serial.available() > 0)
  {
    char sms1 = Serial.read();
   // Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R')
    {
     // ss.listen();
     // Serial.write(ss.read());
  // put your main code here, to run repeatedly:



  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}
  }}

void displayInfo()
{
  Serial.print(F("Location: "));
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
    Serial.println();

    String link = "www.google.com/maps/place/" + String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6) ;
    Serial.println(link);
    Serial.println(); 

    delay(2000);
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

Now the problem is that when i press R sometimes show me the lat and long , but in other dont show me nothing, I think that is something about the speed of transmision or something like that :

Location: 16.279113,-99.206916
www.google.com/maps/place/16.279114,-99.206917




R //NOTHING HAPPENS


R //NOTHING HAPPENS


R  //NOTHING HAPPENS


R //NOTHING HAPPENS


R//NOTHING HAPPENS


R IT WORK
Location: 16.279129,-99.206901
www.google.com/maps/place/16.279129,-99.206902




R

Thank you

That I can't really help you with; I don't have your setup and no experience with TinyGPS.

Does the code that I gave in reply #1 always work; every time you issue a 'R' you get data?

Below a slightly modified version of the code that I gave you in reply #1. Please run it using a couple of 'R's and post the result (as text); I will see if I can find some time tomorrow.

//variables  GLOBALES

#include <SoftwareSerial.h>
//SoftwareSerial sim800(7,8);
SoftwareSerial GPS(9, 10);
char sms1 = 0;

void setup()
{

  GPS.begin(9600);
  Serial.begin(9600);
  Serial.println("Iniciando...");

}

void loop()
{
  if (Serial.available() > 0)
  {
    char sms1 = Serial.read();
    Serial.println("a new character was type\n");
    Serial.println(sms1);
    if (sms1 == 'R')
    {
      Serial.print("<<");
      while (GPS.available() > 0)
      {
        Serial.print("Received: ");
        Serial.write(GPS.read());
      }
      Serial.println(">>");
    }
  }
}

Sure sterretje!

I test the code an I got this

ceiv: 1Received: 6Received: .Received: 7Received: 5Received: 8Received: 7Received: 0Received: ,Received: NReceived: ,Received: ⸮⸮⸮⸮⸮⸮a new character was type

R
<<Received: )Received: ⸮Received: bReceived: ⸮Received: ⸮Received: bReceived: ⸮Received: ⸮Received: bReceived: ⸮Received: ⸮Received: bReceived: ⸮Received: ⸮Received: bReceived: bReceived: bReceived: bReceived: bReceived: bReceived: bReceived: bReceived: ⸮Received: rReceived: ⸮Received: ⸮Received: bReceived: ⸮Received: rReceived: ⸮Received: ⸮Received: bReceived: ⸮Received: rReceived: ⸮Received: ⸮Received: RReceived: ⸮Received: "Received: 5Received: 
Received: $Received: GReceived: PReceived: GReceived: SReceived: VReceived: ,Received: 2Received: ,Received: 1Received: ,Received: 0Received: 8Received: ,Received: 0Received: 5Received: ,Received: 3Received: 2Received: ,Received: 0Received: 3Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 4Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 1Received: 0Received: 6Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 7Received: 8Received: 5Received: ,Received: 0Received: 2Received: $Received: MReceived: .Received: 
Received: 3Received: 6Received: 9Received: WReceived: ,Received: 7Received: $Received: 1Received: ,Received: ,Received: 0Received: 3Received: 0Received: 2Received: 1Received: ,Received: 
Received: 2Received: 3Received: 2Received: ,Received: 2Received: 7Received: 3Received: 1Received: 
Received: 1Received: 0Received: ,Received: 0Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 5Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 1Received: 3Received: 1Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 7Received: 0Received: 3Received: ,Received: WReceived: ,Received: 0Received: .Received: 6Received: 0Received: 9Received: ,Received: 1Received: 6Received: TReceived: NReceived: *Received: ,Received: 1Received: NReceived: 0Received: .Received: MReceived: 6Received: AReceived: 2Received: 2Received: 0Received: SReceived: 2Received: 5Received: 2Received: ,Received: 1Received: SReceived: 8Received: ,Received: 2Received: 3Received: 1Received: PReceived: ,Received: 1Received: LReceived: 3Received: 3Received: 0Received: 7Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 6Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 1Received: 5Received: 6Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 6Received: 4Received: 4Received: ,Received: WReceived: ,Received: 0Received: .Received: 4Received: 7Received: 9Received: ,Received: AReceived: GReceived: 7Received: KReceived: GReceived: 0Received: 5Received: 3Received: 3Received: .Received: ,Received: SReceived: 0Received: ,Received: 9Received: $Received: 0Received: 1Received: 2Received: 2Received: 0Received: $Received: 0Received: 3Received: 2Received: 0Received: ,Received: 
Received: 3Received: 2Received: $Received: .Received: 9Received: ,Received: AReceived: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 7Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 1Received: 5Received: 3Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 6Received: 3Received: 3Received: ,Received: WReceived: ,Received: 0Received: .Received: 7Received: 3Received: 1Received: ,Received: 0Received: PReceived: 0Received: 5Received: $Received: 4Received: 7Received: 1Received: 1Received: 1Received: 6Received: GReceived: 8Received: ,Received: 2Received: AReceived: ,Received: ,Received: ,Received: ,Received: 4Received: DReceived: ,Received: ,Received: 2Received: 1Received: ,Received: *Received: ,Received: 4Received: 7Received: 9Received: ,Received: 3Received: 0Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 8Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 1Received: 6Received: 3Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 5Received: 9Received: 3Received: ,Received: WReceived: ,Received: 0Received: .Received: 7Received: 5Received: 4Received: ,Received: 4Received: 
Received: ,Received: 1Received: 9Received: 3Received: 1Received: 0Received: ,Received: 9Received: -Received: 
Received: 2Received: ,Received: 8Received: 0Received: VReceived: ,Received: ,Received: ,Received: 1Received: 3Received: VReceived: ,Received: 2Received: 4Received: ,Received: 7Received: GReceived: 2Received: 8Received: LReceived: 3Received: 5Received: 4Received: 7Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 4Received: 9Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 2Received: 6Received: 5Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 3Received: 9Received: 0Received: ,Received: WReceived: ,Received: 2Received: .Received: 6Received: 1Received: 8Received: ,Received: AReceived: GReceived: 1Received: KReceived: GReceived: 0Received: 6Received: 3Received: 4Received: .Received: ,Received: SReceived: 0Received: ,Received: .Received: 
Received: ,Received: 7Received: 3Received: 9Received: ,Received: 
Received: ,Received: 1Received: ,Received: 2Received: 4Received: 9Received: ,Received: ,Received: 
Received: 6Received: 9Received: WReceived: ,Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 5Received: 0Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 2Received: 9Received: 9Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 3Received: 8Received: 2Received: ,Received: WReceived: ,Received: 1Received: .Received: 6Received: 6Received: 1Received: ,Received: ,Received: TReceived: 6Received: ,Received: PReceived: .Received: 2Received: .Received: 0Received: 7Received: MReceived: GReceived: 2Received: ,Received: 2Received: 8Received: ,Received: ,Received: ,Received: ,Received: 4Received: CReceived: ,Received: ,Received: 2Received: 1Received: ,Received: *Received: ,Received: 4Received: 8Received: 9Received: ,Received: 2Received: 0Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 5Received: 1Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 3Received: 3Received: 3Received: ,Received: NReceived: ,Received: 0Received: 9Received: 9Received: 1Received: 2Received: .Received: 3Received: 5Received: 2Received: 9Received: 4Received: ,Received: WReceived: ,Received: 1Received: .Received: 3Received: 9Received: 0Received: ,Received: 1Received: 6Received: ,Received: ,Received: AReceived: AReceived: ,Received: ,Received: 2Received: 2Received: ,Received: *Received: ,Received: 1Received: ,Received: 9Received: $Received: 0Received: 1Received: 2Received: 2Received: 0Received: $Received: 0Received: 3Received: 2Received: 0Received: ,Received: 
Received: ,Received: 3Received: GReceived: 7Received: 1Received: 0Received: ,Received: $Received: GReceived: PReceived: RReceived: MReceived: CReceived: ,Received: 0Received: 3Received: 3Received: 0Received: 5Received: 2Received: .Received: 0Received: 0Received: ,Received: AReceived: ,Received: 1Received: 9Received: 1Received: 6Received: .Received: 7Received: 6Received: 3Received: 7Received: 0Received: ,Received: NReceived: ,Received:d:

I only press one time 'R'
and the data is coming continuosly
Thank you for your help!

Your output shows that you received 3 messages

I suspect that the the Arduino is faster than what the GPS spits out. Reason is that I would have expected a newline before the '>>' on the last output.

Below code is a modified version of example 3 of Robin's updated Serial Input Basics thread. It reads from SoftwareSerial instead of Serial and the buffer size is bigger. The showNewData was significantly modified.

It will read a full message from '$' (start marker) till '\n' (end marker); it will also keep the markers in the message (this differs from Robin's code) so TinyGPS can process them correctly.

#include <SoftwareSerial.h>
//SoftwareSerial sim800(7,8);
SoftwareSerial GPS(9, 10);

// sterretje: bigger buffer
const byte numChars = 128;
// sterretje end
char receivedChars[numChars];

boolean newData = false;

void setup()
{
  Serial.begin(115200);
  GPS.begin(9600);
  Serial.println("<Arduino is ready>");
}

void loop()
{
  //sterretje: use new function name
  gpsReceive();
  //recvWithStartEndMarkers();
  // sterretje end
  showNewData();
}

// sterretje: rename function
void gpsReceive()
//void recvWithStartEndMarkers()
// sterretje end
{
  static boolean recvInProgress = false;
  static byte ndx = 0;
  // sterretje: start and end marker adjusted
  char startMarker = '

Note that I've increased the Serial speed for the PC (you will need to adjust serial monitor) so it will not block as much; you can play with that and might have to increase it more.

Please post the output that you get (one or two 'R'). It should be a line of text followed by a line of hex numbers for each message.

I will try some things out using a simulation and adding TinyGPS in the mix as well; that's for later today.

Example output:

<Arduino is ready>
<<$GPRMC,045103.000,A,3014.1984,N,09749.2872,W,0.67,161.46,030913,,,A*7C
>>
HEX data
24 47 50 52 4D 43 2C 30 34 35 31 30 33 2E 30 30 30 2C 41 2C 33 30 31 34 2E 31 39 38 34 2C 4E 2C 30 39 37 34 39 2E 32 38 37 32 2C 57 2C 30 2E 36 37 2C 31 36 31 2E 34 36 2C 30 33 30 39 31 33 2C 2C 2C 41 2A 37 43 0D 0A

;
 char endMarker = '\n';
 // sterretje end
 char rc;

while (GPS.available() > 0 && newData == false)
 {
   rc = GPS.read();

if (recvInProgress == true)
   {
     if (rc != endMarker)
     {
       receivedChars[ndx] = rc;
       ndx++;
       if (ndx >= numChars)
       {
         ndx = numChars - 1;
       }
     }
     else
     {
       // sterretje: include end marker in received message
       receivedChars[ndx] = rc;
       ndx++;
       // sterretje end

receivedChars[ndx] = '\0'; // terminate the string
       recvInProgress = false;
       ndx = 0;
       newData = true;
     }
   }

else if (rc == startMarker)
   {
     // sterretje: include start marker in received message
     receivedChars[ndx] = rc;
     ndx++;
     // sterretje end

recvInProgress = true;
   }
 }
}

void showNewData()
{
 if (newData == true)
 {
   Serial.print(F("<<"));
   Serial.print(receivedChars);
   Serial.println(F(">>"));
   Serial.println(F("HEX data"));
   for (uint8_t cnt = 0; cnt < strlen(receivedChars); cnt++)
   {
     if (receivedChars[cnt] < 0x10)
     {
       Serial.print(F("0"));
     }
     Serial.print(receivedChars[cnt], HEX);
     Serial.print(F(" "));
   }
   Serial.println();
   newData = false;
 }
}


Note that I've increased the Serial speed for the PC (you will need to adjust serial monitor) so it will not block as much; you can play with that and might have to increase it more.

Please post the output that you get (one or two 'R'). It should be a line of text followed by a line of hex numbers for each message.

I will try some things out using a simulation and adding TinyGPS in the mix as well; that's for later today.

Example output:

§DISCOURSE_HOISTED_CODE_1§

I've integrated the TinyGPS in the previous code. For testing, I replaced gpsSerial by Serial and used the example NMEA sequences from the BasicExample.ino that comes with the library.

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
SoftwareSerial gpsSerial(9, 10);

TinyGPSPlus gps;


// sterretje: bigger buffer
const byte numChars = 128;
// sterretje end
char receivedChars[numChars];

boolean newData = false;

void setup()
{
  Serial.begin(115200);
  gpsSerial.begin(9600);
  Serial.println("<Arduino is ready>");
}

void loop()
{
  //sterretje: use new function name
  gpsReceive();
  //recvWithStartEndMarkers();
  // sterretje end
  showNewData();
}

// sterretje: rename function
void gpsReceive()
//void recvWithStartEndMarkers()
// sterretje end
{
  static boolean recvInProgress = false;
  static byte ndx = 0;
  // sterretje: start and end marker adjusted
  char startMarker = '

For $GPRMC,045251.000,A,3014.4275,N,09749.0626,W,0.51,217.94,030913,,,A*7D the result is

<<$GPRMC,045251.000,A,3014.4275,N,09749.0626,W,0.51,217.94,030913,,,A*7D
>>
HEX data
24 47 50 52 4D 43 2C 30 34 35 32 35 31 2E 30 30 30 2C 41 2C 33 30 31 34 2E 34 32 37 35 2C 4E 2C 30 39 37 34 39 2E 30 36 32 36 2C 57 2C 30 2E 35 31 2C 32 31 37 2E 39 34 2C 30 33 30 39 31 33 2C 2C 2C 41 2A 37 44 0D 0A 
GPS data: 
Location: 30.240457,-97.817710  Date/Time: 9/3/2013 04:52:51.00
================

For $GPGGA,045252.000,3014.4273,N,09749.0628,W,1,09,1.3,206.9,M,-22.5,M,,0000*6F I get an invalid date (at occasion?)

<<$GPGGA,045252.000,3014.4273,N,09749.0628,W,1,09,1.3,206.9,M,-22.5,M,,0000*6F
>>
HEX data
24 47 50 47 47 41 2C 30 34 35 32 35 32 2E 30 30 30 2C 33 30 31 34 2E 34 32 37 33 2C 4E 2C 30 39 37 34 39 2E 30 36 32 38 2C 57 2C 31 2C 30 39 2C 31 2E 33 2C 32 30 36 2E 39 2C 4D 2C 2D 32 32 2E 35 2C 4D 2C 2C 30 30 30 30 2A 36 46 0D 0A 
GPS data: 
Location: 30.240455,-97.817710  Date/Time: INVALID 04:52:52.00
================

I suspect a bug in the library but it might be expected behaviour; the BasicExample.ino code displays a date for every sequence but the GPGGA sequences in the example are missing a date field (which I think should be there). I verified this behaviour by changing the sequence so it starts with a GPGGA; the result for the first sequence now also shows an invalid date.

Original:

BasicExample.ino
Basic demonstration of TinyGPS++ (no device needed)
Testing TinyGPS++ library v. 1.0.2
by Mikal Hart

Location: 30.236640,-97.821456  Date/Time: 9/3/2013 04:51:03.00
Location: 30.236640,-97.821456  Date/Time: 9/3/2013 04:51:04.00
Location: 30.239700,-97.815856  Date/Time: 9/3/2013 04:52:00.00
Location: 30.239772,-97.815681  Date/Time: 9/3/2013 04:52:01.00
Location: 30.240457,-97.817710  Date/Time: 9/3/2013 04:52:51.00
Location: 30.240455,-97.817710  Date/Time: 9/3/2013 04:52:52.00

Done.

Modified (so a GPGGA sequence is the first):

BasicExample.ino
Basic demonstration of TinyGPS++ (no device needed)
Testing TinyGPS++ library v. 1.0.2
by Mikal Hart

Location: 30.236640,-97.821456  Date/Time: INVALID 04:51:04.00
Location: 30.239700,-97.815856  Date/Time: 9/3/2013 04:52:00.00
Location: 30.239772,-97.815681  Date/Time: 9/3/2013 04:52:01.00
Location: 30.240457,-97.817710  Date/Time: 9/3/2013 04:52:51.00
Location: 30.240455,-97.817710  Date/Time: 9/3/2013 04:52:52.00
Location: 30.236640,-97.821456  Date/Time: 9/3/2013 04:51:03.00

Done.

;
  char endMarker = '\n';
  // sterretje end
  char rc;

while (gpsSerial.available() > 0 && newData == false)
  {
    rc = gpsSerial.read();

if (recvInProgress == true)
    {
      if (rc != endMarker)
      {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars)
        {
          ndx = numChars - 1;
        }
      }
      else
      {
        // sterretje: include end marker in received message
        receivedChars[ndx] = rc;
        ndx++;
        // sterretje end

receivedChars[ndx] = '\0'; // terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }

else if (rc == startMarker)
    {
      // sterretje: include start marker in received message
      receivedChars[ndx] = rc;
      ndx++;
      // sterretje end

recvInProgress = true;
    }
  }
}

void showNewData()
{
  if (newData == true)
  {
    Serial.print(F("<<"));
    Serial.print(receivedChars);
    Serial.println(F(">>"));
    Serial.println(F("HEX data"));
    for (uint8_t cnt = 0; cnt < strlen(receivedChars); cnt++)
    {
      if (receivedChars[cnt] < 0x10)
      {
        Serial.print(F("0"));
      }
      Serial.print(receivedChars[cnt], HEX);
      Serial.print(F(" "));
    }
    Serial.println();
    Serial.println(F("GPS data: "));

for (uint8_t cnt = 0; cnt < strlen(receivedChars); cnt++)
    {
      if (gps.encode(receivedChars[cnt]))
        displayInfo();
    }
    Serial.println(F("================"));

newData = false;
  }
}

void displayInfo()
{
  Serial.print(F("Location: "));
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

Serial.println();
}


For $GPRMC,045251.000,A,3014.4275,N,09749.0626,W,0.51,217.94,030913,,,A*7D the result is

§DISCOURSE_HOISTED_CODE_1§


For $GPGGA,045252.000,3014.4273,N,09749.0628,W,1,09,1.3,206.9,M,-22.5,M,,0000*6F I get an invalid date (at occasion?)

§DISCOURSE_HOISTED_CODE_2§


I suspect a bug in the library but it might be expected behaviour; the BasicExample.ino code displays a date for every sequence but the GPGGA sequences in the example are missing a date field (which I think should be there). I verified this behaviour by changing the sequence so it starts with a GPGGA; the result for the first sequence now also shows an invalid date.

Original:

§DISCOURSE_HOISTED_CODE_3§


Modified (so a GPGGA sequence is the first):

§DISCOURSE_HOISTED_CODE_4§