diff --git a/examples/ZED-F9P/Example9_GetHighPrecisionGeodeticPacket/Example9_GetHighPrecisionGeodeticPacket.ino b/examples/ZED-F9P/Example9_GetHighPrecisionGeodeticPacket/Example9_GetHighPrecisionGeodeticPacket.ino deleted file mode 100644 index 24169b7..0000000 --- a/examples/ZED-F9P/Example9_GetHighPrecisionGeodeticPacket/Example9_GetHighPrecisionGeodeticPacket.ino +++ /dev/null @@ -1,93 +0,0 @@ -/* - Get the high precision geodetic solution - By: Nathan Seidle - Modified by: Steven Rowland and Paul Clark - SparkFun Electronics - Date: April 17th, 2020 - License: MIT. See license file for more information but you can - basically do whatever you want with this code. - - This example shows how to inspect the accuracy of the high-precision - positional solution. - - Feel like supporting open source hardware? - Buy a board from SparkFun! - ZED-F9P RTK2: https://www.sparkfun.com/products/15136 - NEO-M8P RTK: https://www.sparkfun.com/products/15005 - SAM-M8Q: https://www.sparkfun.com/products/15106 - - 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 "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS -SFE_UBLOX_GPS myGPS; - -long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module. - -void setup() -{ - Serial.begin(115200); - while (!Serial); //Wait for user to open terminal - - 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.enableDebugging(Serial); - - myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) - myGPS.setNavigationFrequency(20); //Set output to 20 times a second - - byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module - Serial.print("Current update rate:"); - Serial.println(rate); - - //myGPS.saveConfiguration(); //Save the current settings to flash and BBR -} - -void loop() -{ - //Query module only every second. Doing it more often will just cause I2C traffic. - //The module only responds when a new position is available - if (millis() - lastTime > 1000) - { - lastTime = millis(); //Update the timer - Serial.print("HP Lat: "); - int32_t latitude = myGPS.getHighResLatitude(); - Serial.print(latitude); - - Serial.print(", HP Lon: "); - int32_t longitude = myGPS.getHighResLongitude(); - Serial.print(longitude); - - Serial.print(", Horizontal Accuracy(0.1mm): "); - uint32_t accuracy = myGPS.getHorizontalAccuracy(); - Serial.print(accuracy); - - Serial.print(", Vertical Accuracy(0.1mm): "); - uint32_t verticalAccuracy = myGPS.getVerticalAccuracy(); - Serial.println(verticalAccuracy); - - Serial.print("Elipsoid(mm): "); - int32_t elipsoid = myGPS.getElipsoid(); - Serial.print(elipsoid); - - Serial.print(", Mean Sea Level(mm): "); - int32_t meanSeaLevel = myGPS.getMeanSeaLevel(); - Serial.print(meanSeaLevel); - - Serial.print(", Time of Week(millis): "); - uint32_t timeOfWeek = myGPS.getTimeOfWeek(); - Serial.println(timeOfWeek); - } - -} diff --git a/examples/ZED-F9P/Example9_GetHighPrecisionPositionUsingDouble/Example9_GetHighPrecisionPositionUsingDouble.ino b/examples/ZED-F9P/Example9_GetHighPrecisionPositionUsingDouble/Example9_GetHighPrecisionPositionUsingDouble.ino new file mode 100644 index 0000000..4fe7905 --- /dev/null +++ b/examples/ZED-F9P/Example9_GetHighPrecisionPositionUsingDouble/Example9_GetHighPrecisionPositionUsingDouble.ino @@ -0,0 +1,146 @@ +/* + Get the high precision geodetic solution for latitude and longitude using double + By: Nathan Seidle + Modified by: Paul Clark (PaulZC) + SparkFun Electronics + Date: April 17th, 2020 + License: MIT. See license file for more information but you can + basically do whatever you want with this code. + + This example shows how to inspect the accuracy of the high-precision + positional solution. Please see below for information about the units. + + ** This example will only work correctly on platforms which support 64-bit double ** + + Feel like supporting open source hardware? + Buy a board from SparkFun! + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 + NEO-M8P RTK: https://www.sparkfun.com/products/15005 + + Hardware Connections: + Plug a Qwiic cable into the GPS and (e.g.) a Redboard Artemis https://www.sparkfun.com/products/15444 + or an Artemis Thing Plus https://www.sparkfun.com/products/15574 + 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 + +#define myWire Wire // This will work on the Redboard Artemis and the Artemis Thing Plus using Qwiic +//#define myWire Wire1 // Uncomment this line if you are using the extra SCL1/SDA1 pins (D17 and D16) on the Thing Plus + +#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS +SFE_UBLOX_GPS myGPS; + +long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module. + +void setup() +{ + Serial.begin(115200); + while (!Serial); //Wait for user to open terminal + + myWire.begin(); + + //myGPS.enableDebugging(Serial); // Uncomment this line to enable debug messages + + if (myGPS.begin(myWire) == 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) + ; + } + + // Check that this platform supports 64-bit (8 byte) double + if (sizeof(double) < 8) + { + Serial.println(F("Warning! Your platform does not support 64-bit double.")); + Serial.println(F("The latitude and longitude will be inaccurate.")); + } + + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) + + //myGPS.setNavigationFrequency(20); //Set output to 20 times a second + + byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module + Serial.print("Current update rate: "); + Serial.println(rate); + + //myGPS.saveConfiguration(); //Save the current settings to flash and BBR +} + +void loop() +{ + //Query module only every second. + //The module only responds when a new position is available. + if (millis() - lastTime > 1000) + { + lastTime = millis(); //Update the timer + + // getHighResLatitude: returns the latitude from HPPOSLLH as an int32_t in degrees * 10^-7 + // getHighResLatitudeHp: returns the high resolution component of latitude from HPPOSLLH as an int8_t in degrees * 10^-9 + // getHighResLongitude: returns the longitude from HPPOSLLH as an int32_t in degrees * 10^-7 + // getHighResLongitudeHp: returns the high resolution component of longitude from HPPOSLLH as an int8_t in degrees * 10^-9 + // getElipsoid: returns the height above ellipsoid as an int32_t in mm + // getElipsoidHp: returns the high resolution component of the height above ellipsoid as an int8_t in mm * 10^-1 + // getMeanSeaLevel: returns the height above mean sea level as an int32_t in mm + // getMeanSeaLevelHp: returns the high resolution component of the height above mean sea level as an int8_t in mm * 10^-1 + // getHorizontalAccuracy: returns the horizontal accuracy estimate from HPPOSLLH as an uint32_t in mm * 10^-1 + + // First, let's collect the position data + int32_t latitude = myGPS.getHighResLatitude(); + int8_t latitudeHp = myGPS.getHighResLatitudeHp(); + int32_t longitude = myGPS.getHighResLongitude(); + int8_t longitudeHp = myGPS.getHighResLongitudeHp(); + int32_t ellipsoid = myGPS.getElipsoid(); + int8_t ellipsoidHp = myGPS.getElipsoidHp(); + int32_t msl = myGPS.getMeanSeaLevel(); + int8_t mslHp = myGPS.getMeanSeaLevelHp(); + uint32_t accuracy = myGPS.getHorizontalAccuracy(); + + // Defines storage for the lat and lon as double + double d_lat; // latitude + double d_lon; // longitude + + // Assemble the high precision latitude and longitude + d_lat = ((double)latitude) / 10000000.0; // Convert latitude from degrees * 10^-7 to degrees + d_lat += ((double)latitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 ) + d_lon = ((double)longitude) / 10000000.0; // Convert longitude from degrees * 10^-7 to degrees + d_lon += ((double)longitudeHp) / 1000000000.0; // Now add the high resolution component (degrees * 10^-9 ) + + // Print the lat and lon + Serial.print("Lat (deg): "); + Serial.print(d_lat, 9); + Serial.print(", Lon (deg): "); + Serial.print(d_lon, 9); + + // Now define float storage for the heights and accuracy + float f_ellipsoid; + float f_msl; + float f_accuracy; + + // Calculate the height above ellipsoid in mm * 10^-1 + f_ellipsoid = (ellipsoid * 10) + ellipsoidHp; + // Now convert to m + f_ellipsoid = f_ellipsoid / 10000.0; // Convert from mm * 10^-1 to m + + // Calculate the height above mean sea level in mm * 10^-1 + f_msl = (msl * 10) + mslHp; + // Now convert to m + f_msl = f_msl / 10000.0; // Convert from mm * 10^-1 to m + + // Convert the horizontal accuracy (mm * 10^-1) to a float + f_accuracy = accuracy; + // Now convert to m + f_accuracy = f_accuracy / 10000.0; // Convert from mm * 10^-1 to m + + // Finally, do the printing + Serial.print(", Ellipsoid (m): "); + Serial.print(f_ellipsoid, 4); // Print the ellipsoid with 4 decimal places + + Serial.print(", Mean Sea Level (m): "); + Serial.print(f_msl, 4); // Print the mean sea level with 4 decimal places + + Serial.print(", Accuracy (m): "); + Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places + } +}