Mkr gps not initializing?

Hi,

I am trying to make a gps tracker with arduino mkr nb1500 and the mkr gps shield using the arduino iot cloud. When I run just the example scketch for the gps shield I get all of the info (i.e. lat, long, speed) almost instantaneously. When I try to run that same code but from the iot web page it never seems to gsther data... well it did twice and now it just reads only 0 for everything the gps is collecting. All other cloud functions seem to work...

Any ideas on why this is happeneing and how to get it to be reliable??

I am wondering if it is somehow skipping over the initialization part of the code? I honestly have no idea but am egar to learn and figure it all out.

Ant help would be much appreciated.

Thanks!

Me too. :nerd_face:

Post your sketch, well formated, with comments and in so called code tags "</>" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.

Thanks paulpaulson

Here is the code...

  Sketch generated by the Arduino IoT Cloud Thing "Untitled"https://create.arduino.cc/editor/sammy_j2/2ccb7b30-ca84-48ad-99bf-74a530982aea
  https://create.arduino.cc/cloud/things/47cffd46-b4dd-49db-ba4d-c96331c986e2

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudLocation coordinates;

  bool ledNB;



  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include "Arduino_MKRGPS.h"

float Lat;
float Long;
float altitude;
float speed   ;
int   satellites;



void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);
  if (!GPS.begin(GPS_MODE_SHIELD)) {
    Serial.println("Failed to initialize GPS!");
    while (1);
  }


  ledNB = 1;
  pinMode(LED_BUILTIN, OUTPUT);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);


  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();


  if (GPS.available()) {

    Long  = GPS.longitude();
    Lat   = GPS.latitude();
    Long  = GPS.longitude();
    altitude   = GPS.altitude();
    speed      = GPS.speed();
    satellites = GPS.satellites();
    Serial.print("Location: ");
    Serial.print(Lat, 7);
    Serial.print(", ");
    Serial.println(Long, 7);

    Serial.print("Altitude: ");
    Serial.print(altitude);
    Serial.println("m");

    Serial.print("Ground speed: ");
    Serial.print(speed);
    Serial.println(" km/h");

    Serial.print("Number of satellites: ");
    Serial.println(satellites);

    Serial.println();

    coordinates = {Lat, Long};

  }
  Serial.print("Location: ");
    Serial.print(Lat, 7);
    Serial.print(", ");
    Serial.println(Long, 7);

    Serial.print("Altitude: ");
    Serial.print(altitude);
    Serial.println("m");

    Serial.print("Ground speed: ");
    Serial.print(speed);
    Serial.println(" km/h");

    Serial.print("Number of satellites: ");
    Serial.println(satellites);

    Serial.println();


}


/*
  Since LedNB is READ_WRITE variable, onLedNBChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLedNBChange()  {
  // Add your code here to act upon LedNB change

  Serial.println(ledNB);

  if (ledNB) {
    digitalWrite(LED_BUILTIN, HIGH);
  }

  else
  {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

As far as schematics go its just the MKR GPS shield plugged in on top of the MKR NB.

I have it printing outside the 'if' statement just to see what it has been returning...

Thanks!

update...

it looks like if I try to upload the GPS example code over the online editor the gps unit fails to initialize every time. If I upload from the IDE on my laptop it works instantly...

What could be causing the issue when uploading from the internet vs uploading from the IDE on the laptop??