Buenas Adumet,
échale un ojo a
http://www.ladyada.net/make/gpsshield/Yo utilizé su sketch para leer ese modelo, y funciona sin problemas.
(creo que este en concreto, no sé si lo adapté, ojéalo)
// A simple sketch to read GPS data and parse the $GPRMC string
// see
http://www.ladyada.net/mak/ for more info
#include <NewSoftSerial.h>
NewSoftSerial mySerial = NewSoftSerial(9, 2);
#define GPSRATE 4800
// GPS parser para SRIF STAR III 406a
#define BUFFSIZ 90
char buffer[BUFFSIZ];
char *parseptr;
char buffidx;
int latitud_dd, longitud_dd;
double latitud, latitud_aux, longitud, longitud_aux,altitud;
char latdir, longdir;
char status;
void setup()
{
Serial.begin(GPSRATE);
mySerial.begin(GPSRATE);
//Imprimimos titulo
Serial.println("GPS parser");
}
void loop()
{
uint32_t tmp;
readline();
// check if $GPRMC (global positioning fixed data)
if (strncmp(buffer, "$GPGGA",6) == 0) {
Serial.println(buffer);
//Posicionamos detrás de la cadena $GPGGA, y saltamos la hora
parseptr = buffer+7;
parseptr = strchr(parseptr, ',') + 1;
status = parseptr[0];
// Captura de latitud y longitud
// Extraemos valor de latitud
latitud_aux = parsedecimal(parseptr);
latitud_dd = latitud_aux;
latitud_dd /= 100;
latitud = latitud_dd + ((latitud_aux - (latitud_dd * 100)) / 60);
//Leemos referencia norte o sur
parseptr = strchr(parseptr, ',') + 1;
// read latitud N/S data
if (parseptr[0] != ',') {
latdir = parseptr[0];
}
// Extraemos valor de longitud
parseptr = strchr(parseptr, ',')+1;
longitud_aux = parsedecimal(parseptr);
longitud_dd = longitud_aux;
longitud_dd /= 100;
longitud = longitud_dd + ((longitud_aux - (longitud_dd * 100)) / 60);
//Leemos referencia este u oeste
parseptr = strchr(parseptr, ',')+1;
// read longitud E/W data
if (parseptr[0] != ',') {
longdir = parseptr[0];
}
//Saltamos los campos position fix, satellites used, y HDOP
parseptr = strchr(parseptr, ',')+1;
parseptr = strchr(parseptr, ',')+1;
parseptr = strchr(parseptr, ',')+1;
//Leemos altura en metros
parseptr = strchr(parseptr, ',')+1;
altitud = parsedecimal(parseptr);
Serial.print("Lat: ");
if (latdir == 'S')
latitud *= -1;
Serial.println(latitud,4);
Serial.print("Long: ");
if (longdir == 'W')
longitud *= -1;
Serial.println(longitud,4);
Serial.print("Altitud: ");
Serial.print(altitud);
Serial.println(" m");
}
}
double parsedecimal(char *str) {
double d = 0;
char aux_str[BUFFSIZ];
int i = 0;
while (str[0] != 0) {
if (((str[0] > '9') || (str[0] < '0'))&&(str[0]!='.')){
aux_str
='\0';
return atof(aux_str);
}
aux_str=str[0];
str++;
i++;
}
return atof(aux_str);
}
void readline(void) {
char c;
buffidx = 0;
while (1) {
c=mySerial.read();
if (c == -1)
continue;
//Serial.print(c);
if (c == '\n')
continue;
if ((buffidx == BUFFSIZ-1) || (c == '\r')) {
buffer[buffidx] = 0;
return;
}
buffer[buffidx++]= c;
}
}
--
Eduardo Marín.
Un saludo.