#include <SoftwareSerial.h>
SoftwareSerial SoftSerial(2, 3);
char buffer[64];                   
byte count=0;
                       
void setup() {
    SoftSerial.begin(9600);                
    Serial.begin(9600);                     
}

void loop() {
    String type = "";
    String date = "";
    String lattitude = "";
    String longitude = "";
    
    if (SoftSerial.available()) {                    
        while(SoftSerial.available()) {               
            buffer[count++]=SoftSerial.read();      
            if(count == 64) break;
        }
    String trame ( buffer);
     
   // Type trame 
    type = trame.substring(1,6);
    if (type == "GPGGA") {
        Serial.print("Trame : ");Serial.println(type);
        
        // Date
        date = trame.substring(7,13);
        Serial.print("Date : ");Serial.println(date);
        
        // Lattitude 
        lattitude = trame.substring(18,27)+trame.substring(28,29);
        Serial.print("Lattitude : ");Serial.println(lattitude);
      
        // Longitude
        longitude = trame.substring(30,40)+trame.substring(41,42);
        Serial.print("Longitude : ");Serial.println(longitude);
        }
        
    else { Serial.println("Attente Trame GPGGA");
    }
    
    delay(1000);
    clearBufferArray();                         
    count = 0;                                
    }
}


void clearBufferArray() {
    for (int i=0; i<count;i++) {
        buffer[i]=NULL;
    }                      
}
