Hi Roy
Looking at this other part of the code, I think I see what it is doing, but it is unusual to use the for loop this way.
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 1000;)
{
while (ss.available())
{
char c = ss.read();
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;
}
}
There is also a possibility that, if data comes in on software serial fast and long enough, the while loop would not finish when you think it should, and you get stuck inside the for loop forever, or at least longer than one second.
A different way to structure it is this. I'm assuming that as soon as newData becomes true, you want to move on to the rest of the program. You don't have to gather a full one second's worth of data if you get a valid sentence before then?
unsigned endLoopTime = millis() + 1000; // Spend up to 1,000 ms in the loop
// newData previously set to false in your program
while ( (millis() < endLoopTime) && (!newData) )
{
if (ss.available())
{
char c = ss.read();
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;
}
}