Skip to content

Commit 33491ba

Browse files
committed
docs: Update GNSS variable names and initialization delays
Refactor GNSS variable names for clarity and consistency. Adjust initialization delays to improve sensor startup time and responsiveness. Signed-off-by: ChihoSin [email protected]
1 parent 81db4e3 commit 33491ba

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

docs/product/f2207/quickstart.mdx

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mikalhart/TinyGPSPlus@^1.1.0
8282
#define GNSS_WAKE_PIN PIN_MFP4 // Wake pin for GNSS, change if needed
8383
#define PERI_EN_PIN PIN_PERI_EN // Peripheral enable pin, change if needed
8484

85-
TinyGPSPlus sensor;
85+
TinyGPSPlus gnss;
8686

8787
// Buffer to store the latest NMEA sentence
8888
String latestNmeaSentence = "";
@@ -120,7 +120,7 @@ void setup()
120120
Serial.println("GNSS bus initialized");
121121

122122
// Wait a moment for module to fully initialize
123-
delay(1000);
123+
delay(200);
124124

125125
// Record startup time
126126
startupTime = millis();
@@ -133,24 +133,35 @@ void setup()
133133
{
134134
while (Serial1.available() > 0)
135135
{
136-
sensor.encode(Serial1.read());
136+
gnss.encode(Serial1.read());
137137
}
138-
if (sensor.location.isValid() || sensor.time.isValid() || sensor.satellites.value() > 0)
138+
if (gnss.location.isValid() || gnss.time.isValid() || gnss.satellites.value() > 0)
139139
{
140140
break;
141141
}
142142
delay(200);
143143
}
144+
145+
// Configure GNSS settings, calculate checksum reference https://www.hhhh.org/wiml/proj/nmeaxor.html
146+
Serial1.write("$PCAS04,7*1E\r\n"); // Configure satellite constellation
147+
delay(250);
148+
Serial1.write("$PCAS11,3*1E\r\n"); // Configure positioning mode
149+
delay(250);
150+
Serial1.write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n"); // Configure positioning frequency
151+
delay(250);
152+
Serial1.write("$PCAS02,200*1D\r\n"); // Configure positioning frequency
153+
delay(250);
154+
144155
Serial.println("GNSS sensor initialized");
145156

146157
// Start measurement (GNSS automatically starts after initialization)
147158
}
148159

149160
void loop()
150161
{
151-
delay(100); // Wait equivalent to sensor.wait()
162+
delay(50); // Wait equivalent to gnss.wait()
152163

153-
// Read data from GNSS (equivalent to sensor.update())
164+
// Read data from GNSS (equivalent to gnss.update())
154165
bool dataUpdated = false;
155166
while (Serial1.available() > 0)
156167
{
@@ -172,18 +183,18 @@ void loop()
172183
}
173184
}
174185

175-
if (sensor.encode(c))
186+
if (gnss.encode(c))
176187
{
177188
dataUpdated = true;
178189
}
179190
}
180191

181-
if (dataUpdated) // Equivalent to sensor.update() == RESULT_OK
192+
if (dataUpdated) // Equivalent to gnss.update() == RESULT_OK
182193
{
183-
if (sensor.location.isValid() || sensor.time.isValid()) // Equivalent to sensor.hasNewData()
194+
if (gnss.location.isValid() || gnss.time.isValid()) // Equivalent to gnss.hasNewData()
184195
{
185196
// Check for first fix achievement
186-
if (!firstFixAchieved && sensor.location.isValid())
197+
if (!firstFixAchieved && gnss.location.isValid())
187198
{
188199
firstFixTime = millis();
189200
firstFixAchieved = true;
@@ -197,37 +208,37 @@ void loop()
197208
Serial.printf("%-12s%-12s%-12s\n", "INDEX", "VALUE", "UNIT");
198209
Serial.print("\033[0m");
199210

200-
if (sensor.location.isValid())
211+
if (gnss.location.isValid())
201212
{
202-
Serial.printf("%-12s%-12.6f%-12s\n", "LATITUDE", sensor.location.lat(), "°");
203-
Serial.printf("%-12s%-12.6f%-12s\n", "LONGITUDE", sensor.location.lng(), "°");
213+
Serial.printf("%-12s%-12.6f%-12s\n", "LATITUDE", gnss.location.lat(), "°");
214+
Serial.printf("%-12s%-12.6f%-12s\n", "LONGITUDE", gnss.location.lng(), "°");
204215
}
205216

206-
if (sensor.altitude.isValid())
217+
if (gnss.altitude.isValid())
207218
{
208-
Serial.printf("%-12s%-12.2f%-12s\n", "ALTITUDE", sensor.altitude.meters(), "m");
219+
Serial.printf("%-12s%-12.2f%-12s\n", "ALTITUDE", gnss.altitude.meters(), "m");
209220
}
210221

211-
if (sensor.speed.isValid())
222+
if (gnss.speed.isValid())
212223
{
213-
Serial.printf("%-12s%-12.2f%-12s\n", "SPEED", sensor.speed.kmph(), "km/h");
224+
Serial.printf("%-12s%-12.2f%-12s\n", "SPEED", gnss.speed.kmph(), "km/h");
214225
}
215226

216-
if (sensor.satellites.isValid())
227+
if (gnss.satellites.isValid())
217228
{
218-
Serial.printf("%-12s%-12d%-12s\n", "SATELLITES", sensor.satellites.value(), "");
229+
Serial.printf("%-12s%-12d%-12s\n", "SATELLITES", gnss.satellites.value(), "");
219230
}
220231

221-
if (sensor.hdop.isValid())
232+
if (gnss.hdop.isValid())
222233
{
223-
Serial.printf("%-12s%-12.2f%-12s\n", "HDOP", sensor.hdop.hdop(), "");
234+
Serial.printf("%-12s%-12.2f%-12s\n", "HDOP", gnss.hdop.hdop(), "");
224235
}
225236

226237
// Add GPS time display
227-
if (sensor.time.isValid() && sensor.date.isValid())
238+
if (gnss.time.isValid() && gnss.date.isValid())
228239
{
229-
Serial.printf("%-12s%02d:%02d:%02d%-12s\n", "TIME", sensor.time.hour(), sensor.time.minute(), sensor.time.second(), "UTC");
230-
Serial.printf("%-12s%04d-%02d-%02d%-12s\n", "DATE", sensor.date.year(), sensor.date.month(), sensor.date.day(), "");
240+
Serial.printf("%-12s%02d:%02d:%02d%-12s\n", "TIME", gnss.time.hour(), gnss.time.minute(), gnss.time.second(), "UTC");
241+
Serial.printf("%-12s%04d-%02d-%02d%-12s\n", "DATE", gnss.date.year(), gnss.date.month(), gnss.date.day(), "");
231242
}
232243

233244
// Add Time to First Fix Information

0 commit comments

Comments
 (0)