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() {
Serial.begin(9600);
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()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
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.).