Last active
November 21, 2018 01:51
-
-
Save KornWtp/5b08e8547b19982f78e59353f97e967b to your computer and use it in GitHub Desktop.
TTGO_LoRa_GPS.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TinyGPS++.h> | |
#include <HardwareSerial.h> | |
TinyGPSPlus gps; | |
HardwareSerial mySerial1(1); | |
int timezone = 7; | |
void setup() | |
{ | |
Serial.begin(115200); | |
mySerial1.begin(9600, SERIAL_8N1, 12, 15); //12-TX 15-RX | |
} | |
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()+timezone); | |
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 (mySerial1.available()) | |
gps.encode(mySerial1.read()); | |
} while (millis() - start < ms); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment