Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8f1b20b

Browse files
committed
update keywords.txt
add Example16_AutoPVT_ExplicitUpdate.ino -> show how to use explicit updates by calling checkUblox add Example17_AssumeAutoPVTviaUart.ino -> show how to use a Rx only UART connection to receive PVT message
1 parent f6ca7b2 commit 8f1b20b

File tree

3 files changed

+180
-1
lines changed

3 files changed

+180
-1
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
Configuring the GPS to automatically send position reports over I2C, with explicit data parsing calls
3+
By: Nathan Seidle Thorsten von Eicken and Felix Jirka
4+
SparkFun Electronics
5+
Date: July 1st, 2019
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to configure the U-Blox GPS the send navigation reports automatically
10+
and retrieving the latest one via checkUblox when available.
11+
This eliminates the implicit update in getPVT when accessing data fields twice.
12+
Also this reduces the memory overhead of a separate buffer while introducing a slight error by inconsistencies because of the unsynchronized updates (on a multi core system).
13+
14+
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
15+
simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in
16+
size?) where it can be retrieved in the next I2C poll.
17+
18+
Feel like supporting open source hardware?
19+
Buy a board from SparkFun!
20+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
21+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
22+
SAM-M8Q: https://www.sparkfun.com/products/15106
23+
24+
Hardware Connections:
25+
Plug a Qwiic cable into the GPS and a BlackBoard
26+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
27+
Open the serial monitor at 115200 baud to see the output
28+
*/
29+
30+
#include <Wire.h> //Needed for I2C to GPS
31+
32+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
33+
SFE_UBLOX_GPS myGPS;
34+
35+
void setup()
36+
{
37+
Serial.begin(115200);
38+
while (!Serial); //Wait for user to open terminal
39+
Serial.println("SparkFun Ublox Example");
40+
41+
Wire.begin();
42+
43+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
44+
{
45+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
46+
while (1);
47+
}
48+
49+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
50+
myGPS.setNavigationFrequency(2); //Produce two solutions per second
51+
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
52+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
53+
}
54+
55+
/*
56+
Calling getPVT would return false now (compare to Example 13 where it would return true), so we just use the data provided
57+
If you are using a threaded OS eg. FreeRTOS on an ESP32, the explicit mode of autoPVT allows you to use the data provided on both cores and inside multiple threads
58+
The data update in background creates an inconsistent state, but that should not cause issues for most applications as they usually won't change the GPS location significantly within a 2Hz - 5Hz update rate.
59+
Also you could oversample (10Hz - 20Hz) the data to smooth out such issues...
60+
*/
61+
void loop()
62+
{
63+
static uint16_t counter = 0;
64+
65+
if (counter % 10 == 0) {
66+
// update your AHRS filter here for a ~100Hz update rate
67+
// GPS data will be quasi static but data from your IMU will be changing
68+
}
69+
// debug output each half second
70+
if (counter % 500 == 0) {
71+
Serial.println();
72+
long latitude = myGPS.getLatitude();
73+
Serial.print(F("Lat: "));
74+
Serial.print(latitude);
75+
76+
long longitude = myGPS.getLongitude();
77+
Serial.print(F(" Long: "));
78+
Serial.print(longitude);
79+
Serial.print(F(" (degrees * 10^-7)"));
80+
81+
long altitude = myGPS.getAltitude();
82+
Serial.print(F(" Alt: "));
83+
Serial.print(altitude);
84+
Serial.print(F(" (mm)"));
85+
86+
byte SIV = myGPS.getSIV();
87+
Serial.print(F(" SIV: "));
88+
Serial.print(SIV);
89+
90+
Serial.println();
91+
}
92+
// call checkUblox all 50ms to capture the gps data
93+
if (counter % 50 == 0) {
94+
myGPS.checkUblox();
95+
}
96+
delay(1);
97+
counter++;
98+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
Reading lat and long via UBX binary commands using an RX-only UART
3+
By: Nathan Seidle, Adapted from Example11 by Felix Jirka
4+
SparkFun Electronics
5+
Date: July 2nd, 2019
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to configure the library for serial port use with a single wire connection using the assumeAutoPVT method.
10+
Saving your pins for other stuff :-)
11+
12+
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
13+
14+
Feel like supporting open source hardware?
15+
Buy a board from SparkFun!
16+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
17+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
18+
SAM-M8Q: https://www.sparkfun.com/products/15106
19+
20+
Preconditions:
21+
U-Blox module is configured to send cyclical PVT message
22+
Hardware Connections:
23+
Connect the U-Blox serial TX pin to Rx of Serial2 (default: GPIO16) on your ESP32
24+
Open the serial monitor at 115200 baud to see the output
25+
*/
26+
27+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
28+
SFE_UBLOX_GPS myGPS;
29+
30+
void setup()
31+
{
32+
Serial.begin(115200);
33+
while (!Serial); //Wait for user to open terminal
34+
Serial.println("SparkFun Ublox Example 17");
35+
36+
//Use any Serial port with at least a Rx Pin connected or a receive only version of SoftwareSerial here
37+
//Assume that the U-Blox GPS is running at 9600 baud (the default)
38+
Serial2.begin(9600);
39+
// no need to check return value as internal call to isConnected() will not succeed
40+
myGPS.begin(Serial2);
41+
42+
// tell lib, we are expecting the module to send PVT messages by itself to our Rx pin
43+
// you can set second parameter to "false" if you want to control the parsing and eviction of the data (need to call checkUblox cyclically)
44+
myGPS.assumeAutoPVT(true, true);
45+
46+
}
47+
48+
void loop()
49+
{
50+
// if implicit updates are allowed, this will trigger parsing the incoming messages
51+
// and be true once a PVT message has been parsed
52+
// In case you want to use explicit updates, wrap this in a timer and call checkUblox as often as needed, not to overflow your UART buffers
53+
if (myGPS.getPVT())
54+
{
55+
long latitude = myGPS.getLatitude();
56+
Serial.print(F("Lat: "));
57+
Serial.print(latitude);
58+
59+
long longitude = myGPS.getLongitude();
60+
Serial.print(F(" Long: "));
61+
Serial.print(longitude);
62+
Serial.print(F(" (degrees * 10^-7)"));
63+
64+
long altitude = myGPS.getAltitude();
65+
Serial.print(F(" Alt: "));
66+
Serial.print(altitude);
67+
Serial.print(F(" (mm)"));
68+
69+
byte SIV = myGPS.getSIV();
70+
Serial.print(F(" SIV: "));
71+
Serial.print(SIV);
72+
73+
Serial.println();
74+
}
75+
else {
76+
Serial.println(F("Wait for GPS data"));
77+
delay(500);
78+
}
79+
}

keywords.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ enableDebugging KEYWORD2
8585
disableDebugging KEYWORD2
8686

8787
factoryReset KEYWORD2
88-
setAutoPVT KEYWORD2
88+
89+
setAutoPVT KEYWORD2
90+
assumeAutoPVT KEYWORD2
8991

9092
getYear KEYWORD2
9193
getMonth KEYWORD2

0 commit comments

Comments
 (0)