I have pin 2 and 3 used as my serial input from a GPS module. I have everything set up working correctly, however, I want to perform more tasks than just reading a GPS module.
void setup() {
Serial.begin(9600);
///////////////////////////////////
// 9600 NMEA is the default baud rate
mySerial.begin(9600);
Serial.println("NMEA Sentences");
// uncomment this line to turn on only the "minimum recommended" data for high update rates!
mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCONLY);
// uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
// mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);
// Set the update rate
// 1 Hz update rate
mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);
// 5 Hz update rate- for 9600 baud you'll have to set the output to RMC only (see above)
// mySerial.println(PMTK_SET_NMEA_UPDATE_5HZ);
// 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
// mySerial.println(PMTK_SET_NMEA_UPDATE_10HZ);
//////////////////////////////////
}
Assuming I have all the setup etc correct in my code which I do, if I have this
void loop() {
if(mySerial.available()) {
Serial.print((char)mySerial.read());
}
}
and the NMEA sentence displays just fine. However I want to perform more tasks, and so I need to perform something like this
void loop() {
// perform lots of other functions here
while(!otherFunctionsComplete) ... // Very time consuming code
// just want to read 1 full nmea sentence from gps
getGPSData();
}
void getGPSData() {
// wait here until i get the GPRMCA sentence
while (mySerial.available()) {
Serial.print((char)mySerial.read());
}
}
The problem is I only get the buffer size 64 bytes of data using the second method. I want to wait and read the incoming bytes on the serial until i get a '$GPRMCA' and then store all the rest of the bytes. Any help with this?