The MKR GPS Shield only works if I call GPS.Available() very frequently, like keep looping it for 10s before doing anything else.
The MKR GPS Shield does not appear to "lock" on satellites. If I go outside with clear sky and wait for 10 minutes, which any decent GNSS should get a lock. GPS.Available() returns 0.
The only way for the board to work is to call GPS.Available() non-stop. After reading a few posts, I'm not alone here.
The module only output data at 1Hz by default. It make no sense to call it in a non-stop loop.
Update:
Switched to Sparksfun u-box library and it works fine. Has cache. Can read from on-chip memory. Locks in no time. Does not matter how long you wait between calls. Can read actual time instead of time from epoch crap, which is different each GNSS.
I STAND BY MY WORD: Whoever wrote the official MKR GPS library should be ashamed of themselves, it's completely rubbish.
Getting Started
Our Arduino_MKRGPS library handles the two different interfaces and offer a consistent set of APIs designed for a full usage of the GPS acquired information
The library does not even touch the tip of iceberg of what this u-box module can do.
So, write a GPS library that's better. It's all open source freeware. Did you test any example sketches that come with the library? Deviate significantly from those in your code?
Thats the way most GPS libraries work, you need to feed the libraries with a constant stream of characters from the GPS so that the library is kept up to date with location etc.
The GPS is just a standard Ublox SAM M8Q, if you want to not use it in the standard way, i.e. constanly feeding the library with characters, then you can turn off all the NMEA stuff and poll it dirctly for location information etc.
You might want to try this library;
Its interrupt driven so the library is automagically kept up to date with stuff.
Correct! I use Ultimate GPS and tinygps+. I do not need to send a thingy to the GPS module blah, blah, blah. Would that mean your GPS module is at fault that it is not doing the thing unless told to do so and not the fault of the library? Unlike other GPS modules that do the thing, automatically, and I just read the info when it's available.
Look at the example code for your device using the library:
/*
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 Shield 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()) {
Serial.println("Failed to initialize GPS!");
while (1);
}
}
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();
}
}
GPS.available() just means if the GPS has data available do the thing. It's all good and you do not have an issue.
Ultimate GPS and MKR GPS Shield use different chip and different library. This thread is about MKR GPS and its official library. Do you have experience with the module and library in question ?
Thus, if the GPS has data available at the moment you query the GPS unit at once a second, then the GPS unit will provide you with data. If, at the exact moment you query the GPS and it does not have data, then shrug.
There are several GPS libraries that have been around for a few years, so it might be better to use them since there is a fair number of people experienced in thier use.
There are probably very few people around with knowledge of that particular MKR GPS Shield library, so you might need to rely on support direct from Arduino.