SparkFun GPS Dead Reckoning NEO-M8U Hookup Guide

Contributors: bboyho, Elias The Sparkiest
Favorited Favorite 3

Example 2 - IMU Data

After you have your sensor calibrated (see example 1), you can now poll the internal IMU to see what data is being fed to the GNSS calculations. Open the second example (located in File Examples > SparkFun u-blox GNSS Arduino Library > Dead Reckoning > Example2_getIMUData) to follow along! First, the sketch checks to see that the board is calibrated before it attempts to read IMU data.

void setup()
  while (!Serial); //Wait for user to open terminal
  Serial.println("SparkFun Ublox Example");


  if (myGNSS.begin() == false) //Connect to the Ublox module using Wire port
    Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
    while (1);

  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)

  if (myGNSS.getEsfInfo()){

    Serial.print("Fusion Mode: ");  

    if (myGNSS.imuMeas.fusionMode == 1){
      Serial.println("Fusion Mode is Initialized!");  
        else {
      Serial.println("Fusion Mode is either disabled or not initialized - Freezing!");  
            Serial.println("Please see Example 1 description at top for more information.");

Next, the sketch grabs that IMU data which is stored in a struct called imuMeas.

void loop()

  if (myGNSS.getEsfIns())
    Serial.print("X: ");
    Serial.print("Y: ");
    Serial.print("Z: ");
    Serial.print("X Acceleration: ");
    Serial.print("Y Acceleration: ");
    Serial.print("Z Acceleration: ");
        // These values also have "validity checks" that can be provided by the
        // ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald. 


If you have not already, select your Board (in this case the Arduino Uno), and associated COM port. Upload the code to the board and set the serial monitor to 115200 baud. This may be a good time to bring a friend along to drive if you decide to actively monitor the output. Otherwise, check out the data after taking the board for a stroll. Try driving around as the board senses the car's movement. Then park in a safe location with the engine turned off before inspecting the data.