This repository was archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathExample2_getIMUData.ino
84 lines (67 loc) · 2.48 KB
/
Example2_getIMUData.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
By: Elias Santistevan
SparkFun Electronics
Date: May, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
Feel like supporting open source hardware?
Buy a board from SparkFun!
NEO-M8U: https://www.sparkfun.com/products/16329
ZED-F9R: https://www.sparkfun.com/products/16344
Hardware Connections:
Plug a Qwiic cable into the GPS and a Redboard Qwiic
If you don't have a platform with a Qwiic connection use the
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
After calibrating the module, also known as "Fusion Mode", you can get
data directly from the IMU. This data is integrated directly into the GNSS
output, but is provided by the module as well.
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
SFE_UBLOX_GPS myGPS;
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");
Wire.begin();
if (myGPS.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);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
if (myGPS.getEsfInfo()){
Serial.print("Fusion Mode: ");
Serial.println(myGPS.imuMeas.fusionMode);
if (myGPS.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.");
}
}
}
void loop()
{
if (myGPS.getEsfIns())
{
Serial.print("X: ");
Serial.println(myGPS.imuMeas.xAngRate);
Serial.print("Y: ");
Serial.println(myGPS.imuMeas.yAngRate);
Serial.print("Z: ");
Serial.println(myGPS.imuMeas.zAngRate);
Serial.print("X Acceleration: ");
Serial.println(myGPS.imuMeas.xAccel);
Serial.print("Y Acceleration: ");
Serial.println(myGPS.imuMeas.yAccel);
Serial.print("Z Acceleration: ");
Serial.println(myGPS.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);
}