Skip to content

Release candidate update #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ void loop()
Serial.print(myGNSS.getMinute());
Serial.print(":");
Serial.print(myGNSS.getSecond());
Serial.print(".");
Serial.print(myGNSS.getNanosecond());
Serial.print(" nanoseconds: ");
Serial.print(myGNSS.getNanosecond()); // Nanoseconds can be negative

myGNSS.flushPVT();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void loop()
Serial.print("0");
Serial.print(mseconds);

Serial.print(" nanoSeconds: ");
Serial.print(" nanoseconds: ");
Serial.print(myGNSS.getNanosecond());

Serial.println();
Expand Down
91 changes: 91 additions & 0 deletions examples/Example26_End/Example26_End.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
Demonstrating how to use "end"
By: Paul Clark
SparkFun Electronics
Date: April 1st, 2021
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to use the end function.
End will stop all automatic message processing and free (nearly) all used RAM.
The file buffer is deleted (if it exists).

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 GNSS 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 <Wire.h> //Needed for I2C to GNSS

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
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

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.saveConfiguration(); //Optional: Save the current settings to flash and BBR

myGNSS.end(); // Call end now just because we can - it won't do much as we haven't used any automatic messages
}

void loop()
{
// Allocate 128 bytes for file storage - this checks that issue #20 has been resolved
// Allocating only 128 bytes will let this code run on the ATmega328P
// If your processor has plenty of RAM, you can increase this to something useful like 16KB
myGNSS.setFileBufferSize(128);

if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected. Freezing."));
while (1);
}

Serial.print(F("The file buffer size is: "));
Serial.println(myGNSS.getFileBufferSize());

// Request Position, Velocity, Time
// RAM will be allocated for PVT message processing
// getPVT will return true is fresh PVT data was received and processed
if (myGNSS.getPVT())
{
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);

long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));

long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.println(F(" (mm)"));
}

// Calling end will free the RAM allocated for file storage and PVT processing
// Calling end is optional. You can comment the next line if you want to.
myGNSS.end();
}
90 changes: 90 additions & 0 deletions examples/Example27_MultipleRates/Example27_MultipleRates.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
Configuring the GNSS to produce multiple messages at different rates
By: Paul Clark
SparkFun Electronics
Date: April 1st, 2021
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example shows how to configure the U-Blox GNSS to output multiple messages at different rates:
PVT is output once per measurement;
POS_ECEF is output every second measurement;
VEL_NED is output every third measurement.

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 GNSS 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 <Wire.h> //Needed for I2C to GNSS

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
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();

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.setMeasurementRate(1000); //Produce a measurement every 1000ms
myGNSS.setNavigationRate(1); //Produce a navigation solution every measurement

myGNSS.setAutoPVTrate(1); //Tell the GNSS to "send" each PVT solution every measurement
//myGNSS.setAutoPOSECEFrate(2); //Tell the GNSS to "send" each POS_ECEF solution every second measurement
myGNSS.setAutoNAVVELNEDrate(3); //Tell the GNSS to "send" each VEL_NED solution every third measurement
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
}

void loop()
{
// Calling getPVT returns true if there actually is a fresh navigation solution available.
if (myGNSS.getPVT())
{
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);

long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));

long altitude = myGNSS.getAltitude();
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.println(F(" (mm)"));
}

// Calling getVELNED returns true if there actually is fresh velocity data available.
if (myGNSS.getNAVVELNED())
{
Serial.print(F("velN: "));
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velN / 100.0, 2); // convert velN to m/s

Serial.print(F(" velE: "));
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velE / 100.0, 2); // convert velE to m/s

Serial.print(F(" velD: "));
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velD / 100.0, 2); // convert velD to m/s
Serial.println(F(" (m/s)"));

myGNSS.flushNAVVELNED(); //Mark all the data as read/stale so we get fresh data next time
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ void loop()
Serial.print("Lat (deg): ");
Serial.print(lat_int); // Print the integer part of the latitude
Serial.print(".");
Serial.print(lat_frac); // Print the fractional part of the latitude
printFractional(lat_frac, 9); // Print the fractional part of the latitude with leading zeros
Serial.print(", Lon (deg): ");
Serial.print(lon_int); // Print the integer part of the latitude
Serial.print(".");
Serial.println(lon_frac); // Print the fractional part of the latitude
printFractional(lon_frac, 9); // Print the fractional part of the latitude with leading zeros
Serial.println();

// Now define float storage for the heights and accuracy
float f_ellipsoid;
Expand Down Expand Up @@ -152,3 +153,20 @@ void loop()
Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places
}
}

// Pretty-print the fractional part with leading zeros - without using printf
// (Only works with positive numbers)
void printFractional(int32_t fractional, uint8_t places)
{
if (places > 1)
{
for (uint8_t place = places - 1; place > 0; place--)
{
if (fractional < pow(10, place))
{
Serial.print("0");
}
}
}
Serial.print(fractional);
}
2 changes: 2 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ UBX_HNR_INS_data_t KEYWORD1

setPacketCfgPayloadSize KEYWORD2
begin KEYWORD2
end KEYWORD2
setI2CpollingWait KEYWORD2
setI2CTransactionSize KEYWORD2
getI2CTransactionSize KEYWORD2
Expand Down Expand Up @@ -81,6 +82,7 @@ checkCallbacks KEYWORD2
pushRawData KEYWORD2

setFileBufferSize KEYWORD2
getFileBufferSize KEYWORD2
extractFileBufferData KEYWORD2
fileBufferAvailable KEYWORD2
getMaxFileBufferAvail KEYWORD2
Expand Down
Loading