MKR GPS: GPS.available() returns always 0

Hello dear Community,

I searched in the forums for over two hours now and there was no solution that worked for me and some threads don't even have a solution available. Unfortunately, many people that started the thread didn't respond whether a solution worked for them or not.

I am using the MKR WAN1310-Board and want to use the MKR GPS via I2C-Cable on that. As many other users described in other threads, the GPS.available() function never returns a 1, only 0. I did not solder any bridges, I kept them standard (https://www.arduino.cc/en/Guide/MKRGPSShield).

I couldn't test this outdoors, but I was able to test the code at an open window, I waited some minutes but it didn't change anything.

Maybe it is worth mentioning that I use the current Beta-Version of Arduino. I used the standard example code which I only modified at one line, where I made GPS.begin() to GPS.begin(GPS_MODE_I2C), just to be sure.

/*
  GPS Location

  This sketch uses the GPS to determine the location of the board
  and prints it to the Serial monitor.

  Circuit:
   - MKR board
   - MKR GPS attached via I2C cable

  This example code is in the public domain.
*/

#include <Arduino_MKRGPS.h>

void setup() {
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // If you are using the MKR GPS as shield, change the next line to pass
  // the GPS_MODE_SHIELD parameter to the GPS.begin(...)
  if (!GPS.begin(GPS_MODE_I2C)) {
    Serial.println("Failed to initialize GPS!");
    while (1);
  }
  else
    Serial.println("GPS init success");
}

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();
  }
}

Hopefully, someone has experience with that and can help me. Thank you in advance!

Yeah, that's pretty basic code and seems like it should just work. 2 thoughts...

  1. Just to confirm, you are connected via cable, right? You didn't solder on the headers and attach it as a shield. If that's correct, yeah, it looks like you're calling GPS.begin() correctly. Having said that, GPS_MODE_I2C should just be the default. Try it without passing anything in (no args). That's how I call it when I use it. Should result in the same thing... but who knows... worth trying.

  2. Try it outside! Probably needs to be the next big thing to try. If it just can't get a good GPS lock, you're just never going to get anything. I (almost) always have to go outside. I eventually had to put in a "GPS simulation" mode to do most of my development with.

Thank you for your fast reply. Right after I posted this, I used a little time slot without rain and tried it outdoors. It seems to work fine, I got all data from the GPS module. I guess the antenna isn't really top notch. The only thing is that the development of some decent code will be harder if I only can test it outdoors. I guess a tent could be a reasonable choice as an accessory when buying this module.

So for everyone with similar problems: An open window doesn't do its job, being outside is far better. The MKR GPS module works with the example code via the I2C cable just fine.

Yeah, like I said, I had to put in a GPS simulation mode for most of my development (got tired of sitting outside in the dark at night trying to test with the bugs eating me alive). For me, it's just an #ifdef, but I'm sure more creative things could be done. When I'm in sim mode, rather than initializing or calling the GPS, I just "fake it". My GPS functionality just returns a pre-defined location. I just picked the location of my house as a starting point. Every call after that just moves the location by a little bit. Depends on what you want your application to do. I found it to be very helpful though.

Hey All,
I'd love to know how you got GPS.available() to return 1. I've used the TinyGPSPlus library and the Arduino_MKRGPS library with no luck. I'm connecting a MKR GPS to a MKR WiFi 1010 via the I2C cable. I'm beginning to think that the MKR GPS module isn't quite as robust as I was hoping. Any thoughts would be greatly appreciated. Blessings!!