Fastest GPS library?

Well that was weird. I left it running and went for dinner. When I came back it was reporting the latitude!

Ok, I think all the GPS and SD stuff is running correctly at 1Hz.

However if I put this if (rtc.begin()) { back in to check if the RTC is connected it adds one second to the loop and causes the GPS to write data to the SD card every 2 seconds.

So I am back to this problem of checking for the RTC without slowing the loop down. Is there another way to check for it that is quicker?

Or possibly check for it in Setup and pass a status variable to the Loop?

Thanks

Johnny

Hi Johnny,

I suspect you are using your GNSS indoors? Or with a poor view of the sky? The latitude will read as zero until the GNSS has (at least) a 2D fix. There are other ways to check if the time is valid: getTimeValid, getConfirmedTime, getTimeFullyResolved. They report slightly different things; check the u-blox interface description for more details.

I don’t know what rtc.begin is doing behind the scenes. If you simply want to check that a device is present at address 0x68, then try this:

Wire.beginTransmission(0x68);
bool connected = (Wire.endTransmission() == 0); // connected will be true if a device with address 0x68 is on the bus

I hope this helps,

Paul

Definitely need to migrate slow RTC stuff out of loop() and into setup()

Determine if it needs adjusting, then adjust it once, perhaps then monitor occasionally if you think it’s deviating by a second, or enough to require adjustment.

The initialization of the RTC might be quite expensive, or have loops waiting for it to tick, or synchronize with the much slower RTC vs MCU clocks.

Look at the underlying library code to understand.

Clive

I ended up doing something similar by only checking for and updating the RTC in the first 30 seconds after booting by checking millis. After 30 seconds it ignores the RTC etc and just logs the GPS data.

// Write GPS date & time to the RTC during the first 30 seconds of bootup.
if (millis() < 30000) {
if (rtc.begin()) {
Serial.println(“Updating RTC with GPS date & time…”);
rtc.adjust(DateTime(myYear, myMonth, myDay, myHour, myMinute, mySecond));
Serial.flush();
}
}

Not the most elegant technique but I can live with this.

Paul

I will try that code later, however I am excited to start using this thing as soon as possible. [And analyze the data, draw conclusions, and potentially refine the code & hardware if required].

A big “Thank You” to all for helping me. This was getting very frustrating [and expensive].

Johnny