Resolving a complex asynchronous system with an Arduino Board

Hello All,

I have a system that read data from the GPS that is updated with a new GPS coordinate at a period that range between 0.1 to 2 seconds. The GPS coordinates are then passed to the GSM which send the coordinate to the webserver. The necessary time to send the data from the GSM to the websever is 39 seconds.

Therefore for any GSM transaction I lost almost 20 GPS coordinates as the Microcontroller is busy sending the data to the GSM.

The fact that the GPS do not present valid data at a precise time, prevent me from using any interrupt such as timer interrupt to retrieve the GPS data.

Is it possible to run certain tasks in the Microcontroller background until a certain variable get a certain value? If yes I will then run the retrieving of data via GPS in background until the GPS coordinate become valid.

Otherwise does anybody know of a GPS board that has a pin that indicates when the GPS coordinates become valid?

Or does anybody has a suggestion?

The GPS that I am using can be seen in the link below

The code use to retrieve the data from the GPS is below

for (unsigned long start = millis(); millis() - start < 1000;) {

while (Serial2.available()) {
char c =;
//Serial.write(c); // uncomment this line if you want to see the GPS data flowing
if (gps.encode(c)) // Did a new valid sentence come in?
newData = true;

if (newData) {
gps.f_get_position(&flat, &flon, &age);


Any feedback will be appreciated
Many thanks,