Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <TinyGPS++.h> // library for GPS module
- #include <SoftwareSerial.h>
- #include <ESP8266WiFi.h>
- TinyGPSPlus gps; // The TinyGPS++ object
- SoftwareSerial ss(4, 5); // The serial connection to the GPS device
- float latitude , longitude;
- String date_str , time_str , lat_str , lng_str;
- void setup() {
- Serial.begin(115200);
- ss.begin(9600);
- Serial.println();
- }
- void loop() {
- // Serial.println("afadf");
- while (ss.available() > 0){ //while data is available
- if (gps.encode(ss.read())) //read gps data
- {
- if (gps.location.isValid()) //check whether gps location is valid
- {
- latitude = gps.location.lat();
- lat_str = String(latitude , 6); // latitude location is stored in a string
- longitude = gps.location.lng();
- lng_str = String(longitude , 6); //longitude location is stored in a string
- Serial.println(latitude);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement