[SOLVED] Arduino or NodeMCU GPS tracking system on Map widget

The last sketch you posted but with the following changes:

bool simulation = true;
Only set this as true for test purposes, change back to false afterwards

In setup() change the 30000L to 5000L and this readGPS()

void readGPS(){
  ESP.wdtFeed();  // feed the ESP WDT, not needed in simulation mode at 4800ms delay but included just in case it's needed
  long startTime = millis();
  long counter = 0;
  Serial.print("Started reading GPS data at ");  
  Serial.println(startTime); 
   
  if(simulation == true || IranHack == true)
  {
    //long loopmax = 100L;  // max 2,147,483,647 or double this if usigned
    long loopmax = 1L;      // doesn't need to be a long variable
    while (counter < loopmax)   
    { 
      counter++;
      Serial.print(".");
      delay(4800);           // e.g. pause, 4800 seems ok 
    }
    Serial.println();
    //counter = 0;   // not required as counter is redefined each time readGPS() is called
    displayInfo();  
  }
  else
  {
    while (ss.available() > 0)  // sketch displays information every time a new sentence is correctly encoded.
      if (gps.encode(ss.read()))
        displayInfo();
  }
  Serial.print("Finished reading GPS data at ");
  Serial.print(millis());
  Serial.print(" and it took ");
  Serial.print(millis() - startTime);
  Serial.println("ms.");
  Serial.println("-----------------------------------------------------------");
  Serial.println();   
}

Post your SM with the changes above and later we can try to work out why the sketch is not pulling down your actual GPS data.

1 Like