|
| 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, also known as "Fusion Mode", you can get |
| 20 | + data directly from the IMU. This example code walks you through trouble |
| 21 | + shooting or identifying the different states of any individual |
| 22 | + "external" (which include internal) sensors you've hooked up (vehicle speed |
| 23 | + sensor) or the internal IMU used by the modules. You can see if the sensor is |
| 24 | + being used, if it's calibrated, ready, what data type it returns, the state |
| 25 | + of the measurement etc. |
| 26 | +
|
| 27 | +*/ |
| 28 | + |
| 29 | +#include <Wire.h> //Needed for I2C to GPS |
| 30 | + |
| 31 | +#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS |
| 32 | +SFE_UBLOX_GPS myGPS; |
| 33 | + |
| 34 | +void setup() |
| 35 | +{ |
| 36 | + Serial.begin(115200); |
| 37 | + while (!Serial); //Wait for user to open terminal |
| 38 | + Serial.println(F("SparkFun Ublox Example")); |
| 39 | + |
| 40 | + Wire.begin(); |
| 41 | + |
| 42 | + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port |
| 43 | + { |
| 44 | + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
| 45 | + while (1); |
| 46 | + } |
| 47 | + |
| 48 | + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) |
| 49 | + |
| 50 | + // GetEsfInfo also gets the number of sensors used by the ublox module, this |
| 51 | + // includes (in the case of the ZED-F9R) wheel tick input from the vehicle |
| 52 | + // speed sensor attached to the module. |
| 53 | + if (myGPS.getEsfInfo()){ |
| 54 | + |
| 55 | + Serial.print(F("Fusion Mode: ")); |
| 56 | + Serial.println(myGPS.imuMeas.fusionMode); |
| 57 | + |
| 58 | + if (myGPS.imuMeas.fusionMode == 1){ |
| 59 | + Serial.println(F("Fusion Mode is Initialized!")); |
| 60 | + } |
| 61 | + else { |
| 62 | + Serial.println(F("Fusion Mode is either disabled or not initialized - Freezing!")); |
| 63 | + Serial.println(F("Please see Example 1 description at top for more information.")); |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +void loop() |
| 69 | +{ |
| 70 | + |
| 71 | + for(int i=1; i<=myGPS.ubloxSen.numSens; i++){ |
| 72 | + myGPS.getSensState(i); // Give the sensor you want to check on. |
| 73 | + Serial.print(F("Sensor Data Type: ")); //See ublox receiver description |
| 74 | + //or our hookup guide for information on the |
| 75 | + //return value. |
| 76 | + Serial.println(myGPS.ubloxSen.senType); |
| 77 | + Serial.print(F("Being Used: ")); |
| 78 | + Serial.println(myGPS.ubloxSen.isUsed); |
| 79 | + Serial.print(F("Is Ready: ")); |
| 80 | + Serial.println(myGPS.ubloxSen.isReady); |
| 81 | + Serial.print(F("Calibration Status: ")); |
| 82 | + Serial.println(myGPS.ubloxSen.calibStatus); |
| 83 | + Serial.print(F("Time Status: ")); |
| 84 | + Serial.println(myGPS.ubloxSen.timeStatus); |
| 85 | + Serial.print(F("Bad Measure: ")); |
| 86 | + Serial.println(myGPS.ubloxSen.timeStatus); |
| 87 | + Serial.print(F("Bad Time Tag: ")); |
| 88 | + Serial.println(myGPS.ubloxSen.badTag); |
| 89 | + Serial.print(F("Missed Measure : ")); |
| 90 | + Serial.println(myGPS.ubloxSen.missMeas); |
| 91 | + Serial.print(F("Noisy Measure: ")); |
| 92 | + Serial.println(myGPS.ubloxSen.noisyMeas); |
| 93 | + } |
| 94 | + |
| 95 | +} |
| 96 | + |
| 97 | + |
0 commit comments