SparkFun GPS NEO-M9N Hookup Guide

Contributors: Elias The Sparkiest
Favorited Favorite 3

Example Code

We're just going to look at example two (i.e. "Example2_NMEAParsing.ino") which in my opinion, makes it clear the awesomeness of these GPS receivers. That is to say, talking to satellites and finding out where in the world you are.

#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

void setup()
  Serial.println("SparkFun u-blox Example");


  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

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 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.

This image shows a screenshot of the Arduino Serial terminal spitting out latitude and longitude data.

These are the coordinates for SparkFun HQ