1
+ /*
2
+ Enable Galileo High Accuracy Service: https://gssc.esa.int/navipedia/index.php/Galileo_High_Accuracy_Service_(HAS)
3
+ By: Nathan Seidle
4
+ SparkFun Electronics
5
+ Date: May 9th, 2024
6
+ License: MIT. Please see LICENSE.md for more information.
7
+
8
+ The UM980 is capable of receiving the new Galileo E6 signal and obtain a sub 0.2m precision
9
+ location fix. This example shows how to enable E6 and HAS
10
+
11
+ These examples are targeted for an ESP32 platform but any platform that has multiple
12
+ serial UARTs should be compatible.
13
+
14
+ Feel like supporting open source hardware?
15
+ Buy a board from SparkFun!
16
+ SparkFun Triband GNSS RTK Breakout - UM980 (GPS-23286) https://www.sparkfun.com/products/23286
17
+
18
+ Hardware Connections:
19
+ Connect RX2 (green wire) of the UM980 to pin 4 on the ESP32
20
+ Connect TX2 (orange wire) of the UM980 to pin 13 on the ESP32
21
+ To make this easier, a 4-pin locking JST cable can be purchased here: https://www.sparkfun.com/products/17240
22
+ Note: Almost any ESP32 pins can be used for serial.
23
+ Connect a dual or triband GNSS antenna: https://www.sparkfun.com/products/21801
24
+
25
+ */
26
+
27
+ int pin_UART1_TX = 4 ;
28
+ int pin_UART1_RX = 13 ;
29
+
30
+ #include < SparkFun_Unicore_GNSS_Arduino_Library.h> // http://librarymanager/All#SparkFun_Unicore_GNSS
31
+
32
+ UM980 myGNSS;
33
+
34
+ HardwareSerial SerialGNSS (1 ); // Use UART1 on the ESP32
35
+
36
+ unsigned long lastCheck = 0 ;
37
+
38
+ unsigned long startTime = 0 ;
39
+ unsigned long convergingStartTime = 0 ;
40
+ unsigned long timeToConvergence = 0 ;
41
+
42
+ void setup ()
43
+ {
44
+ Serial.begin (115200 );
45
+ delay (250 );
46
+ Serial.println ();
47
+ Serial.println (" SparkFun UM980 Example 19" );
48
+
49
+ // The CONFIG response can be ~500 bytes over runing the ESP32 RX buffer of 256 bytes
50
+ // Increase the size of the RX buffer
51
+ SerialGNSS.setRxBufferSize (1024 );
52
+
53
+ // We must start the serial port before using it in the library
54
+ SerialGNSS.begin (115200 , SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
55
+
56
+ // myGNSS.enableDebugging(); // Print all debug to Serial
57
+
58
+ if (myGNSS.begin (SerialGNSS) == false ) // Give the serial port over to the library
59
+ {
60
+ Serial.println (" UM980 failed to respond. Check ports and baud rates. Freezing..." );
61
+ while (true );
62
+ }
63
+ Serial.println (" UM980 detected!" );
64
+
65
+ // E6 reception requires version 11833 or greater
66
+ int um980Version = String (myGNSS.getVersion ()).toInt (); // Convert the string response to a value
67
+
68
+ Serial.print (" UM980 firmware version: v" );
69
+ Serial.println (um980Version);
70
+
71
+ if (um980Version < 11833 )
72
+ {
73
+ Serial.println (" E6 requires 11833 or newer. Please update the firmware on your UM980. Freezing..." );
74
+ while (true );
75
+ }
76
+ else
77
+ Serial.println (" Firmware is E6-PPP compatible." );
78
+
79
+ if (myGNSS.isConfigurationPresent (" CONFIG SIGNALGROUP 2" ) == false )
80
+ {
81
+ if (myGNSS.sendCommand (" CONFIG SIGNALGROUP 2" ) == false )
82
+ Serial.println (" Signal group 2 command failed" );
83
+ else
84
+ {
85
+ Serial.println (" Enabling signal group 2 causes the UM980 to reboot. This can take a few seconds." );
86
+
87
+ while (1 )
88
+ {
89
+ delay (1000 ); // Wait for device to reboot
90
+ if (myGNSS.isConnected () == true ) break ;
91
+ else Serial.println (" Device still rebooting" );
92
+ }
93
+
94
+ Serial.println (" UM980 has completed reboot." );
95
+ }
96
+ }
97
+ else
98
+ Serial.println (" Signal group 2 already enabled" );
99
+
100
+ if (myGNSS.isConfigurationPresent (" CONFIG PPP ENABLE E6-HAS" ) == false )
101
+ {
102
+ if (myGNSS.sendCommand (" CONFIG PPP ENABLE E6-HAS" ) == true )
103
+ Serial.println (" E6 service enabled" );
104
+ else
105
+ Serial.println (" E6 config error" );
106
+ }
107
+ else
108
+ Serial.println (" E6 service already enabled" );
109
+
110
+ startTime = millis ();
111
+
112
+ Serial.println (" E6 PPP should now be enabled. Sit back and watch the LLA deviations decrease below 0.2m!" );
113
+ Serial.println (" r) Reset ESP" );
114
+ Serial.println (" R) Factory reset UM980" );
115
+ }
116
+
117
+ void loop ()
118
+ {
119
+ if (Serial.available ())
120
+ {
121
+ byte incoming = Serial.read ();
122
+ if (incoming == ' r' )
123
+ ESP.restart ();
124
+ else if (incoming == ' R' )
125
+ um980Reset ();
126
+ }
127
+
128
+
129
+ myGNSS.update (); // Regularly call to parse any new data
130
+
131
+ if (millis () - lastCheck > 1000 )
132
+ {
133
+ lastCheck = millis ();
134
+ printUpdate ();
135
+ }
136
+ }
137
+
138
+ void printUpdate ()
139
+ {
140
+ Serial.print (" Lat/Long/Alt: " );
141
+ Serial.print (myGNSS.getLatitude (), 11 ); // Accurate 11 decimal places
142
+ Serial.print (" /" );
143
+ Serial.print (myGNSS.getLongitude (), 11 );
144
+ Serial.print (" /" );
145
+ Serial.print (myGNSS.getAltitude (), 4 ); // Accurate to 4 decimal places
146
+ Serial.println ();
147
+
148
+ Serial.print (" Deviation of Lat/Long/Alt (m): " );
149
+ Serial.print (myGNSS.getLatitudeDeviation (), 4 );
150
+ Serial.print (" /" );
151
+ Serial.print (myGNSS.getLongitudeDeviation (), 4 );
152
+ Serial.print (" /" );
153
+ Serial.println (myGNSS.getAltitudeDeviation (), 4 );
154
+
155
+ Serial.print (" Satellites in view: " );
156
+ Serial.print (myGNSS.getSIV ());
157
+ Serial.println ();
158
+
159
+ int positionType = myGNSS.getPositionType ();
160
+ Serial.print (" Position Type: " );
161
+ Serial.print (positionType);
162
+ Serial.print (" - " );
163
+ if (positionType == 0 ) Serial.print (" No solution" );
164
+ else if (positionType == 8 ) Serial.print (" Velocity computed using instantaneous Doppler" );
165
+ else if (positionType == 16 ) Serial.print (" Single point positioning" );
166
+ else if (positionType == 17 ) Serial.print (" Pseudorange differential solution" );
167
+ else if (positionType == 18 ) Serial.print (" SBAS positioning" );
168
+ else if (positionType == 32 ) Serial.print (" L1 float solution" );
169
+ else if (positionType == 33 ) Serial.print (" Ionosphere-free float solution" );
170
+ else if (positionType == 34 ) Serial.print (" Narrow-lane float solution" );
171
+ else if (positionType == 48 ) Serial.print (" L1 fixed solution" );
172
+ else if (positionType == 49 ) Serial.print (" Wide-lane fixed solution" );
173
+ else if (positionType == 50 ) Serial.print (" Narrow-lane fixed solution" );
174
+ else if (positionType == 68 )
175
+ {
176
+ Serial.print (" PPP solution converging" );
177
+
178
+ if (convergingStartTime == 0 ) convergingStartTime = millis ();
179
+ if (convergingStartTime > 0 )
180
+ {
181
+ Serial.print (" - Seconds in converging phase: " );
182
+ Serial.print ((millis () - (convergingStartTime - startTime)) / 1000.0 , 0 );
183
+ Serial.print (" s" );
184
+ }
185
+ }
186
+ else if (positionType == 69 )
187
+ {
188
+ Serial.print (" Precise Point Positioning" );
189
+
190
+ if (timeToConvergence == 0 ) timeToConvergence = millis ();
191
+ if (timeToConvergence > 0 )
192
+ {
193
+ Serial.print (" - Seconds in converging phase: " );
194
+ Serial.print ((millis () - (convergingStartTime - startTime)) / 1000.0 , 0 );
195
+ Serial.print (" s" );
196
+
197
+ Serial.print (" - Total time to convergence: " );
198
+ Serial.print ((timeToConvergence - startTime) / 1000.0 , 0 );
199
+ Serial.print (" s" );
200
+ }
201
+ }
202
+ else Serial.print (" Unknown" );
203
+ Serial.println ();
204
+
205
+ Serial.println ();
206
+ }
207
+
208
+ void um980Reset ()
209
+ {
210
+ while (Serial.available ()) Serial.read (); // Clear RX buffer
211
+ Serial.println (" Press any key to factory reset the UM980" );
212
+ while (Serial.available () == 0 ) delay (1 ); // Wait for user to press a button
213
+
214
+ // Clear saved configurations, satellite ephemerides, position information, and reset baud rate to 115200bps.
215
+ if (myGNSS.factoryReset () == true )
216
+ Serial.println (" UM980 now reset to factory defaults" );
217
+ else
218
+ Serial.println (" Error resetting UM980 to factory defaults" );
219
+
220
+ Serial.println (" Waiting for UM980 to reboot" );
221
+
222
+ while (1 )
223
+ {
224
+ delay (1000 ); // Wait for device to reboot
225
+ if (myGNSS.isConnected () == true ) break ;
226
+ else Serial.println (" Device still rebooting" );
227
+ }
228
+
229
+ Serial.println (" UM980 has completed reset" );
230
+ }
0 commit comments