
#include <Wire.h> //Needed for I2C to GPS
#include "SparkFun_Ublox_Arduino_Library.h" //Click here to get the library: http://librarymanag
er/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;
void setup()
{
Serial.begin(115200);
Serial.println("SparkFun Ublox Example");
Wire.begin();
if (myGPS.begin() == false)
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezi
ng."));
while (1);
}
//This will pipe all NMEA sentences to the serial port so we can see them
myGPS.setNMEAOutputPort(Serial);
}
void loop()
{
myGPS.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 you'll have to wait ~29s to get a lock onto any satellites. After that first lock, the backup
battery on the board will provide power to some internal systems that will allow for a
hot start
the next time you
turn on the board. The
hot start
only lasts four hours, but allows you to get a lock within one second. After you get
a lock the serial terminal will start listing longitude and latitude coordinates, as seen below. Make sure to set the
serial monitor to
115200 baud
.