Skip to content

Commit 2a8f162

Browse files
committed
v3.0.10 - add auto support for RTCM 1005
1 parent f1bebf3 commit 2a8f162

File tree

7 files changed

+395
-74
lines changed

7 files changed

+395
-74
lines changed

examples/ZED-F9P/Example24_getLatestRTCM1005/Example24_getLatestRTCM1005.ino

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: May 4th, 2023
66
License: MIT. See license file for more information.
77
8-
This example shows how to turn on/off the RTCM sentences being output over I2C.
8+
This example shows how to perform a survey-in and then enable RTCM sentences over I2C.
99
It then demonstrates how to use the new getLatestRTCM1005 function to retrieve the latest RTCM 1005 message.
1010
getLatestRTCM1005 returns immediately - it is not blocking.
1111
It returns:
@@ -32,6 +32,8 @@ SFE_UBLOX_GNSS myGNSS;
3232
void setup()
3333
{
3434

35+
delay(1000);
36+
3537
Serial.begin(115200);
3638
Serial.println(F("SparkFun u-blox GNSS Example"));
3739

@@ -45,10 +47,104 @@ void setup()
4547
delay(1000);
4648
}
4749

50+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
51+
52+
//We need to do a survey-in before the ZED will generate RTCM 1005
53+
54+
//Check if Survey is in Progress before initiating one
55+
bool response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
56+
57+
if (response == false) // Check if fresh data was received
58+
{
59+
Serial.println(F("Failed to get Survey In status. Freezing..."));
60+
while (1); //Freeze
61+
}
62+
63+
if (myGNSS.getSurveyInActive() == true) // Use the helper function
64+
{
65+
Serial.print(F("Survey already in progress."));
66+
}
67+
else
68+
{
69+
//Start survey - define the minimum observationTime and requiredAccuracy
70+
uint32_t observationTime = 60; float requiredAccuracy = 5.0; // 60 seconds, 5.0m
71+
72+
response = myGNSS.enableSurveyModeFull(observationTime, requiredAccuracy, VAL_LAYER_RAM); //Enable Survey in. Save setting in RAM layer only (not BBR)
73+
74+
if (response == false)
75+
{
76+
Serial.println(F("Survey start failed. Freezing..."));
77+
while (1); //Freeze
78+
}
79+
80+
Serial.println(F("Survey started."));
81+
Serial.print(F("This will run until "));
82+
Serial.print(observationTime);
83+
Serial.print(F("s have passed _and_ better than "));
84+
Serial.print(requiredAccuracy, 2);
85+
Serial.println(F("m accuracy is achieved."));
86+
Serial.println();
87+
}
88+
89+
while(Serial.available()) Serial.read(); //Clear buffer
90+
91+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
92+
93+
//Wait for survey to complete
94+
95+
while (myGNSS.getSurveyInValid() == false) // Call the helper function
96+
{
97+
if(Serial.available())
98+
{
99+
byte incoming = Serial.read();
100+
if (incoming == 'x')
101+
{
102+
//Stop survey mode
103+
response = myGNSS.disableSurveyMode(); //Disable survey
104+
Serial.println(F("Survey stopped"));
105+
break;
106+
}
107+
}
108+
109+
response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
110+
111+
if (response == true) // Check if fresh data was received
112+
{
113+
Serial.print(F("\r\nPress x to end survey - "));
114+
Serial.print(F("Time elapsed: "));
115+
Serial.print((String)myGNSS.getSurveyInObservationTimeFull()); // Call the helper function
116+
Serial.print(F(" ("));
117+
Serial.print((String)myGNSS.packetUBXNAVSVIN->data.dur); // Read the survey-in duration directly from packetUBXNAVSVIN
118+
119+
Serial.print(F(") Accuracy: "));
120+
Serial.print((String)myGNSS.getSurveyInMeanAccuracy()); // Call the helper function
121+
Serial.print(F(" ("));
122+
// Read the mean accuracy directly from packetUBXNAVSVIN and manually convert from mm*0.1 to m
123+
float meanAcc = ((float)myGNSS.packetUBXNAVSVIN->data.meanAcc) / 10000.0;
124+
Serial.print((String)meanAcc);
125+
Serial.println(F(")"));
126+
}
127+
else
128+
{
129+
Serial.println(F("\r\nSVIN request failed"));
130+
}
131+
}
132+
133+
Serial.println(F("Base survey complete. Configuring RTCM."));
134+
135+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
136+
48137
//Disable or enable various RTCM sentences over the I2C interface
138+
49139
myGNSS.setI2COutput(COM_TYPE_NMEA | COM_TYPE_UBX | COM_TYPE_RTCM3); // Turn on UBX, NMEA and RTCM sentences on I2C
50-
myGNSS.newCfgValset(VAL_LAYER_RAM_BBR); // Use cfgValset to disable / enable individual RTCM messages
51-
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); // Enable RTCM 1005 at current navigation rate
140+
141+
myGNSS.newCfgValset(VAL_LAYER_RAM); // Use cfgValset to disable / enable individual RTCM messages. Save setting in RAM layer only (not BBR)
142+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); // Enable RTCM 1005 (Stationary Antenna Reference Point, No Height Information) at current navigation rate
143+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_I2C, 1); // Enable RTCM 1074 (GPS MSM4). RTCM 1077 (GPS MSM7) is higher resolution but is almost twice as many bytes
144+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1084_I2C, 1); // Enable RTCM 1084 (GLONASS MSM4). RTCM 1087 (GLONASS MSM7) is higher resolution
145+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1094_I2C, 1); // Enable RTCM 1094 (Galileo MSM4). RTCM 1097 (Galileo MSM7) is higher resolution
146+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_I2C, 1); // Enable RTCM 1124 (BeiDou MSM4). RTCM 1127 (BeiDou MSM7) is higher resolution
147+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); // Enable RTCM message 1230 (GLONASS L1 and L2 Code-Phase Biases) every 10 seconds
52148
if (myGNSS.sendCfgValset()) // Send the configuration VALSET
53149
Serial.println(F("RTCM messages were configured successfully"));
54150
else
@@ -62,6 +158,8 @@ void setup()
62158
Serial.println(F("double is not 64-bit. ECEF resolution may be limited!"));
63159
}
64160

161+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
162+
65163
void loop()
66164
{
67165
// getLatestRTCM1005 calls checkUblox for us. We don't need to do it here
@@ -86,7 +184,9 @@ void loop()
86184
double z = data.AntennaReferencePointECEFZ;
87185
z /= 10000.0; // Convert to m
88186

89-
Serial.print(F("Latest RTCM 1005: ARP ECEF-X: "));
187+
Serial.print(F("Latest RTCM "));
188+
Serial.print(data.MessageNumber);
189+
Serial.print(F(": ARP ECEF-X: "));
90190
Serial.print(x, 4); // 4 decimal places
91191
Serial.print(F(" Y: "));
92192
Serial.print(y, 4); // 4 decimal places
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
Get the RTCM 1005 sentence using a callback
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: May 4th, 2023
6+
License: MIT. See license file for more information.
7+
8+
This example shows how to perform a survey-in and then enable RTCM sentences over I2C.
9+
It then demonstrates how to use a callback to retrieve the latest RTCM 1005 message.
10+
11+
Feel like supporting open source hardware?
12+
Buy a board from SparkFun!
13+
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
14+
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
15+
16+
Hardware Connections:
17+
Plug a Qwiic cable into the GNSS and a RedBoard
18+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
19+
Open the serial monitor at 115200 baud to see the output
20+
*/
21+
22+
#include <Wire.h> //Needed for I2C to GNSS
23+
24+
#include <SparkFun_u-blox_GNSS_v3.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS_v3
25+
SFE_UBLOX_GNSS myGNSS;
26+
27+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
28+
29+
// Callback: newRTCM1005 will be called when new RTCM 1005 data arrives
30+
// See u-blox_structs.h for the full definition of RTCM_1005_data_t
31+
// _____ You can use any name you like for the callback. Use the same name when you call setRTCM1005callbackPtr
32+
// / _____ This _must_ be RTCM_1005_data_t
33+
// | / _____ You can use any name you like for the struct
34+
// | | /
35+
// | | |
36+
void newRTCM1005(RTCM_1005_data_t *rtcmStruct)
37+
{
38+
Serial.println();
39+
40+
double x = rtcmStruct->AntennaReferencePointECEFX;
41+
x /= 10000.0; // Convert to m
42+
double y = rtcmStruct->AntennaReferencePointECEFY;
43+
y /= 10000.0; // Convert to m
44+
double z = rtcmStruct->AntennaReferencePointECEFZ;
45+
z /= 10000.0; // Convert to m
46+
47+
Serial.print(F("New RTCM "));
48+
Serial.print(rtcmStruct->MessageNumber);
49+
Serial.print(F(" data: ARP ECEF-X: "));
50+
Serial.print(x, 4); // 4 decimal places
51+
Serial.print(F(" Y: "));
52+
Serial.print(y, 4); // 4 decimal places
53+
Serial.print(F(" Z: "));
54+
Serial.print(z, 4); // 4 decimal places
55+
56+
Serial.println();
57+
}
58+
59+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
60+
61+
void setup()
62+
{
63+
64+
delay(1000);
65+
66+
Serial.begin(115200);
67+
Serial.println(F("SparkFun u-blox GNSS Example"));
68+
69+
Wire.begin();
70+
71+
//myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
72+
73+
while (myGNSS.begin() == false)
74+
{
75+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
76+
delay(1000);
77+
}
78+
79+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
80+
81+
//We need to do a survey-in before the ZED will generate RTCM 1005
82+
83+
//Check if Survey is in Progress before initiating one
84+
bool response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
85+
86+
if (response == false) // Check if fresh data was received
87+
{
88+
Serial.println(F("Failed to get Survey In status. Freezing..."));
89+
while (1); //Freeze
90+
}
91+
92+
if (myGNSS.getSurveyInActive() == true) // Use the helper function
93+
{
94+
Serial.print(F("Survey already in progress."));
95+
}
96+
else
97+
{
98+
//Start survey - define the minimum observationTime and requiredAccuracy
99+
uint32_t observationTime = 60; float requiredAccuracy = 5.0; // 60 seconds, 5.0m
100+
101+
response = myGNSS.enableSurveyModeFull(observationTime, requiredAccuracy, VAL_LAYER_RAM); //Enable Survey in. Save setting in RAM layer only (not BBR)
102+
103+
if (response == false)
104+
{
105+
Serial.println(F("Survey start failed. Freezing..."));
106+
while (1); //Freeze
107+
}
108+
109+
Serial.println(F("Survey started."));
110+
Serial.print(F("This will run until "));
111+
Serial.print(observationTime);
112+
Serial.print(F("s have passed _and_ better than "));
113+
Serial.print(requiredAccuracy, 2);
114+
Serial.println(F("m accuracy is achieved."));
115+
Serial.println();
116+
}
117+
118+
while(Serial.available()) Serial.read(); //Clear buffer
119+
120+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
121+
122+
//Wait for survey to complete
123+
124+
while (myGNSS.getSurveyInValid() == false) // Call the helper function
125+
{
126+
if(Serial.available())
127+
{
128+
byte incoming = Serial.read();
129+
if (incoming == 'x')
130+
{
131+
//Stop survey mode
132+
response = myGNSS.disableSurveyMode(); //Disable survey
133+
Serial.println(F("Survey stopped"));
134+
break;
135+
}
136+
}
137+
138+
response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
139+
140+
if (response == true) // Check if fresh data was received
141+
{
142+
Serial.print(F("\r\nPress x to end survey - "));
143+
Serial.print(F("Time elapsed: "));
144+
Serial.print((String)myGNSS.getSurveyInObservationTimeFull()); // Call the helper function
145+
Serial.print(F(" ("));
146+
Serial.print((String)myGNSS.packetUBXNAVSVIN->data.dur); // Read the survey-in duration directly from packetUBXNAVSVIN
147+
148+
Serial.print(F(") Accuracy: "));
149+
Serial.print((String)myGNSS.getSurveyInMeanAccuracy()); // Call the helper function
150+
Serial.print(F(" ("));
151+
// Read the mean accuracy directly from packetUBXNAVSVIN and manually convert from mm*0.1 to m
152+
float meanAcc = ((float)myGNSS.packetUBXNAVSVIN->data.meanAcc) / 10000.0;
153+
Serial.print((String)meanAcc);
154+
Serial.println(F(")"));
155+
}
156+
else
157+
{
158+
Serial.println(F("\r\nSVIN request failed"));
159+
}
160+
}
161+
162+
Serial.println(F("Base survey complete. Configuring RTCM."));
163+
164+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
165+
166+
//Disable or enable various RTCM sentences over the I2C interface
167+
168+
myGNSS.setI2COutput(COM_TYPE_NMEA | COM_TYPE_UBX | COM_TYPE_RTCM3); // Turn on UBX, NMEA and RTCM sentences on I2C
169+
170+
myGNSS.newCfgValset(VAL_LAYER_RAM); // Use cfgValset to disable / enable individual RTCM messages. Save setting in RAM layer only (not BBR)
171+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); // Enable RTCM 1005 (Stationary Antenna Reference Point, No Height Information) at current navigation rate
172+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1074_I2C, 1); // Enable RTCM 1074 (GPS MSM4). RTCM 1077 (GPS MSM7) is higher resolution but is almost twice as many bytes
173+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1084_I2C, 1); // Enable RTCM 1084 (GLONASS MSM4). RTCM 1087 (GLONASS MSM7) is higher resolution
174+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1094_I2C, 1); // Enable RTCM 1094 (Galileo MSM4). RTCM 1097 (Galileo MSM7) is higher resolution
175+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1124_I2C, 1); // Enable RTCM 1124 (BeiDou MSM4). RTCM 1127 (BeiDou MSM7) is higher resolution
176+
myGNSS.addCfgValset(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1230_I2C, 10); // Enable RTCM message 1230 (GLONASS L1 and L2 Code-Phase Biases) every 10 seconds
177+
if (myGNSS.sendCfgValset()) // Send the configuration VALSET
178+
Serial.println(F("RTCM messages were configured successfully"));
179+
else
180+
Serial.println(F("RTCM message configuration failed!"));
181+
182+
//myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save only the ioPort and message settings to NVM
183+
184+
//myGNSS.setRTCMOutputPort(Serial); // Uncomment this line to echo all RTCM data to Serial for debugging
185+
186+
myGNSS.setRTCM1005callbackPtr(&newRTCM1005); //Set up the callback
187+
188+
if (sizeof(double) != 8) // Check double is 64-bit
189+
Serial.println(F("double is not 64-bit. ECEF resolution may be limited!"));
190+
}
191+
192+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
193+
194+
void loop()
195+
{
196+
myGNSS.checkUblox(); // Check for the arrival of new data and process it.
197+
myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
198+
199+
Serial.print(".");
200+
delay(50);
201+
}

keywords.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ NMEA_VTG_data_t KEYWORD1
8282
NMEA_RMC_data_t KEYWORD1
8383
NMEA_ZDA_data_t KEYWORD1
8484

85+
RTCM_1005_data_t KEYWORD1
86+
8587
#######################################
8688
# Methods and Functions (KEYWORD2)
8789
#######################################
@@ -720,6 +722,9 @@ setRTCMLoggingMask KEYWORD2
720722
getRTCMLoggingMask KEYWORD2
721723
crc24q KEYWORD2
722724

725+
getLatestRTCM1005 KEYWORD2
726+
setRTCM1005callbackPtr KEYWORD2
727+
723728
enableUBXlogging KEYWORD2
724729

725730
setMainTalkerID KEYWORD2
@@ -755,6 +760,8 @@ extractByte KEYWORD2
755760
extractSignedChar KEYWORD2
756761
extractFloat KEYWORD2
757762
extractDouble KEYWORD2
763+
extractUnsignedBits KEYWORD2
764+
extractSignedBits KEYWORD2
758765

759766

760767
#######################################

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS v3
2-
version=3.0.9
2+
version=3.0.10
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

0 commit comments

Comments
 (0)