diff --git a/examples/Basics/Example33_NAVSAT/Example33_NAVSAT.ino b/examples/Basics/Example33_NAVSAT/Example33_NAVSAT.ino new file mode 100644 index 0000000..23fe545 --- /dev/null +++ b/examples/Basics/Example33_NAVSAT/Example33_NAVSAT.ino @@ -0,0 +1,109 @@ +/* + Polling NAV SAT + By: Paul Clark + SparkFun Electronics + Date: June 5th, 2023 + License: MIT. See license file for more information. + + Feel like supporting open source hardware? + Buy a board from SparkFun! + SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136 + SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481 + SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037 + SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719 + SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344 + + Hardware Connections: + Plug a Qwiic cable into the GPS and a BlackBoard + 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 +*/ + +#include //Needed for I2C to GPS + +#include //http://librarymanager/All#SparkFun_u-blox_GNSS_v3 +SFE_UBLOX_GNSS myGNSS; + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + Serial.println("SparkFun u-blox Example"); + + Wire.begin(); + + //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial + + myGNSS.setPacketCfgPayloadSize(UBX_NAV_SAT_MAX_LEN); // Allocate extra RAM to store the full NAV SAT data + + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port + { + Serial.println(F("u-blox GNSS 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) + myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR + + myGNSS.setNavigationFrequency(1); //Produce one solution per second +} + +void loop() +{ + if (myGNSS.getNAVSAT()) // Poll the latest NAV SAT data + { + Serial.println(); + + // See u-blox_structs.h for the full definition of UBX_NAV_SAT_data_t + Serial.print(F("New NAV SAT data received. It contains data for ")); + Serial.print(myGNSS.packetUBXNAVSAT->data.header.numSvs); + if (myGNSS.packetUBXNAVSAT->data.header.numSvs == 1) + Serial.println(F(" SV.")); + else + Serial.println(F(" SVs.")); + + // Just for giggles, print the signal strength for each SV as a barchart + for (uint16_t block = 0; block < myGNSS.packetUBXNAVSAT->data.header.numSvs; block++) // For each SV + { + switch (myGNSS.packetUBXNAVSAT->data.blocks[block].gnssId) // Print the GNSS ID + { + case 0: + Serial.print(F("GPS ")); + break; + case 1: + Serial.print(F("SBAS ")); + break; + case 2: + Serial.print(F("Galileo ")); + break; + case 3: + Serial.print(F("BeiDou ")); + break; + case 4: + Serial.print(F("IMES ")); + break; + case 5: + Serial.print(F("QZSS ")); + break; + case 6: + Serial.print(F("GLONASS ")); + break; + default: + Serial.print(F("UNKNOWN ")); + break; + } + + Serial.print(myGNSS.packetUBXNAVSAT->data.blocks[block].svId); // Print the SV ID + + if (myGNSS.packetUBXNAVSAT->data.blocks[block].svId < 10) Serial.print(F(" ")); + else if (myGNSS.packetUBXNAVSAT->data.blocks[block].svId < 100) Serial.print(F(" ")); + else Serial.print(F(" ")); + + // Print the signal strength as a bar chart + for (uint8_t cno = 0; cno < myGNSS.packetUBXNAVSAT->data.blocks[block].cno; cno++) + Serial.print(F("=")); + + Serial.println(); + } + } +} diff --git a/examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino b/examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino index 5bcae7b..e264633 100644 --- a/examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino +++ b/examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino @@ -14,12 +14,9 @@ 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 and securing it to your vehicle such that it's - stable within 2 degrees, and the board is oriented correctly with regards to - the vehicle's frame, you can now read the vehicle's "attitude". The attitude - includes the vehicle's heading, pitch, and roll. You can also check the - accuracy of those readings. - + getEsfAlignment (UBX-ESF-ALG) reports the status and alignment angles of the IMU within the vehicle. + These define the rotation of the IMU frame within the vehicle (installation frame) - not the heading + of the vehicle itself. The vehicle attitude solution is reported separately by getNAVATT (UBX-NAV-ATT). */ #include //Needed for I2C to GNSS @@ -44,6 +41,8 @@ void setup() myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + myGNSS.setESFAutoAlignment(true); //Enable Automatic IMU-mount Alignment + if (myGNSS.getEsfInfo()){ Serial.print(F("Fusion Mode: ")); @@ -64,13 +63,15 @@ void loop() // ESF data is produced at the navigation rate, so by default we'll get fresh data once per second if (myGNSS.getEsfAlignment()) // Poll new ESF ALG data { - Serial.print(F("Status: ")); - Serial.print(myGNSS.packetUBXESFALG->data.flags.bits.status); + Serial.print(F("IMU-Mount Alignment: On/Off: ")); + Serial.print(myGNSS.packetUBXESFALG->data.flags.bits.autoMntAlgOn); + Serial.print(F(" Status: ")); + Serial.print(myGNSS.packetUBXESFALG->data.flags.bits.status); Serial.print(F(" Roll: ")); Serial.print(myGNSS.getESFroll(), 2); // Use the helper function to get the roll in degrees Serial.print(F(" Pitch: ")); Serial.print(myGNSS.getESFpitch(), 2); // Use the helper function to get the pitch in degrees - Serial.print(F(" Heading: ")); + Serial.print(F(" Yaw: ")); Serial.print(myGNSS.getESFyaw(), 2); // Use the helper function to get the yaw in degrees Serial.print(F(" Errors: ")); Serial.print(myGNSS.packetUBXESFALG->data.error.bits.tiltAlgError); @@ -78,5 +79,15 @@ void loop() Serial.println(myGNSS.packetUBXESFALG->data.error.bits.angleError); } + if (myGNSS.getNAVATT()) // Poll new NAV ATT data + { + Serial.print(F("Vehicle Attitude: Roll: ")); + Serial.print(myGNSS.getATTroll(), 2); // Use the helper function to get the roll in degrees + Serial.print(F(" Pitch: ")); + Serial.print(myGNSS.getATTpitch(), 2); // Use the helper function to get the pitch in degrees + Serial.print(F(" Heading: ")); + Serial.println(myGNSS.getATTheading(), 2); // Use the helper function to get the heading in degrees + } + delay(250); } diff --git a/library.properties b/library.properties index 479639c..3d1d2a3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS v3 -version=3.0.15 +version=3.0.16 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules

diff --git a/src/u-blox_structs.h b/src/u-blox_structs.h index f03dac6..7b90c5d 100644 --- a/src/u-blox_structs.h +++ b/src/u-blox_structs.h @@ -432,6 +432,20 @@ typedef struct struct { uint8_t invalidLlh : 1; // 1 = Invalid lon, lat, height and hMSL + uint8_t lastCorrectionAge : 4; // Age of the most recently received differential correction: + // 0: Not available + // 1: Age between 0 and 1 second + // 2: Age between 1 (inclusive) and 2 seconds + // 3: Age between 2 (inclusive) and 5 seconds + // 4: Age between 5 (inclusive) and 10 seconds + // 5: Age between 10 (inclusive) and 15 seconds + // 6: Age between 15 (inclusive) and 20 seconds + // 7: Age between 20 (inclusive) and 30 seconds + // 8: Age between 30 (inclusive) and 45 seconds + // 9: Age between 45 (inclusive) and 60 seconds + // 10: Age between 60 (inclusive) and 90 seconds + // 11: Age between 90 (inclusive) and 120 seconds + // >=12: Age greater or equal than 120 seconds } bits; } flags3; uint8_t reserved1[5];