SparkFun GPS Breakout (ZOE-M8Q and SAM-M8Q) Hookup Guide
Example Code
We're just going to look at example two (i.e. "Example2_NMEAParsing.ino" of the Arduino library) which in my opinion, makes it clear the awesomeness of these GNSS receivers. That is to say, talking to satellites and finding out where in the world you are.
language:c
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;
void setup()
{
Serial.begin(115200);
Serial.println("SparkFun u-blox Example");
Wire.begin();
if (myGNSS.begin() == false)
{
Serial.println(F("u-blox GNSS module not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
//This will pipe all NMEA sentences to the serial port so we can see them
myGNSS.setNMEAOutputPort(Serial);
}
void loop()
{
myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in.
delay(250); //Don't pound too hard on the I2C bus
}
When you upload this code, the GNSS antenna will need a clear view of the sky and you'll have to wait ~29s to get an initial position fix. After the initial position fix, the backup battery on the board will provide power to some internal systems and store the ephemeris data. This will allow for a hot start the next time you turn on the GNSS receiver. The ephemeris data is only valid for about four hours, but it allows you to get a fix within a few seconds. After you get a position fix, the serial terminal will start listing longitude and latitude coordinates, as seen below. Make sure to set the serial monitor to 115200 baud.
