You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/04.pro/shields/portenta-cat-m1-nb-iot-gnss-shield/tutorials/cheat-sheet/cheat-sheet.md
+47Lines changed: 47 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -256,6 +256,53 @@ Open the example by going to **Examples > GSM > GNSSClient**
256
256
You will see the **NMEA** data in the Serial monitor.
257
257

258
258
259
+
#### Parse NMEA GPS Sentences
260
+
261
+
Previously we shown how to show the GPS data on the Serial Monitor, but it was not possible to evaluate those messages (NMEA sentences).
262
+
To do so you can use an **NMEA parser** that will convert the messages received from the GPS modem and it will parse and save them into variables, you can use the **107-Arduino-NMEA-Parser** library.
263
+
264
+
Open the example from the library at **Examples > 107-Arduino-NMEA-Parser > NMEA-Basic** and you need to add the following:
265
+
266
+
Include the needed libraries.
267
+
268
+
```cpp
269
+
#include"GPS.h"
270
+
#include"GSM.h"
271
+
#include"ArduinoNmeaParser.h"
272
+
#include"Arduino_secrets.h"
273
+
274
+
char pin[] = SECRET_PIN;
275
+
char apn[] = SECRET_APN;
276
+
char username[] = SECRET_LOGIN;
277
+
char pass[] = SECRET_PASS;
278
+
```
279
+
280
+
Inside the `setup()` initialize the GSM and GPS modules.
281
+
282
+
```cpp
283
+
voidsetup(){
284
+
Serial.begin(115200);
285
+
while (!Serial) {}
286
+
Serial.println("GSM...");
287
+
GSM.begin(pin, apn, username, pass, CATNB);
288
+
Serial.println("GPS...");
289
+
GPS.begin();
290
+
Serial.println("Success");
291
+
}
292
+
```
293
+
294
+
Edit the loop to parse the `GPS` readings instead of the `Serial1`.
295
+
296
+
```cpp
297
+
void loop(){
298
+
while(GPS.available()){
299
+
parser.encode((char)GPS.read());
300
+
}
301
+
}
302
+
```
303
+
304
+
***You will see the output data as various "-1" until the GPS has enough visible satellites to get the correct data, make sure the GPS antenna is somewhere that can see the sky.***
305
+
259
306
#### Low Power GPS
260
307
261
308
The GPS antenna is active, that means that it needs power to function as it has electronics inside of it.
0 commit comments