Buenos dias.
Estoy usando el módulo GPS "Adafruit GPS MTK3339 " y la libreria TinyGPS para recivir datos GPS.
Tengo dos temas que no se como solucionar. Paso copia de dos lecturas correlativas, estando el GPS quieto, está encima de mi mesa.
Latitud : 41.8533973 i Longitud : 2.2394618
Data : 12/11/2021
Hora : 11:29:5
Altitud (metres): 559.20
Rumb (graus) : 147.14
Velocitat(kmph) : 2.30
Satelits : 3
Latitud : 41.8533973 i Longitud : 2.2394950
Data : 12/11/2021
Hora : 11:29:8
Altitud (metres): 559.20
Rumb (graus) : 147.14
Velocitat(kmph) : 2.30
Satelits : 3
Haber si algien me puede ayudar.
Primer tema, ¿como puedo diferenciar si mi receptor està parado o no? Los datos de ejemplo que he pasado, son con el receptor quieto, pero la longitud tiene una ligera diferencia, y entiendo que por este motivo me da 2,3Km/h que no es cierto !!!
Segundo tema: como puedo saber la distancia entre cada lectura de los datos GPS?
El código que estoy usando es el sigüente:
// Adafruit GPS MTK3339
/*
Modul GPS
RXD Arduino Pin 7 ; TXD Arduino Pin 6
RST Leave Open ? (Connect to a N/O momentary switch pulled low to reset?)
NC Leave Open
GND Ground ; VCC +5
Make sure you download TinyGPS.h
*/
#include <TinyGPS.h>
#include <SoftwareSerial.h>
unsigned long fix_age;
// Variables GPS
SoftwareSerial GPS(7,6); // Atenció que ha de coincidor amb els pins que fem servir
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;
int year;
byte month, day, hour, minute, second, hundredths;
// Fi variables GPS
void setup()
{
GPS.begin(9600);
Serial.begin(9600);
Serial.println(" ");
Serial.println("*****************************************");
Serial.println("Receptor dades GPS - Adafruit GPS MTK3339 ");
Serial.println("*****************************************");
}
void loop()
{
CapturaGPS();
}
// Funcios GPS *************************************************
void CapturaGPS()
{
gps.get_position(&lat, &lon, &fix_age);
getGPS();
Serial.print("Latitud : ");
Serial.print(LAT/1000000,7);
Serial.print(" i Longitud : ");
Serial.println(LON/1000000,7);
Serial.print("Data : "); Serial.print(day, DEC); Serial.print("/");
Serial.print(month, DEC); Serial.print("/"); Serial.println(year);
Serial.print("Hora : "); Serial.print(hour, DEC); Serial.print(":");
Serial.print(minute, DEC); Serial.print(":"); Serial.println(second, DEC);
Serial.print("Altitud (metres): "); Serial.println(gps.f_altitude());
Serial.print("Rumb (graus) : "); Serial.println(gps.f_course());
Serial.print("Velocitat(kmph) : "); Serial.println(gps.f_speed_kmph());
Serial.print("Satelits : "); Serial.println(gps.satellites());
Serial.println();
delay(2000);
}
void getGPS()
{
bool newdata = false;
unsigned long start = millis();
// Every 1 seconds we print an update
while (millis() - start < 1000)
{
if (feedgps ()){
newdata = true;
}
}
if (newdata)
{
gpsdump(gps);
}
}
bool feedgps()
{
while (GPS.available())
{
if (gps.encode(GPS.read()))
return true;
}
return 0;
}
void gpsdump(TinyGPS &gps)
{
//byte month, day, hour, minute, second, hundredths;
gps.get_position(&lat, &lon);
gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
LAT = lat;
LON = lon;
{
feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors
}
}
// Fi funcios GPS *************************************************
Mil grácias.