SparkFun GPS Dead Reckoning NEO-M8U Hookup Guide

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

language:c
void setup()
{
  Serial.begin(115200);
  while (!Serial); //Wait for user to open terminal
  Serial.println("SparkFun Ublox Example");

  Wire.begin();

  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: ");  
    Serial.println(myGNSS.imuMeas.fusionMode);  

    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.

language:c
void loop()
{

  if (myGNSS.getEsfIns())
  {
    Serial.print("X: ");
    Serial.println(myGNSS.imuMeas.xAngRate);  
    Serial.print("Y: ");
    Serial.println(myGNSS.imuMeas.yAngRate);  
    Serial.print("Z: ");
    Serial.println(myGNSS.imuMeas.zAngRate);  
    Serial.print("X Acceleration: ");
    Serial.println(myGNSS.imuMeas.xAccel);  
    Serial.print("Y Acceleration: ");
    Serial.println(myGNSS.imuMeas.yAccel);  
    Serial.print("Z Acceleration: ");
    Serial.println(myGNSS.imuMeas.zAccel);  
        // These values also have "validity checks" that can be provided by the
        // ublox library, add "Vald" to values: e.g. xAngRateVald or xAccelVald. 
  }

  delay(250);
}

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.