MKR WAN 1310 with MKR GPS as shield not working

I want to use the MKR GPS module as a shield (not I2C) on the MKR WAN 1310. Unfortunately, the code below goes wrong. Even after a very long wait I do not receive any GPS messages.

Does anyone know what I'm doing wrong?

#include <Arduino_MKRGPS.h>

int i;

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
}

if (!GPS.begin(GPS_MODE_SHIELD)) {
Serial.println("Failed to initialize GPS!");
while (1);
}
else Serial.println("GPS Ready");
}

void loop() {
  // check if there is new GPS data available
  if (GPS.available()) {
    // read GPS values
    float latitude   = GPS.latitude();
    float longitude  = GPS.longitude();
    float altitude   = GPS.altitude();
    float speed      = GPS.speed();
    int   satellites = GPS.satellites();

    // print GPS values
    Serial.print("Location: ");
    Serial.print(latitude, 7);
    Serial.print(", ");
    Serial.println(longitude, 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();
  }
  else {
    i++;
    Serial.print("Waiting now ");
    Serial.print(i);
    Serial.println(" seconds");
    delay(1000);
  }
}

Using a different library solved the problem, the code below works for me.

In my opinion it is disappointing that Arduino in their documentation of the MKR GPS only describes how it can be used with an I2C cable, not as a shield. The board is not cheap compared to other GPS boards on the internet, I count on a better explanation of how to use it. Or did I miss some information from Arduino?

#include <TinyGPS++.h>
 
static const int RXPin = 13, TXPin = 14;
static const uint32_t GPSBaud = 9600;
 
TinyGPSPlus gps;
 
void setup()
{
  Serial.begin(115200);
  Serial1.begin(GPSBaud);
}
 
void loop()
{
  while (Serial1.available() > 0)
    if (gps.encode(Serial1.read()))
      displayInfo();
 
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}
 
void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
    delay(1000);
  }
  Serial.println();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.