Skip to content

Commit b20579e

Browse files
authored
Merge pull request #21 from sparkfun/release_candidate
v2.0.5
2 parents 7f38fcd + 02153c3 commit b20579e

File tree

10 files changed

+941
-147
lines changed

10 files changed

+941
-147
lines changed

Diff for: examples/Example16_Nanosecond_MaxOutput/Example16_Nanosecond_MaxOutput.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ void loop()
9999
Serial.print(myGNSS.getMinute());
100100
Serial.print(":");
101101
Serial.print(myGNSS.getSecond());
102-
Serial.print(".");
103-
Serial.print(myGNSS.getNanosecond());
102+
Serial.print(" nanoseconds: ");
103+
Serial.print(myGNSS.getNanosecond()); // Nanoseconds can be negative
104104

105105
myGNSS.flushPVT();
106106

Diff for: examples/Example16_PartialSecond_MaxOutput/Example16_PartialSecond_MaxOutput.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void loop()
110110
Serial.print("0");
111111
Serial.print(mseconds);
112112

113-
Serial.print(" nanoSeconds: ");
113+
Serial.print(" nanoseconds: ");
114114
Serial.print(myGNSS.getNanosecond());
115115

116116
Serial.println();

Diff for: examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Getting Unix Epoch Time and micros using u-blox commands
33
By: UT2UH
4-
Date: March 30th, 2021
4+
Date: March 31th, 2021
55
License: MIT. See license file for more information but you can
66
basically do whatever you want with this code.
77
@@ -69,8 +69,11 @@ void loop()
6969
// getUnixEpoch marks the PVT data as stale so you will get Unix time and PVT time on alternate seconds
7070

7171
uint32_t us; //microseconds returned by getUnixEpoch()
72-
uint32_t epoch = myGNSS.getUnixEpoch(us);
73-
Serial.print("Unix Epoch: ");
72+
uint32_t epoch = myGNSS.getUnixEpoch();
73+
Serial.print("Unix Epoch rounded: ");
74+
Serial.print(epoch, DEC);
75+
epoch = myGNSS.getUnixEpoch(us);
76+
Serial.print(" Exact Unix Epoch: ");
7477
Serial.print(epoch, DEC);
7578
Serial.print(" micros: ");
7679
Serial.println(us, DEC);
@@ -105,4 +108,4 @@ void loop()
105108
Serial.print(F(" SIV: "));
106109
Serial.println(SIV);
107110
}
108-
}
111+
}

Diff for: examples/Example26_End/Example26_End.ino

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
Demonstrating how to use "end"
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: April 1st, 2021
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to use the end function.
10+
End will stop all automatic message processing and free (nearly) all used RAM.
11+
The file buffer is deleted (if it exists).
12+
13+
Feel like supporting open source hardware?
14+
Buy a board from SparkFun!
15+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
16+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
17+
SAM-M8Q: https://www.sparkfun.com/products/15106
18+
19+
Hardware Connections:
20+
Plug a Qwiic cable into the GNSS and a BlackBoard
21+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
22+
Open the serial monitor at 115200 baud to see the output
23+
*/
24+
25+
#include <Wire.h> //Needed for I2C to GNSS
26+
27+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
28+
SFE_UBLOX_GNSS myGNSS;
29+
30+
void setup()
31+
{
32+
Serial.begin(115200);
33+
while (!Serial); //Wait for user to open terminal
34+
Serial.println("SparkFun u-blox Example");
35+
36+
Wire.begin();
37+
38+
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39+
40+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
41+
{
42+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
43+
while (1);
44+
}
45+
46+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
47+
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
48+
49+
myGNSS.end(); // Call end now just because we can - it won't do much as we haven't used any automatic messages
50+
}
51+
52+
void loop()
53+
{
54+
// Allocate 128 bytes for file storage - this checks that issue #20 has been resolved
55+
// Allocating only 128 bytes will let this code run on the ATmega328P
56+
// If your processor has plenty of RAM, you can increase this to something useful like 16KB
57+
myGNSS.setFileBufferSize(128);
58+
59+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
60+
{
61+
Serial.println(F("u-blox GNSS not detected. Freezing."));
62+
while (1);
63+
}
64+
65+
Serial.print(F("The file buffer size is: "));
66+
Serial.println(myGNSS.getFileBufferSize());
67+
68+
// Request Position, Velocity, Time
69+
// RAM will be allocated for PVT message processing
70+
// getPVT will return true is fresh PVT data was received and processed
71+
if (myGNSS.getPVT())
72+
{
73+
long latitude = myGNSS.getLatitude();
74+
Serial.print(F("Lat: "));
75+
Serial.print(latitude);
76+
77+
long longitude = myGNSS.getLongitude();
78+
Serial.print(F(" Long: "));
79+
Serial.print(longitude);
80+
Serial.print(F(" (degrees * 10^-7)"));
81+
82+
long altitude = myGNSS.getAltitude();
83+
Serial.print(F(" Alt: "));
84+
Serial.print(altitude);
85+
Serial.println(F(" (mm)"));
86+
}
87+
88+
// Calling end will free the RAM allocated for file storage and PVT processing
89+
// Calling end is optional. You can comment the next line if you want to.
90+
myGNSS.end();
91+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
Configuring the GNSS to produce multiple messages at different rates
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: April 1st, 2021
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to configure the U-Blox GNSS to output multiple messages at different rates:
10+
PVT is output every second;
11+
POSECEF is output every five seconds;
12+
VELNED is output every ten seconds.
13+
14+
Feel like supporting open source hardware?
15+
Buy a board from SparkFun!
16+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
17+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
18+
SAM-M8Q: https://www.sparkfun.com/products/15106
19+
20+
Hardware Connections:
21+
Plug a Qwiic cable into the GNSS and a BlackBoard
22+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
23+
Open the serial monitor at 115200 baud to see the output
24+
*/
25+
26+
#include <Wire.h> //Needed for I2C to GNSS
27+
28+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
29+
SFE_UBLOX_GNSS myGNSS;
30+
31+
void setup()
32+
{
33+
Serial.begin(115200);
34+
while (!Serial); //Wait for user to open terminal
35+
Serial.println("SparkFun u-blox Example");
36+
37+
Wire.begin();
38+
39+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
40+
{
41+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
42+
while (1);
43+
}
44+
45+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
46+
myGNSS.setMeasurementRate(1000); //Produce a measurement every 1000ms
47+
myGNSS.setNavigationRate(1); //Produce a navigation solution every measurement
48+
49+
myGNSS.setAutoPVTrate(1); //Tell the GNSS to send the PVT solution every measurement
50+
myGNSS.setAutoNAVPOSECEFrate(5); //Tell the GNSS to send each POSECEF solution every 5th measurement
51+
myGNSS.setAutoNAVVELNEDrate(10); //Tell the GNSS to send each VELNED solution every 10th measurement
52+
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
53+
}
54+
55+
void loop()
56+
{
57+
// Calling getPVT returns true if there actually is a fresh navigation solution available.
58+
if (myGNSS.getPVT())
59+
{
60+
long latitude = myGNSS.getLatitude();
61+
Serial.print(F("Lat: "));
62+
Serial.print(latitude);
63+
64+
long longitude = myGNSS.getLongitude();
65+
Serial.print(F(" Long: "));
66+
Serial.print(longitude);
67+
Serial.print(F(" (degrees * 10^-7)"));
68+
69+
long altitude = myGNSS.getAltitude();
70+
Serial.print(F(" Alt: "));
71+
Serial.print(altitude);
72+
Serial.println(F(" (mm)"));
73+
}
74+
75+
// Calling getNAVPOSECEF returns true if there actually is a fresh position solution available.
76+
if (myGNSS.getNAVPOSECEF())
77+
{
78+
Serial.print(F("ecefX: "));
79+
Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefX / 100.0, 2); // convert ecefX to m
80+
81+
Serial.print(F(" ecefY: "));
82+
Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefY / 100.0, 2); // convert ecefY to m
83+
84+
Serial.print(F(" ecefZ: "));
85+
Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefZ / 100.0, 2); // convert ecefY to m
86+
Serial.println(F(" (m)"));
87+
88+
myGNSS.flushNAVPOSECEF(); //Mark all the data as read/stale so we get fresh data next time
89+
}
90+
91+
// Calling getNAVVELNED returns true if there actually is fresh velocity data available.
92+
if (myGNSS.getNAVVELNED())
93+
{
94+
Serial.print(F("velN: "));
95+
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velN / 100.0, 2); // convert velN to m/s
96+
97+
Serial.print(F(" velE: "));
98+
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velE / 100.0, 2); // convert velE to m/s
99+
100+
Serial.print(F(" velD: "));
101+
Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velD / 100.0, 2); // convert velD to m/s
102+
Serial.println(F(" (m/s)"));
103+
104+
myGNSS.flushNAVVELNED(); //Mark all the data as read/stale so we get fresh data next time
105+
}
106+
}

Diff for: examples/ZED-F9P/Example10_GetHighPrecisionPositionAndAccuracy/Example10_GetHighPrecisionPositionAndAccuracy.ino

+20-2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ void loop()
115115
Serial.print("Lat (deg): ");
116116
Serial.print(lat_int); // Print the integer part of the latitude
117117
Serial.print(".");
118-
Serial.print(lat_frac); // Print the fractional part of the latitude
118+
printFractional(lat_frac, 9); // Print the fractional part of the latitude with leading zeros
119119
Serial.print(", Lon (deg): ");
120120
Serial.print(lon_int); // Print the integer part of the latitude
121121
Serial.print(".");
122-
Serial.println(lon_frac); // Print the fractional part of the latitude
122+
printFractional(lon_frac, 9); // Print the fractional part of the latitude with leading zeros
123+
Serial.println();
123124

124125
// Now define float storage for the heights and accuracy
125126
float f_ellipsoid;
@@ -152,3 +153,20 @@ void loop()
152153
Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places
153154
}
154155
}
156+
157+
// Pretty-print the fractional part with leading zeros - without using printf
158+
// (Only works with positive numbers)
159+
void printFractional(int32_t fractional, uint8_t places)
160+
{
161+
if (places > 1)
162+
{
163+
for (uint8_t place = places - 1; place > 0; place--)
164+
{
165+
if (fractional < pow(10, place))
166+
{
167+
Serial.print("0");
168+
}
169+
}
170+
}
171+
Serial.print(fractional);
172+
}

0 commit comments

Comments
 (0)