Using MKR GPS Shield as a shield with Sparkfun u-blox GNSS library

Have a project where I simply cannot use the the I2C cable to connect to the MKR GPS Shield. And, on top of that I am not using the ArduinoMKRGPS library, but rather the Sparkfun u-blox GNSS library. It simply works much better with the project in question...

Everything works perfecly when using the I2C cable, since that uses the default I2C address, but as soon as I use it as a shield the address changes and communication with the shield no longer works.

On the ArduinoMKRGPS library it's easy to fix, since a setting for this is included in the begin command.

void setup() {
  while (!Serial) {
  if (!GPS.begin(GPS_MODE_SHIELD)) {
    Serial.println("Failed to initialize GPS!");
    while (1);
  else {
    Serial.println("Setup complete.");

Running the above code returns "Setup complete" without issues.

The problem comes when I try something similar on the Sparkfun library (directly from Example3_GetPosition):

void setup()
  while (!Serial); //Wait for user to open terminal
  Serial.println("SparkFun u-blox Example");


  if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
    Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
    while (1);

  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
  myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR

This returns "not detected at default I2C address".

I've been searching and looking through the library files for the ArduinoMKRGPS library to try to figure out what's going on, but both my Google-Fu and knowledge of the matter failes me miserably. I simply cannot figure out how to make the Sparkfun library connect to the MKR GPS Shield when having it connected as a shield.

I've tried connecting to the GPS by changing the I2C address in the above mentioned Sparkfun example, all the way from 0x01 to 0x7F, but no success.

myGNSS.begin(Wire, 0x7F)

I'm obviously missing something, and any help is appreciated.

Update 2023-01-13:
I've been asked if I ever figured this out, but I never did since eventually I did end up using the I2C cable after all, due to a redesign of the project (which can be found here: GitHub - johan-m-o/BikeTracker: Open-source movement sensor and GPS tracker for your bicycle. Built on Arduino.).

Some progress, I guess...

From what I can gather (please correct me someone if I'm wrong), the ArduinoMKRGPS library uses UART when the GPS module is connected as a shield.

So, now I've been trying to adapt this code example from the Sparkfun library. Having a hard time with that as well though since it uses SoftwareSerial, something my board (a MKR GSM 1400) doesn't support due to having hardware serial on pins 13/14.

Including the UART code example here as well, in case anyone's interested (unaltered, so obviously #include <SoftwareSerial.h> and the line after won't work out of the box, that's what I'm trying to figure out now):

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX. Pin 10 on Uno goes to TX pin on GNSS module.

long lastTime = 0; //Simple local timer. Limits amount of I2C traffic to u-blox module.

void setup()
  while (!Serial); //Wait for user to open terminal
  Serial.println("SparkFun u-blox Example");

  //Assume that the U-Blox GNSS is running at 9600 baud (the default) or at 38400 baud.
  //Loop until we're in sync and then ensure it's at 38400 baud.
  do {
    Serial.println("GNSS: trying 38400 baud");
    if (myGNSS.begin(mySerial) == true) break;

    Serial.println("GNSS: trying 9600 baud");
    if (myGNSS.begin(mySerial) == true) {
        Serial.println("GNSS: connected at 9600 baud, switching to 38400");
    } else {
        delay(2000); //Wait a bit before trying again to limit the Serial output
  } while(1);
  Serial.println("GNSS serial connected");

  myGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
  myGNSS.saveConfiguration(); //Save the current settings to flash and BBR

void loop()
  //Query module only every second. Doing it more often will just cause I2C traffic.
  //The module only responds when a new position is available
  if (millis() - lastTime > 1000)
    lastTime = millis(); //Update the timer
    long latitude = myGNSS.getLatitude();
    Serial.print(F("Lat: "));

    long longitude = myGNSS.getLongitude();
    Serial.print(F(" Long: "));
    Serial.print(F(" (degrees * 10^-7)"));

    long altitude = myGNSS.getAltitude();
    Serial.print(F(" Alt: "));
    Serial.print(F(" (mm)"));

    byte SIV = myGNSS.getSIV();
    Serial.print(F(" SIV: "));


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