LS23060 Partial Messages

I’m trying to use the gps with New Soft Serial, but I’m having problems. I get what appear to be mostly accurate messages, but the last handful of characters are garbage, so I don’t get things like the checksum.

If I use this code:

Serial.begin(57600);
  mySerial.begin(57600);
  mySerial.print("$PMTK220,1000*2C");
  mySerial.print("$PMTK314,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2C");

in my setup method I get this as a result:

$GPGGA,230658.600,3751.2128,N,07739.5112,W,1,6,1.20,103.0,M,-33431,347.

$GPGGA,230658.800,3751.2128,N,07739.5113,W,1,6,1.20,103.0,M,-33.389V7.

$GPGGA,230659.000,3751.2127,N,07739.5112,W,1,6,1.20,103.0,M,-333,347.

$GPGGA,230659.200,3751.2126,N,07739.5113,W,1,6,1.20,103.0,M,-334P4,47.

$GPGGA,230659.400,3751.2126,N,07739.5112,W,1,6,1.20,103.0,M,-3331,

$VAA$GPGGA,230659.600,3751.2126,N,07739.5111,W,1,6,1.20,103.0,M,-33.35,47.

$GPGGA,230659.800,3751.2126,N,07739.5110,W,1,6,1.20,103.0,M,-334.8,4,A

$GPGGA,230700.000,3751.2125,N,07739.5108,W,1,6,1.20,103.0,M,-333,3VP11

$GPGGA,230700.200,3751.2125,N,07739.5107,W,1,6,1.20,102.9,M,-33,G83VA1

$GPGGA,230700.400,3751.2125,N,07739.5106,W,1,6,1.20,102.9,M,-333,3V7

$GPGGA,230700.600,3751.2125,N,07739.5105,W,1,6,1.20,102.9,M,-333143,P1

$GPGGA,230700.800,3751.2124,N,07739.5105,W,1,6,1.20,102.9,M,-334.8,07

Also if I add something like this to change the baud rate of the gps at the end of my setup method all I get is garbage as output.

Does anyone have any ideas as to what I’m doing wrong?

Thanks,

Chris

I’ve been playing with it a little more and still haven’t had any luck. I’ve played around with this line: ```
mySerial.print(“$PMTK314,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2C”);


If I change some of the 0's to any number's one through 5 it should start outputting other messages, not just the GGA message. But it doesn't seem to change anything. 

I also tried this line ```
mySerial.print("$PMTK104*37");
``` which I thought would reset it to factory defaults but that also didn't appear to change anything either. 

I'm not sure why it change to just running GGA settings when I ran the code originally, but I'm beginning to wonder if I have some sort of flaky connection between the Arduino and the GPS? I'm using an Arduino Duemilanove so I think it runs at 5 volts, and maybe that's why it doesn't pick up all the data and also why the commands only seem to work some of the time?

I finally got it working! I looked at the sparkfun product webpage for the GPS and found someone had posted code to create the necessary messages. Turns out my checksums were the problem.

Here’s the code I’m currently using to only output GPGGA messages like I wanted.

#include <NewSoftSerial.h>
NewSoftSerial mySerial(2, 3);
bool newgps;
char* rawgps;
char* utctime;
char* longitude;
char* latitude;
char* alt;
char* sats;

#define CH_CR 0x0D 
#define CH_LF 0x0A
const char CRLF[]={CH_CR, CH_LF, 0};


void setup()  
{
  Serial.begin(57600);
  
  //In case the battery died and reset to factory settings change baud rate here
  mySerial.begin(57600);
  char s4[40];
   mySerial.print(NMEA_ConstructSentence(s4,"PMTK251,14400")); 
   mySerial.end();
  mySerial.begin(14400);
  
  char s1[40];
  mySerial.print(NMEA_ConstructSentence(s1,"PMTK220,200")); //200 for 5 HZ 1000 for 1 Hz
  char s2[40];
  mySerial.print(NMEA_ConstructSentence(s2,"PMTK314,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0")); //For GGA messages once every 5 messages
   char s3[40];
   mySerial.print(NMEA_ConstructSentence(s3,"PMTK251,14400")); //Not sure why this has to be sent everytime but won't work without 
   
  newgps = false;
  rawgps="";
  utctime = 0;

  free(s4);
  free(s1);
  free(s2);
  free(s3);
}

void loop()                     // run over and over again
{
  
  if (mySerial.available()) //{
    Serial.print((char)mySerial.read());
   
  //}
}


char * NMEA_ComputeChecksum(char *s) 
{ 
  static char ck_string[4]; 
  static unsigned char chksum;
  for(chksum=0; *s; ++s) 
  {
    chksum ^= *s;
  }
  
  sprintf(ck_string, "*%02X", chksum);

  return(ck_string); 
}

char * NMEA_ConstructSentence(char *s, char *msg ) 
{ 
  strcpy(s, "$"); 
  strcat(s,msg); 
  strcat(s,NMEA_ComputeChecksum(msg)); 
  strcat(s, CRLF);
  return(s); 
}

I’m not sure if it will work after the little battery drains, but I’ll be testing that once it drains.