Skip to content

Commit dd52d92

Browse files
authored
Merge pull request #4 from sparkfun/ParserInLib
Parser in lib
2 parents 2cf0f16 + aff94f4 commit dd52d92

File tree

23 files changed

+1533
-824
lines changed

23 files changed

+1533
-824
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Enable NMEA out COM1 (USB-C) for viewing in u-center (u-blox's software) or UPrecise (Unicore's software)
3+
By: Nathan Seidle
4+
SparkFun Electronics
5+
Date: October 2nd, 2023
6+
License: MIT. Please see LICENSE.md for more information.
7+
8+
This sketch turns on all the major NMEA setences at 2Hz and prints the
9+
incoming serial out the Serial port. This is useful for viewing the GNSS
10+
data in a program like u-center.
11+
These examples are targeted for an ESP32 platform but any platform that has multiple
12+
serial UARTs should be compatible.
13+
14+
Feel like supporting open source hardware?
15+
Buy a board from SparkFun!
16+
SparkFun Triband GNSS RTK Breakout - UM980 (GPS-23286) https://www.sparkfun.com/products/23286
17+
18+
Hardware Connections:
19+
Connect RX2 of the UM980 to pin 4 on the ESP32
20+
Connect TX2 of the UM980 to pin 13 on the ESP32
21+
To make this easier, a 4-pin locking JST cable can be purchased here: https://www.sparkfun.com/products/17240
22+
Note: Almost any ESP32 pins can be used for serial.
23+
Connect a dual or triband GNSS antenna: https://www.sparkfun.com/products/21801
24+
*/
25+
26+
int pin_UART1_TX = 4;
27+
int pin_UART1_RX = 13;
28+
29+
#include <SparkFun_Unicore_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_Unicore_GNSS
30+
31+
UM980 myGNSS;
32+
33+
HardwareSerial SerialGNSS(1); //Use UART1 on the ESP32
34+
35+
void setup()
36+
{
37+
Serial.begin(115200);
38+
delay(250);
39+
Serial.println();
40+
Serial.println("SparkFun UM980 Example");
41+
42+
//We must start the serial port before using it in the library
43+
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
44+
45+
myGNSS.enableDebugging(); // Print all debug to Serial
46+
47+
if (myGNSS.begin(SerialGNSS) == false) //Give the serial port over to the library
48+
{
49+
Serial.println("UM980 failed to respond. Check ports and baud rates. Freezing...");
50+
while (true);
51+
}
52+
Serial.println("UM980 detected!");
53+
54+
bool response = true;
55+
56+
//Turn off all NMEA, RTCM, and any other messages that may be reporting periodic
57+
response &= myGNSS.disableOutput();
58+
59+
float outputRate = 0.5; //0.5 = 2 reports per second.
60+
61+
char comPort[] = "COM1";
62+
response &= myGNSS.setNMEAPortMessage("GPGGA", comPort, outputRate);
63+
response &= myGNSS.setNMEAPortMessage("GPGSA", comPort, outputRate);
64+
response &= myGNSS.setNMEAPortMessage("GPGST", comPort, outputRate);
65+
response &= myGNSS.setNMEAPortMessage("GPGSV", comPort, outputRate);
66+
response &= myGNSS.setNMEAPortMessage("GPRMC", comPort, outputRate);
67+
response &= myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
68+
69+
//If any one command fails, it will force response to false
70+
if(response == false)
71+
{
72+
Serial.println("UM980 failed to configure. Freezing...");
73+
while(true);
74+
}
75+
76+
Serial.println("NMEA now reporting on USB-C serial port");
77+
}
78+
79+
void loop()
80+
{
81+
while(SerialGNSS.available())
82+
Serial.write(SerialGNSS.read());
83+
}

examples/Example12_FactoryReset/Example12_FactoryReset.ino renamed to examples/Example11_FactoryReset/Example11_FactoryReset.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Date: October 2nd, 2023
66
License: MIT. Please see LICENSE.md for more information.
77
8-
This example shows how set the UM980 back to defaults.
8+
This example shows how to set the UM980 back to defaults.
99
These examples are targeted for an ESP32 platform but any platform that has multiple
1010
serial UARTs should be compatible.
1111
@@ -35,7 +35,7 @@ void setup()
3535
Serial.begin(115200);
3636
delay(250);
3737
Serial.println();
38-
Serial.println("UM980 comm over ESP UART1");
38+
Serial.println("SparkFun UM980 Example");
3939

4040
//We must start the serial port before using it in the library
4141
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
@@ -59,13 +59,15 @@ void setup()
5959
else
6060
Serial.println("Error resetting UM980 to factory defaults");
6161

62-
Serial.println("Waiting for device to reboot");
62+
Serial.println("Waiting for UM980 to reboot");
63+
6364
while (1)
6465
{
6566
delay(1000); //Wait for device to reboot
6667
if (myGNSS.isConnected() == true) break;
6768
else Serial.println("Device still rebooting");
6869
}
70+
6971
Serial.println("UM980 has completed reset");
7072

7173

examples/Example13_SendCommand/Example13_SendCommand.ino renamed to examples/Example12_SendCommand/Example12_SendCommand.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void setup()
3737
Serial.begin(115200);
3838
delay(250);
3939
Serial.println();
40-
Serial.println("UM980 comm over ESP UART1");
40+
Serial.println("SparkFun UM980 Example");
4141

4242
//We must start the serial port before using it in the library
4343
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);

examples/Example14_SetPPS/Example14_SetPPS.ino renamed to examples/Example13_SetPPS/Example13_SetPPS.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void setup()
3535
Serial.begin(115200);
3636
delay(250);
3737
Serial.println();
38-
Serial.println("UM980 comm over ESP UART1");
38+
Serial.println("SparkFun UM980 Example");
3939

4040
//We must start the serial port before using it in the library
4141
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);

examples/Example15_PollForValidRTCMMessages/Example15_PollForValidRTCMMessages.ino renamed to examples/Example14_PollForValidRTCMMessages/Example14_PollForValidRTCMMessages.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setup()
4343
Serial.begin(115200);
4444
delay(250);
4545
Serial.println();
46-
Serial.println("UM980 comm over ESP UART1");
46+
Serial.println("SparkFun UM980 Example");
4747

4848
//We must start the serial port before using it in the library
4949
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);

examples/Example1_PositionTime/Example1_PositionTime.ino renamed to examples/Example1_PositionVelocityTime/Example1_PositionVelocityTime.ino

+26-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setup()
4040
Serial.begin(115200);
4141
delay(250);
4242
Serial.println();
43-
Serial.println("UM980 comm over ESP UART1");
43+
Serial.println("SparkFun UM980 Example");
4444

4545
//We must start the serial port before using it in the library
4646
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
@@ -57,29 +57,49 @@ void setup()
5757

5858
void loop()
5959
{
60+
myGNSS.update(); //Regularly call to parse any new data
61+
6062
if (millis() - lastCheck > 1000)
6163
{
6264
lastCheck = millis();
6365

64-
//This is the polling method and requires a slight delay (around 135ms)
65-
//while the device responds to the request
66+
//The get methods are updated whenever new data is parsed with the update() call.
67+
//By default, this data is updated once per second.
6668

6769
Serial.print("Lat/Long/Alt: ");
6870
Serial.print(myGNSS.getLatitude(), 11);
6971
Serial.print("/");
7072
Serial.print(myGNSS.getLongitude(), 11);
7173
Serial.print("/");
72-
Serial.println(myGNSS.getAltitude(), 4);
74+
Serial.print(myGNSS.getAltitude(), 4);
75+
Serial.println();
76+
77+
Serial.print("Horizontal Speed: ");
78+
Serial.print(myGNSS.getHorizontalSpeed());
79+
Serial.print("m/s Vertical Speed: ");
80+
Serial.print(myGNSS.getVerticalSpeed());
81+
Serial.print("m/s Direction from North: ");
82+
Serial.print(myGNSS.getTrackGround());
83+
Serial.print("(degrees)");
84+
Serial.println();
7385

7486
Serial.print("Date (yyyy/mm/dd): ");
7587
Serial.print(myGNSS.getYear());
7688
Serial.print("/");
7789
Serial.print(myGNSS.getMonth());
7890
Serial.print("/");
79-
Serial.println(myGNSS.getDay());
91+
Serial.print(myGNSS.getDay());
92+
Serial.print(" Time (hh:mm:dd): ");
93+
Serial.print(myGNSS.getHour());
94+
Serial.print(":");
95+
Serial.print(myGNSS.getMinute());
96+
Serial.print(":");
97+
Serial.print(myGNSS.getSecond());
98+
Serial.println();
8099

81100
Serial.print("Satellites in view: ");
82-
Serial.println(myGNSS.getSIV());
101+
Serial.print(myGNSS.getSIV());
102+
Serial.println();
83103

84104
Serial.println();
85105
}

examples/Example2_ECEFAndStats/Example2_ECEFAndStats.ino

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void setup()
3737
Serial.begin(115200);
3838
delay(250);
3939
Serial.println();
40-
Serial.println("UM980 comm over ESP UART1");
40+
Serial.println("SparkFun UM980 Example");
4141

4242
//We must start the serial port before using it in the library
4343
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
@@ -54,7 +54,9 @@ void setup()
5454

5555
void loop()
5656
{
57-
if (millis() - lastCheck > 2000)
57+
myGNSS.update(); //Regularly call to parse any new data
58+
59+
if (millis() - lastCheck > 1000)
5860
{
5961
lastCheck = millis();
6062

@@ -153,9 +155,9 @@ void loop()
153155
Serial.print(pseudorangeCorrection);
154156
Serial.print(" - ");
155157
if (pseudorangeCorrection == 0) Serial.print("Unknown");
156-
else if (pseudorangeCorrection == 0x01) Serial.print("Klobuchar broadcast ephemeris correction");
157-
else if (pseudorangeCorrection == 0x10) Serial.print("SBAS ionospheric grid correction");
158-
else if (pseudorangeCorrection == 0x11) Serial.print("Multi-frequency correction");
158+
else if (pseudorangeCorrection == 0x001) Serial.print("Klobuchar broadcast ephemeris correction");
159+
else if (pseudorangeCorrection == 0x010) Serial.print("SBAS ionospheric grid correction");
160+
else if (pseudorangeCorrection == 0x011) Serial.print("Multi-frequency correction");
159161
else if (pseudorangeCorrection == 0x100) Serial.print("Pseudorange differential correction");
160162
else Serial.print("Unknown");
161163
Serial.println();

examples/Example2_UsbNMEA/Example2_UsbNMEA.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void setup()
3737
Serial.begin(115200);
3838
delay(250);
3939
Serial.println();
40-
Serial.println("UM980 comm over ESP UART1");
40+
Serial.println("SparkFun UM980 Example");
4141

4242
//We must start the serial port before using it in the library
4343
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
@@ -53,7 +53,7 @@ void setup()
5353

5454
bool response = true;
5555

56-
//Turn off all NMEA, RTCM, and any other message that may be reporting periodically
56+
//Turn off all NMEA, RTCM, and any other messages that may be reporting periodic
5757
response &= myGNSS.disableOutput();
5858

5959
float outputRate = 0.5; //0.5 = 2 reports per second.
@@ -66,7 +66,7 @@ void setup()
6666
response &= myGNSS.setNMEAPortMessage("GPRMC", comPort, outputRate);
6767
response &= myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
6868

69-
//If any one command failed, it will force response to false
69+
//If any one command fails, it will force response to false
7070
if(response == false)
7171
{
7272
Serial.println("UM980 failed to configure. Freezing...");

examples/Example3_EnableNMEA_5Hz/Example3_EnableNMEA_5Hz.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Setting messages on different ports on the UM980.
2+
Enable NMEA messages on different ports on the UM980.
33
By: Nathan Seidle
44
SparkFun Electronics
55
Date: October 2nd, 2023
@@ -9,6 +9,8 @@
99
These examples are targeted for an ESP32 platform but any platform that has multiple
1010
serial UARTs should be compatible.
1111
12+
This example pipes all NMEA sentences to the UART.
13+
1214
Feel like supporting open source hardware?
1315
Buy a board from SparkFun!
1416
SparkFun Triband GNSS RTK Breakout - UM980 (GPS-23286) https://www.sparkfun.com/products/23286
@@ -35,7 +37,7 @@ void setup()
3537
Serial.begin(115200);
3638
delay(250);
3739
Serial.println();
38-
Serial.println("UM980 comm over ESP UART1");
40+
Serial.println("SparkFun UM980 Example");
3941

4042
//We must start the serial port before using it in the library
4143
SerialGNSS.begin(115200, SERIAL_8N1, pin_UART1_RX, pin_UART1_TX);
@@ -49,10 +51,10 @@ void setup()
4951
}
5052
Serial.println("UM980 detected!");
5153

52-
//Set the output rate of NMEA messages. Users can set both of the message type and update rate.
54+
//Set the output rate of NMEA messages. Users can set both the message type and update rate.
5355
//1, 0.5, 0.2, 0.1, 0.05 corresponds to 1Hz, 2Hz, 5Hz, 10Hz, 20Hz respectively.
5456
//1, 2, 5 corresponds to 1Hz, 0.5Hz, 0.2Hz respectively.
55-
//Configure the port we are currently commuicating with on the UM980 (the ESP32 is connected to COM2)
57+
//Configure the port we are currently communicating with on the UM980 (the ESP32 is connected to COM2)
5658
myGNSS.setNMEAMessage("GPGGA", 1); //Message type, 1 report per second.
5759
myGNSS.setNMEAMessage("GPGSA", 1); //Message type, 1 report per second.
5860
myGNSS.setNMEAMessage("GPGST", 1); //Message type, 1 report per second.

examples/Example4_EnableNMEA/Example4_EnableNMEA.ino

-68
This file was deleted.

0 commit comments

Comments
 (0)