1
+ /*
2
+ Configuring the max age of an RTK Fix before the device drops back to RTK Float
3
+ By: Nathan Seidle + Mikal Hart
4
+ SparkFun Electronics
5
+ Date: 21 May 2025
6
+ License: MIT. Please see LICENSE.md for more information.
7
+
8
+ This example shows how to configure the max differential age of RTK Fix used for the position engine.
9
+
10
+ If corrections are discontinue while the engine is in RTK Fix mode, it will continue with an RTK Fix for a certain amount
11
+ of time. This is known as the differential age. By default, the LG290P will maintain an RTK Fix for 120 seconds.alignas
12
+ Some applications require a lower (or higher) RTK Fix after corrections have been lost.
13
+
14
+ It is a known practice to raise the minimum elevation from the default of 5 degrees to 10 or even 15 degrees
15
+ when in an urban environment to exclude satellites that are too low and may be blocked by structures causing
16
+ multipath errors. Similarly, increasing the minimum CNR from 10 dBHz to 20 or 25 dBHz can exclude satellites
17
+ with lower signal strength from being used in the position calculation.
18
+
19
+ The LG290P firmware must be v5 ("LG290P03AANR01A05S") or higher for these commands to work. We recommend using the QGNSS software
20
+ to update the LG290P firmware.
21
+ Latest Firmware: https://github.com/sparkfun/SparkFun_RTK_Postcard/tree/main/Firmware
22
+ Docs: https://docs.sparkfun.com/SparkFun_LG290P_Quadband_GNSS_RTK_Breakout/software_overview/#qgnss-software
23
+
24
+ These examples are targeted for an ESP32 platform but any platform that has multiple
25
+ serial UARTs should be compatible.
26
+
27
+ Feel like supporting open source hardware?
28
+ Buy a board from SparkFun!
29
+ SparkFun Quadband GNSS RTK Breakout - LG290P (GPS-26620) https://www.sparkfun.com/products/26620
30
+
31
+ Hardware Connections:
32
+ Connect RX3 (green wire) of the LG290P to pin 14 on the ESP32
33
+ Connect TX3 (orange wire) of the LG290P to pin 13 on the ESP32
34
+ To make this easier, a 4-pin locking JST cable can be purchased here: https://www.sparkfun.com/products/17240
35
+ Note: Almost any ESP32 pins can be used for serial.
36
+ Connect a multi-band GNSS antenna: https://www.sparkfun.com/products/21801
37
+ */
38
+
39
+ #include < SparkFun_LG290P_GNSS.h> // Click here to get the library: http://librarymanager/All#SparkFun_LG290P
40
+
41
+ // Adjust these values according to your configuration
42
+ int pin_UART1_TX = 14 ;
43
+ int pin_UART1_RX = 13 ;
44
+ int gnss_baud = 460800 ;
45
+
46
+ LG290P myGNSS;
47
+ HardwareSerial SerialGNSS (1 ); // Use UART1 on the ESP32
48
+
49
+ void setup ()
50
+ {
51
+ Serial.begin (115200 );
52
+ delay (250 );
53
+ Serial.println ();
54
+ Serial.println (" SparkFun Max Differential Age example" );
55
+ Serial.println (" Initializing device..." );
56
+
57
+ // We must start the serial port before using it in the library
58
+ // Increase buffer size to handle high baud rate streams
59
+ SerialGNSS.setRxBufferSize (1024 );
60
+ SerialGNSS.begin (gnss_baud, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
61
+
62
+ // myGNSS.enableDebugging(Serial); // Print all debug to Serial
63
+ if (myGNSS.begin (SerialGNSS) == false ) // Give the serial port over to the library
64
+ {
65
+ Serial.println (" LG290P failed to respond. Check ports and baud rates. Freezing..." );
66
+ while (true );
67
+ }
68
+ Serial.println (" LG290P detected!" );
69
+
70
+ uint16_t differentialAge = 0 ;
71
+ if (myGNSS.getRtkDifferentialAge (differentialAge) == false )
72
+ {
73
+ Serial.println (" Failed to read differential age. Do you have version 5 or newer of the LG290P firmware installed?" );
74
+ }
75
+ else
76
+ {
77
+ Serial.printf (" Successfully checked differential age: %d seconds\r\n " , differentialAge);
78
+
79
+ // 120 seconds is default meaning if the engine has RTK Fix, and no more corrections are provided, RTK Fix will be
80
+ // maintained for 120 more seconds, befor falling back to RTK Float, then 3D fix.
81
+ // 1 to 600 is allowed
82
+ if (myGNSS.setRtkDifferentialAge (10 ) == false )
83
+ Serial.println (" Failed to set differential age" );
84
+ else
85
+ {
86
+ if (myGNSS.getRtkDifferentialAge (differentialAge) == false )
87
+ Serial.println (" Failed to read differential age." );
88
+ else
89
+ {
90
+ Serial.printf (" Differential age set to %d seconds.\r\n " , differentialAge);
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ void loop ()
97
+ {
98
+
99
+ }
0 commit comments