Hola.
Llevo algun tiempo intentando que mi Arduino Nano me muestre en el monitor de serie los datos de Latitud, Longitud y Altitud extraidos de los datos que me da el GPS.
Cuando conecto los pines RX y TX directamente al GPS, no tengo problema que aparezcan usando el siguiente codigo:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Logicamente, cuando el GPS adquiere señal, aparecen todos los datos al completo.
ejemplo:
$GPGSV,3,1,09,01,54,299,18,03,32,216,28,08,64,138,13,10,15,044,18*7A
$GPGSV,3,2,09,14,25,304,,17,03,311,,21,71,354,24,27,29,133,06*7A
$GPGSV,3,3,09,32,28,073,26*4B
$GLGSV,3,1,11,65,45,158,21,66,00,187,,71,14,028,25,72,52,066,09*61
$GLGSV,3,2,11,77,02,216,,78,22,267,28,79,16,320,,81,05,298,*62
$GLGSV,3,3,11,86,05,098,,87,51,059,10,88,49,329,26*58
El problema viene cuando intento extraer los datos y quedarme solo con los de Latitud, longitud y altura. (Usando los datos dados por la linea $GNGGA
He usado multiples codigos y variaciones del mismo, pero siempre con el mismo resultado: el monitor de serie no muestra nada.
Ejemplo del codigo:
#include <TinyGPSPlus.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 4800;
TinyGPSPlus gps;
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
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);
}
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();
}
Que puedo estar haciendo mal? Alguna ayuda?



