I am using CRIUS Neo-6 GPS module and I would like to send data from GPS via GSM module every 10 seconds. The piece of code I have looks like this:
if (Serial1.available() > 0)
if (gps.encode(Serial1.read()))
{
double hour = gps.time.hour();
double minute = gps.time.minute();
double second = gps.time.second();
Serial.println("Sending SMS:");
GPRS.print("AT+CMGF=1\r");
delay(100);
GPRS.println("AT+CMGS= \"00*********\"");
delay(100);
GPRS.print("HOUR=");
GPRS.print(hour);
GPRS.print(" MINUTE=");
GPRS.println(minute);
GPRS.print(" SECOND=");
GPRS.println(second);
delay(100);
GPRS.print((char)26);
delay(100);
GPRS.println();
Serial.println("Text sent.");
Serial.println();
delay(10000);
}
Serial1 is a SoftwareSerial instance for communication with GPS module. Now this sends an SMS every 10 seconds but the data is messed up, it is like the time doesnt refresh always. I get something like:
HOUR=6.00 MINUTE=37.00 SECOND=54.00
HOUR=6.00 MINUTE=37.00 SECOND=54.00
HOUR=6.00 MINUTE=37.00 SECOND=54.00
HOUR=6.00 MINUTE=38.00 SECOND=15.00
and so on.. Its like always two or three identical SMS-es and then next one with 30 seconds gap. What should I change to always send latest gps time?