Skip to content

Instantly share code, notes, and snippets.

@Adekoreday
Created May 19, 2019 16:09
Show Gist options
  • Save Adekoreday/f13c35727c7c1d8499154202495b8ae0 to your computer and use it in GitHub Desktop.
Save Adekoreday/f13c35727c7c1d8499154202495b8ae0 to your computer and use it in GitHub Desktop.
ioT-GPS-tracker
void loop(){
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);
}
}
voiddisplayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
latt=gps.location.lat();
lngg = gps.location.lng();
Serial.println(context);
client.add("gps_coordinates", value1, context);
client.sendAll(true);
delay(5000);
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment