|
| 1 | +/* |
| 2 | + By: Elias Santistevan |
| 3 | + SparkFun Electronics |
| 4 | + Date: May, 2020 |
| 5 | + License: MIT. See license file for more information but you can |
| 6 | + basically do whatever you want with this code. |
| 7 | +
|
| 8 | + Feel like supporting open source hardware? |
| 9 | + Buy a board from SparkFun! |
| 10 | + NEO-M8U: https://www.sparkfun.com/products/16329 |
| 11 | + ZED-F9R: https://www.sparkfun.com/products/16344 |
| 12 | +
|
| 13 | + Hardware Connections: |
| 14 | + Plug a Qwiic cable into the GPS and a Redboard Qwiic |
| 15 | + If you don't have a platform with a Qwiic connection use the |
| 16 | + SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) |
| 17 | + Open the serial monitor at 115200 baud to see the output |
| 18 | +
|
| 19 | + After calibrating the module and securing it to your vehicle such that it's |
| 20 | + stable within 2 degrees, and the board is oriented correctly with regards to |
| 21 | + the vehicle's frame, you can now read the vehicle's "attitude". The attitude |
| 22 | + includes the vehicle's heading, pitch, and roll. You can also check the |
| 23 | + accuracy of those readings. |
| 24 | +
|
| 25 | +*/ |
| 26 | + |
| 27 | +#include <Wire.h> //Needed for I2C to GPS |
| 28 | + |
| 29 | +#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS |
| 30 | +SFE_UBLOX_GPS myGPS; |
| 31 | + |
| 32 | +void setup() |
| 33 | +{ |
| 34 | + Serial.begin(115200); |
| 35 | + while (!Serial); //Wait for user to open terminal |
| 36 | + Serial.println("SparkFun Ublox Example"); |
| 37 | + |
| 38 | + Wire.begin(); |
| 39 | + |
| 40 | + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port |
| 41 | + { |
| 42 | + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
| 43 | + while (1); |
| 44 | + } |
| 45 | + |
| 46 | + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) |
| 47 | + |
| 48 | + if (myGPS.getEsfInfo()){ |
| 49 | + |
| 50 | + Serial.print("Fusion Mode: "); |
| 51 | + Serial.println(myGPS.imuMeas.fusionMode); |
| 52 | + |
| 53 | + if (myGPS.imuMeas.fusionMode == 1){ |
| 54 | + Serial.println("Fusion Mode is Initialized!"); |
| 55 | + } |
| 56 | + else { |
| 57 | + Serial.println("Fusion Mode is either disabled or not initialized - Freezing!"); |
| 58 | + Serial.println("Please see Example 1 description at top for more information."); |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +void loop() |
| 64 | +{ |
| 65 | + myGPS.getVehAtt(); // Give the sensor you want to check on. |
| 66 | + Serial.print("Roll: "); |
| 67 | + Serial.println(myGPS.vehAtt.roll); |
| 68 | + Serial.print("Pitch: "); |
| 69 | + Serial.println(myGPS.vehAtt.pitch); |
| 70 | + Serial.print("Heading: "); |
| 71 | + Serial.println(myGPS.vehAtt.heading); |
| 72 | + Serial.print("Roll Accuracy: "); |
| 73 | + Serial.println(myGPS.vehAtt.accRoll); |
| 74 | + Serial.print("Pitch Accuracy: "); |
| 75 | + Serial.println(myGPS.vehAtt.accPitch); |
| 76 | + Serial.print("Heading Accuracy: "); |
| 77 | + Serial.println(myGPS.vehAtt.accHeading); |
| 78 | +} |
| 79 | + |
| 80 | + |
0 commit comments