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

Commit 47c83da

Browse files
committed
Adding autoHPPOSLLH. Tested on the ZED-F9P.
1 parent 1075c2e commit 47c83da

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
Configuring the GPS to automatically send HPPOSLLH position reports over I2C
3+
By: Paul Clark
4+
Date: October 27th 2020
5+
6+
Based on an earlier example:
7+
By: Nathan Seidle and Thorsten von Eicken
8+
SparkFun Electronics
9+
Date: January 3rd, 2019
10+
License: MIT. See license file for more information but you can
11+
basically do whatever you want with this code.
12+
13+
This example shows how to configure the U-Blox GPS the send navigation reports automatically
14+
and retrieving the latest one via getHPPOSLLH. This eliminates the blocking in getHPPOSLLH while the GPS
15+
produces a fresh navigation solution at the expense of returning a slighly old solution.
16+
17+
This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS
18+
simply outputs the UBX_NAV_HPPOSLLH packet. With I2C it queues it into its internal I2C buffer (4KB in
19+
size?) where it can be retrieved in the next I2C poll.
20+
21+
Feel like supporting open source hardware?
22+
Buy a board from SparkFun!
23+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
24+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
25+
26+
Hardware Connections:
27+
Plug a Qwiic cable into the GPS and a BlackBoard
28+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
29+
Open the serial monitor at 115200 baud to see the output
30+
*/
31+
32+
#include <Wire.h> //Needed for I2C to GPS
33+
34+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
35+
SFE_UBLOX_GPS myGPS;
36+
37+
void setup()
38+
{
39+
Serial.begin(115200);
40+
while (!Serial); //Wait for user to open terminal
41+
Serial.println("SparkFun Ublox Example");
42+
43+
Wire.begin();
44+
45+
//myGPS.enableDebugging(); // Uncomment this line to enable lots of helpful debug messages
46+
47+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
48+
{
49+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
50+
while (1);
51+
}
52+
53+
// Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate
54+
//myGPS.factoryDefault(); delay(5000);
55+
56+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
57+
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR
58+
59+
myGPS.setNavigationFrequency(1); //Produce one solution per second
60+
61+
62+
// The acid test: all four of these combinations should work seamlessly :-)
63+
64+
//myGPS.setAutoPVT(false); // Library will poll each reading
65+
//myGPS.setAutoHPPOSLLH(false); // Library will poll each reading
66+
67+
//myGPS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically
68+
//myGPS.setAutoHPPOSLLH(false); // Library will poll each reading
69+
70+
// This combination causes the PVT data to be overwritten by HPPOSLLH.
71+
// But that's OK. Both sets of readings are still extracted OK.
72+
//myGPS.setAutoPVT(false); // Library will poll each reading
73+
//myGPS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically
74+
75+
myGPS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically
76+
myGPS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically
77+
78+
}
79+
80+
void loop()
81+
{
82+
Serial.println();
83+
84+
// PVT first
85+
86+
long latitude = myGPS.getLatitude();
87+
Serial.print(F("Lat: "));
88+
Serial.print(latitude);
89+
90+
long longitude = myGPS.getLongitude();
91+
Serial.print(F(" Long: "));
92+
Serial.print(longitude);
93+
94+
long highResLatitude = myGPS.getHighResLatitude();
95+
Serial.print(F(" Hi Res Lat: "));
96+
Serial.print(highResLatitude);
97+
98+
int highResLatitudeHp = myGPS.getHighResLatitudeHp();
99+
Serial.print(F(" "));
100+
Serial.print(highResLatitudeHp);
101+
102+
long highResLongitude = myGPS.getHighResLongitude();
103+
Serial.print(F(" Hi Res Long: "));
104+
Serial.print(highResLongitude);
105+
106+
int highResLongitudeHp = myGPS.getHighResLongitudeHp();
107+
Serial.print(F(" "));
108+
Serial.print(highResLongitudeHp);
109+
110+
unsigned long horizAccuracy = myGPS.getHorizontalAccuracy();
111+
Serial.print(F(" Horiz accuracy: "));
112+
Serial.println(horizAccuracy);
113+
114+
delay(750);
115+
116+
Serial.println();
117+
118+
// HPPOSLLH first
119+
120+
highResLatitude = myGPS.getHighResLatitude();
121+
Serial.print(F("Hi Res Lat: "));
122+
Serial.print(highResLatitude);
123+
124+
highResLatitudeHp = myGPS.getHighResLatitudeHp();
125+
Serial.print(F(" "));
126+
Serial.print(highResLatitudeHp);
127+
128+
highResLongitude = myGPS.getHighResLongitude();
129+
Serial.print(F(" Hi Res Long: "));
130+
Serial.print(highResLongitude);
131+
132+
highResLongitudeHp = myGPS.getHighResLongitudeHp();
133+
Serial.print(F(" "));
134+
Serial.print(highResLongitudeHp);
135+
136+
horizAccuracy = myGPS.getHorizontalAccuracy();
137+
Serial.print(F(" Horiz accuracy: "));
138+
Serial.print(horizAccuracy);
139+
140+
latitude = myGPS.getLatitude();
141+
Serial.print(F(" Lat: "));
142+
Serial.print(latitude);
143+
144+
longitude = myGPS.getLongitude();
145+
Serial.print(F(" Long: "));
146+
Serial.println(longitude);
147+
148+
delay(750);
149+
}

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -3013,6 +3013,15 @@ boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
30133013
if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
30143014
return (true);
30153015

3016+
if ((retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) && (packetCfg.id == UBX_NAV_HPPOSLLH))
3017+
{
3018+
if (_printDebug == true)
3019+
{
3020+
_debugSerial->println(F("getPVT: data was OVERWRITTEN by HPPOSLLH (but that's OK)"));
3021+
}
3022+
return (true);
3023+
}
3024+
30163025
if (_printDebug == true)
30173026
{
30183027
_debugSerial->print(F("getPVT retVal: "));
@@ -3180,6 +3189,15 @@ boolean SFE_UBLOX_GPS::getHPPOSLLH(uint16_t maxWait)
31803189
if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
31813190
return (true);
31823191

3192+
if ((retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) && (packetCfg.id == UBX_NAV_PVT))
3193+
{
3194+
if (_printDebug == true)
3195+
{
3196+
_debugSerial->println(F("getHPPOSLLH: data was OVERWRITTEN by PVT (but that's OK)"));
3197+
}
3198+
return (true);
3199+
}
3200+
31833201
if (_printDebug == true)
31843202
{
31853203
_debugSerial->print(F("getHPPOSLLH retVal: "));

0 commit comments

Comments
 (0)