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

Commit 3aea588

Browse files
committed
Updating examples 1-12 after testing with v2.0
1 parent f2904f4 commit 3aea588

File tree

14 files changed

+200
-93
lines changed

14 files changed

+200
-93
lines changed

examples/Example10_AltitudeMSL/Example10_AltitudeMSL.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
SAM-M8Q: https://www.sparkfun.com/products/15106
2424
2525
Hardware Connections:
26-
Plug a Qwiic cable into the GPS and a BlackBoard
26+
Plug a Qwiic cable into the GNSS and a BlackBoard
2727
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
2828
Open the serial monitor at 115200 baud to see the output
2929
*/
3030

31-
#include <Wire.h> //Needed for I2C to GPS
31+
#include <Wire.h> //Needed for I2C to GNSS
3232

3333
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
3434
SFE_UBLOX_GPS myGPS;
@@ -45,7 +45,7 @@ void setup()
4545

4646
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4747
{
48-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
48+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4949
while (1);
5050
}
5151
}

examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C/Example1_FactoryDefaultviaI2C.ino

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void setup()
3232

3333
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
3434
{
35-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
35+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
3636
while (1);
3737
}
3838

@@ -42,14 +42,16 @@ void setup()
4242

4343
myGPS.factoryReset(); //Reset everything: baud rate, I2C address, update rate, everything.
4444

45-
if (myGPS.begin() == false) //Attempt to re-connect
45+
delay(5000); // Wait while the module restarts
46+
47+
while (myGPS.begin() == false) //Attempt to re-connect
4648
{
47-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
48-
while (1);
49+
delay(1000);
50+
Serial.println(F("Attempting to re-connect to u-blox GNSS..."));
4951
}
5052

5153
Serial.println("Unit has now been factory reset. Freezing...");
52-
while(1);
54+
while(1); // Do nothing more
5355
}
5456

5557
void loop()

examples/Example11_ResetModule/Example2_FactoryDefaultsviaSerial/Example2_FactoryDefaultsviaSerial.ino

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,32 @@
1515
1616
Hardware Connections:
1717
Connect the U-Blox serial port to Serial1
18-
If you're using an Uno or don't have a 2nd serial port (Serial1), consider using software serial
18+
If you're using a Uno or don't have a 2nd serial port (Serial1), use SoftwareSerial instead (see below)
1919
Open the serial monitor at 115200 baud to see the output
2020
*/
2121

2222
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
2323
SFE_UBLOX_GPS myGPS;
2424

25+
#include <SoftwareSerial.h>
26+
27+
//#define mySerial Serial1 // Uncomment this line to connect via Serial1
28+
// - or -
29+
SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin.
30+
31+
#define defaultRate 9600 // Uncomment this line if you are using an M8 - which defaults to 9600 Baud on UART1
32+
// - or -
33+
//#define defaultRate 38400 // Uncomment this line if you are using an F9 - which defaults to 38400 Baud on UART1
34+
2535
int state = 0; // steps through auto-baud, reset, etc states
2636

2737
void setup()
2838
{
2939
Serial.begin(115200);
3040
while (!Serial); //Wait for user to open terminal
3141
Serial.println("SparkFun u-blox Example");
42+
43+
//myGPS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
3244
}
3345

3446
void loop()
@@ -38,15 +50,15 @@ void loop()
3850
switch (state) {
3951
case 0: // auto-baud connection, then switch to 38400 and save config
4052
do {
41-
Serial.println("GPS: trying 38400 baud");
42-
Serial1.begin(38400);
43-
if (myGPS.begin(Serial1)) break;
53+
Serial.println("GNSS: trying 38400 baud");
54+
mySerial.begin(38400);
55+
if (myGPS.begin(mySerial)) break;
4456

4557
delay(100);
46-
Serial.println("GPS: trying 9600 baud");
47-
Serial1.begin(9600);
48-
if (myGPS.begin(Serial1)) {
49-
Serial.println("GPS: connected at 9600 baud, switching to 38400");
58+
Serial.println("GNSS: trying 9600 baud");
59+
mySerial.begin(9600);
60+
if (myGPS.begin(mySerial)) {
61+
Serial.println("GNSS: connected at 9600 baud, switching to 38400");
5062
myGPS.setSerialRate(38400);
5163
delay(100);
5264
} else {
@@ -55,41 +67,44 @@ void loop()
5567
} while(1);
5668
myGPS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
5769
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
58-
Serial.println("GPS serial connected, saved config");
70+
Serial.println("GNSS serial connected, saved config");
5971
state++;
6072
break;
61-
case 1: // hardReset, expect to see GPS back at 38400 baud
73+
case 1: // hardReset, expect to see GNSS back at 38400 baud
6274
Serial.println("Issuing hardReset (cold start)");
6375
myGPS.hardReset();
64-
delay(1000);
65-
Serial1.begin(38400);
66-
if (myGPS.begin(Serial1)) {
76+
delay(2000);
77+
mySerial.begin(38400);
78+
if (myGPS.begin(mySerial)) {
6779
Serial.println("Success.");
6880
state++;
6981
} else {
70-
Serial.println("*** GPS did not respond at 38400 baud, starting over.");
82+
Serial.println("*** GNSS did not respond at 38400 baud, starting over.");
7183
state = 0;
7284
}
7385
break;
74-
case 2: // factoryReset, expect to see GPS back at 9600 baud
86+
case 2: // factoryReset, expect to see GNSS back at defaultRate baud
7587
Serial.println("Issuing factoryReset");
7688
myGPS.factoryReset();
77-
delay(2000); // takes more than one second... a loop to resync would be best
78-
Serial1.begin(9600);
79-
if (myGPS.begin(Serial1)) {
89+
delay(5000); // takes more than one second... a loop to resync would be best
90+
mySerial.begin(defaultRate);
91+
if (myGPS.begin(mySerial)) {
8092
Serial.println("Success.");
8193
state++;
8294
} else {
83-
Serial.println("*** GPS did not come back at 9600 baud, starting over.");
95+
Serial.println("*** GNSS did not come back at defaultRate baud, starting over.");
8496
state = 0;
8597
}
8698
break;
8799
case 3: // print version info
88-
Serial.print("GPS protocol version: ");
100+
// Note: this may fail on boards like the UNO (ATmega328P) with modules like the ZED-F9P
101+
// because getProtocolVersion returns a lot of data - more than the UNO's serial buffer can hold
102+
Serial.print("GNSS protocol version: ");
89103
Serial.print(myGPS.getProtocolVersionHigh());
90104
Serial.print('.');
91-
Serial.print(myGPS.getProtocolVersionLow());
92-
state = 0;
105+
Serial.println(myGPS.getProtocolVersionLow());
106+
Serial.println("All finished! Freezing...");
107+
while(1);
93108
}
94109
delay(1000);
95110
}

examples/Example12_UseUart/Example12_UseUart.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
SFE_UBLOX_GPS myGPS;
3232

3333
#include <SoftwareSerial.h>
34-
SoftwareSerial mySerial(10, 11); // RX, TX. Pin 10 on Uno goes to TX pin on GPS module.
34+
SoftwareSerial mySerial(10, 11); // RX, TX. Pin 10 on Uno goes to TX pin on GNSS module.
3535

3636
long lastTime = 0; //Simple local timer. Limits amount of I2C traffic to u-blox module.
3737

@@ -41,26 +41,26 @@ void setup()
4141
while (!Serial); //Wait for user to open terminal
4242
Serial.println("SparkFun u-blox Example");
4343

44-
//Assume that the U-Blox GPS is running at 9600 baud (the default) or at 38400 baud.
44+
//Assume that the U-Blox GNSS is running at 9600 baud (the default) or at 38400 baud.
4545
//Loop until we're in sync and then ensure it's at 38400 baud.
4646
do {
47-
Serial.println("GPS: trying 38400 baud");
47+
Serial.println("GNSS: trying 38400 baud");
4848
mySerial.begin(38400);
4949
if (myGPS.begin(mySerial) == true) break;
5050

5151
delay(100);
52-
Serial.println("GPS: trying 9600 baud");
52+
Serial.println("GNSS: trying 9600 baud");
5353
mySerial.begin(9600);
5454
if (myGPS.begin(mySerial) == true) {
55-
Serial.println("GPS: connected at 9600 baud, switching to 38400");
55+
Serial.println("GNSS: connected at 9600 baud, switching to 38400");
5656
myGPS.setSerialRate(38400);
5757
delay(100);
5858
} else {
5959
//myGPS.factoryReset();
6060
delay(2000); //Wait a bit before trying again to limit the Serial output
6161
}
6262
} while(1);
63-
Serial.println("GPS serial connected");
63+
Serial.println("GNSS serial connected");
6464

6565
myGPS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only
6666
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)

examples/Example1_BasicNMEARead/Example1_BasicNMEARead.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
SAM-M8Q: https://www.sparkfun.com/products/15106
1717
1818
Hardware Connections:
19-
Plug a Qwiic cable into the GPS and a BlackBoard
19+
Plug a Qwiic cable into the GNSS and a BlackBoard
2020
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
2121
Open the serial monitor at 115200 baud to see the output
2222
*/
2323

24-
#include <Wire.h> //Needed for I2C to GPS
24+
#include <Wire.h> //Needed for I2C to GNSS
2525

2626
#include "SparkFun_Ublox_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_Ublox_GPS
2727
SFE_UBLOX_GPS myGPS;
@@ -35,7 +35,7 @@ void setup()
3535

3636
if (myGPS.begin() == false)
3737
{
38-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
38+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
3939
while (1);
4040
}
4141

examples/Example2_NMEAParsing/Example2_NMEAParsing.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
For more MicroNMEA info see https://github.com/stevemarple/MicroNMEA
1919
2020
Hardware Connections:
21-
Plug a Qwiic cable into the GPS and a BlackBoard
21+
Plug a Qwiic cable into the GNSS and a BlackBoard
2222
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
2323
Open the serial monitor at 115200 baud to see the output
2424
Go outside! Wait ~25 seconds and you should see your lat/long
2525
*/
2626

27-
#include <Wire.h> //Needed for I2C to GPS
27+
#include <Wire.h> //Needed for I2C to GNSS
2828

2929
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
3030
SFE_UBLOX_GPS myGPS;
@@ -42,7 +42,7 @@ void setup()
4242

4343
if (myGPS.begin() == false)
4444
{
45-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
45+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4646
while (1);
4747
}
4848
}

examples/Example3_GetPosition/Example3_GetPosition.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
SAM-M8Q: https://www.sparkfun.com/products/15106
2424
2525
Hardware Connections:
26-
Plug a Qwiic cable into the GPS and a BlackBoard
26+
Plug a Qwiic cable into the GNSS and a BlackBoard
2727
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
2828
Open the serial monitor at 115200 baud to see the output
2929
*/
3030

31-
#include <Wire.h> //Needed for I2C to GPS
31+
#include <Wire.h> //Needed for I2C to GNSS
3232

3333
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
3434
SFE_UBLOX_GPS myGPS;
@@ -45,12 +45,12 @@ void setup()
4545

4646
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4747
{
48-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
48+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4949
while (1);
5050
}
5151

5252
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53-
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
53+
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
5454
}
5555

5656
void loop()

examples/Example4_FixType/Example4_FixType.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
SAM-M8Q: https://www.sparkfun.com/products/15106
2828
2929
Hardware Connections:
30-
Plug a Qwiic cable into the GPS and a BlackBoard
30+
Plug a Qwiic cable into the GNSS and a BlackBoard
3131
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
3232
Open the serial monitor at 115200 baud to see the output
3333
*/
3434

35-
#include <Wire.h> //Needed for I2C to GPS
35+
#include <Wire.h> //Needed for I2C to GNSS
3636

3737
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
3838
SFE_UBLOX_GPS myGPS;
@@ -46,11 +46,11 @@ void setup()
4646
Serial.println("SparkFun u-blox Example");
4747

4848
Wire.begin();
49-
Wire.setClock(400000); //Optional. Increase I2C clock speed to 400kHz.
49+
//Wire.setClock(400000); //Optional. Increase I2C clock speed to 400kHz.
5050

5151
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
5252
{
53-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
53+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
5454
while (1);
5555
}
5656
}
@@ -80,13 +80,15 @@ void loop()
8080
else if(fixType == 1) Serial.print(F("Dead reckoning"));
8181
else if(fixType == 2) Serial.print(F("2D"));
8282
else if(fixType == 3) Serial.print(F("3D"));
83-
else if(fixType == 4) Serial.print(F("GNSS+Dead reckoning"));
83+
else if(fixType == 4) Serial.print(F("GNSS + Dead reckoning"));
84+
else if(fixType == 5) Serial.print(F("Time only"));
8485

8586
byte RTK = myGPS.getCarrierSolutionType();
8687
Serial.print(" RTK: ");
8788
Serial.print(RTK);
88-
if (RTK == 1) Serial.print(F("High precision float fix!"));
89-
if (RTK == 2) Serial.print(F("High precision fix!"));
89+
if (RTK == 0) Serial.print(F(" (No solution)"));
90+
else if (RTK == 1) Serial.print(F(" (High precision floating fix)"));
91+
else if (RTK == 2) Serial.print(F(" (High precision fix)"));
9092

9193
Serial.println();
9294
}

examples/Example5_SpeedHeadingPrecision/Example5_SpeedHeadingPrecision.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
SAM-M8Q: https://www.sparkfun.com/products/15106
2222
2323
Hardware Connections:
24-
Plug a Qwiic cable into the GPS and a BlackBoard
24+
Plug a Qwiic cable into the GNSS and a BlackBoard
2525
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
2626
Open the serial monitor at 115200 baud to see the output
2727
*/
2828

29-
#include <Wire.h> //Needed for I2C to GPS
29+
#include <Wire.h> //Needed for I2C to GNSS
3030

3131
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
3232
SFE_UBLOX_GPS myGPS;
@@ -43,7 +43,7 @@ void setup()
4343

4444
if (myGPS.begin() == false) //Connect to the u-blox module using Wire port
4545
{
46-
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
46+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4747
while (1);
4848
}
4949
}
@@ -76,7 +76,7 @@ void loop()
7676

7777
int pDOP = myGPS.getPDOP();
7878
Serial.print(F(" pDOP: "));
79-
Serial.print(pDOP / 100.0, 2);
79+
Serial.print(pDOP / 100.0, 2); // Convert pDOP scaling from 0.01 to 1
8080

8181
Serial.println();
8282
}

0 commit comments

Comments
 (0)