Why my GPS modules logs data like this? I want the GPS location every one seconds. but I get data for every 7 8 secs. When I try executing the sarandard examples it works fine. but my own program it does not work as I expect.
Latitude,Longitude,Time
48.772453,11.380930,13:22:34
48.772453,11.380930,13:22:34
48.772224,11.380901,13:22:37
48.772224,11.380901,13:22:37
48.772186,11.380884,13:22:39
48.772186,11.380884,13:22:39
48.772186,11.380884,13:22:39
48.772186,11.380884,13:22:39
48.772186,11.380884,13:22:39
48.772186,11.380884,13:22:39
48.772075,11.380890,13:22:46
48.772075,11.380890,13:22:46
48.772048,11.380926,13:22:48
48.772048,11.380926,13:22:48
48.772048,11.380926,13:22:48
48.772048,11.380926,13:22:48
48.772048,11.380926,13:22:48
48.772048,11.380926,13:22:48
48.772064,11.380880,13:22:55
48.772064,11.380880,13:22:55
48.772068,11.380877,13:22:57
48.772068,11.380877,13:22:57
48.772068,11.380877,13:22:57
48.772068,11.380877,13:22:57
48.772068,11.380877,13:22:57
48.772068,11.380877,13:22:57
48.771968,11.381054,13:23:4
48.771968,11.381054,13:23:4
48.772056,11.380922,13:23:6
48.772056,11.380922,13:23:6
48.772056,11.380922,13:23:6
48.772056,11.380922,13:23:6
48.772056,11.380922,13:23:6
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772121,11.380867,13:23:12
48.772247,11.380781,13:23:21
48.772247,11.380781,13:23:21
48.772247,11.380781,13:23:21
48.772247,11.380781,13:23:21
48.772247,11.380781,13:23:21
48.772247,11.380781,13:23:21
48.772289,11.380819,13:23:28
48.772289,11.380819,13:23:28
48.772285,11.380814,13:23:30
48.772285,11.380814,13:23:30
48.772285,11.380814,13:23:30
48.772285,11.380814,13:23:30
48.772285,11.380814,13:23:30
48.772285,11.380814,13:23:35
48.772319,11.380855,13:23:37
48.772319,11.380855,13:23:37
48.772365,11.380864,13:23:39
48.772365,11.380864,13:23:39
48.772365,11.380864,13:23:39
48.772365,11.380864,13:23:39
48.772365,11.380864,13:23:39
48.772365,11.380864,13:23:39
48.772506,11.380843,13:23:46
48.772506,11.380843,13:23:46
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772518,11.380827,13:23:48
48.772579,11.380825,13:23:56
48.772579,11.380825,13:23:56
48.772605,11.380821,13:23:58
48.772605,11.380821,13:23:58
48.772605,11.380821,13:23:58
48.772605,11.380821,13:23:58
48.772605,11.380821,13:23:58
48.772605,11.380821,13:23:58
48.772682,11.380812,13:24:5
48.772682,11.380812,13:24:5
48.772697,11.380810,13:24:7
48.772697,11.380810,13:24:7
48.772697,11.380810,13:24:7
48.772697,11.380810,13:24:7
48.772697,11.380810,13:24:7
48.772697,11.380810,13:24:7
48.772769,11.380812,13:24:14
48.772769,11.380812,13:24:14
48.772796,11.380803,13:24:16
48.772796,11.380803,13:24:16
48.772796,11.380803,13:24:16
48.772796,11.380803,13:24:16
48.772796,11.380803,13:24:16
48.772865,11.380773,13:24:22
48.772865,11.380773,13:24:22
48.772876,11.380762,13:24:24
48.772876,11.380762,13:24:24
48.772876,11.380762,13:24:24
48.772876,11.380762,13:24:24
48.772876,11.380762,13:24:24
48.772876,11.380762,13:24:24
Here is my code as well.
#include <TinyGPS++.h>
#include <SD.h>
File dataFile; // create a File object to write to the SD card
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
SD.begin(53); // initialize the SD card on pin 53
dataFile = SD.open("data.txt", FILE_WRITE);
dataFile.println("Latitude,Longitude,Time");
dataFile.flush(); // make sure the header is written to the SD card
}
void loop() {
while (Serial1.available() > 0) {
if (gps.encode(Serial1.read())) {
if (gps.location.isValid() && gps.time.isValid()) {
// get latitude, longitude, and time from GPS module
float lat = gps.location.lat();
float lon = gps.location.lng();
int hour = gps.time.hour();
int minute = gps.time.minute();
int second = gps.time.second();
// write latitude, longitude, and time to SD card
dataFile.print(lat, 6);
dataFile.print(",");
dataFile.print(lon, 6);
dataFile.print(",");
dataFile.print(hour);
dataFile.print(":");
dataFile.print(minute);
dataFile.print(":");
dataFile.println(second);
dataFile.flush();
delay(1000);
}
}
}
}