#include <SoftwareSerial.h>
SoftwareSerial gps(4, 3);
void setup()
{
Serial.begin(115200);
gps.begin(9600);
}
void loop(){
if (gps.available()){
char dato;
dato = gps.read();
Serial.print(data);
}
}
#include <SoftwareSerial.h>
#include <TinyGPS.h>
TinyGPS gps;
SoftwareSerial softSerial(4, 3);
void setup(){
Serial.begin(115200);
softSerial.begin(9600);
}
void loop(){
bool newData = false;
unsigned long chars;
unsigned short sentences, failed;
// Esperar a recibir secuencia durante un segundo
for (unsigned long start = millis(); millis() - start < 1000;){
while (softSerial.available()){
char c = softSerial.read();
if (gps.encode(c)){
newData = true;
}
}
}
if (newData)
{
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
Serial.print("Latitud=");
Serial.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
Serial.print(" Longitud=");
Serial.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
Serial.print(" Número de satélites=");
Serial.print(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
Serial.print(" Precisión=");
Serial.print(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
}
gps.stats(&chars, &sentences, &failed);
Serial.print(" CHARS=");
Serial.print(chars);
Serial.print(" SENTENCES=");
Serial.print(sentences);
Serial.print(" CSUM ERR=");
Serial.println(failed);
}