ESP32 + GPS VKEL

Asturias
Posts: 3
Joined: Thu Dec 01, 2016 4:01 pm

ESP32 + GPS VKEL

Postby Asturias » Thu Dec 29, 2016 7:23 pm

Code: Select all

/*****************************************
* ESP32 GPS VKEL 9600 Bds
******************************************/

#include <TinyGPS++.h>                       

TinyGPSPlus gps;                            
HardwareSerial Serial1(1);                 

void setup()
{
  Serial.begin(115200);
  Serial1.begin(9600, SERIAL_8N1, 17, 16);
}

void loop()
{
  Serial.print("Latitude  : ");
  Serial.println(gps.location.lat(), 5);
  Serial.print("Longitude : ");
  Serial.println(gps.location.lng(), 4);
  Serial.print("Satellites: ");
  Serial.println(gps.satellites.value());
  Serial.print("Altitude  : ");
  Serial.print(gps.altitude.feet() / 3.2808);
  Serial.println("M");
  Serial.print("Time      : ");
  Serial.print(gps.time.hour());
  Serial.print(":");
  Serial.print(gps.time.minute());
  Serial.print(":");
  Serial.println(gps.time.second());
  Serial.println("**********************");

  smartDelay(1000);                                      

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

static void smartDelay(unsigned long ms)                
{
  unsigned long start = millis();
  do
  {
    while (Serial1.available())
      gps.encode(Serial1.read());
  } while (millis() - start < ms);
}
It works

Who is online

Users browsing this forum: No registered users and 76 guests