Skip to content

Commit 9df5ba2

Browse files
authored
Merge pull request #2 from sparkfun/release_candidate
v3.0.1
2 parents af4f594 + 64bdc02 commit 9df5ba2

File tree

10 files changed

+478
-58
lines changed

10 files changed

+478
-58
lines changed

examples/Basics/Example8_GetProtocolVersion/Example8_GetProtocolVersion.ino renamed to examples/Basics/Example8_GetModuleInfo/Example8_GetModuleInfo.ino

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Reading the protocol version of a u-blox module
2+
Reading the protocol and firmware versions of a u-blox module
33
By: Nathan Seidle
44
SparkFun Electronics
55
Date: January 3rd, 2019
@@ -32,27 +32,43 @@
3232
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
3333
SFE_UBLOX_GNSS myGNSS;
3434

35-
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
36-
3735
void setup()
3836
{
37+
delay(1000);
38+
3939
Serial.begin(115200);
4040
Serial.println("SparkFun u-blox Example");
4141

4242
Wire.begin();
4343

44+
//myGNSS.enableDebugging(Serial); // Uncomment this line to enable debug messages on Serial
45+
4446
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
4547
{
4648
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
4749
while (1);
4850
}
4951

50-
Serial.print(F("Version: "));
51-
byte versionHigh = myGNSS.getProtocolVersionHigh();
52-
Serial.print(versionHigh);
53-
Serial.print(".");
54-
byte versionLow = myGNSS.getProtocolVersionLow();
55-
Serial.print(versionLow);
52+
if (myGNSS.getModuleInfo())
53+
{
54+
Serial.print(F("FWVER: "));
55+
Serial.print(myGNSS.getFirmwareVersionHigh()); // Returns uint8_t
56+
Serial.print(F("."));
57+
Serial.println(myGNSS.getFirmwareVersionLow()); // Returns uint8_t
58+
59+
Serial.print(F("Firmware: "));
60+
Serial.println(myGNSS.getFirmwareType()); // Returns HPG, SPG etc. as (const char *)
61+
62+
Serial.print(F("PROTVER: "));
63+
Serial.print(myGNSS.getProtocolVersionHigh()); // Returns uint8_t
64+
Serial.print(F("."));
65+
Serial.println(myGNSS.getProtocolVersionLow()); // Returns uint8_t
66+
67+
Serial.print(F("MOD: "));
68+
Serial.println(myGNSS.getModuleName()); // Returns ZED-F9P, MAX-M10S etc. as (const char *)
69+
}
70+
else
71+
Serial.println(F("Error: could not read module info!"));
5672
}
5773

5874
void loop()

examples/Basics/Example8_GetProtocolVersion_Serial/Example8_GetProtocolVersion_Serial.ino renamed to examples/Basics/Example8_GetModuleInfo_Serial/Example8_GetModuleInfo_Serial.ino

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Reading the protocol version of a u-blox module
2+
Reading the protocol and firmware versions of a u-blox module
33
By: Nathan Seidle
44
SparkFun Electronics
55
Date: January 3rd, 2019
@@ -32,21 +32,20 @@
3232

3333
#include <SoftwareSerial.h>
3434

35-
//#define mySerial Serial1 // Uncomment this line to connect via Serial1
35+
#define mySerial Serial1 // Uncomment this line to connect via Serial1
3636
// - or -
3737
//SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin.
3838
// - or -
39-
#define mySerial Serial // Uncomment this line if you just want to keep using Serial
39+
//#define mySerial Serial1 // Uncomment this line if you just want to keep using Serial
4040

4141
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
4242
SFE_UBLOX_GNSS_SERIAL myGNSS;
4343

44-
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
45-
4644
void setup()
4745
{
46+
delay(1000);
47+
4848
Serial.begin(115200);
49-
while (!Serial); //Wait for user to open terminal
5049
Serial.println("SparkFun u-blox Example");
5150

5251
Serial.println("Trying 38400 baud");
@@ -70,12 +69,26 @@ void setup()
7069
}
7170
}
7271

73-
Serial.print(F("Version: "));
74-
byte versionHigh = myGNSS.getProtocolVersionHigh();
75-
Serial.print(versionHigh);
76-
Serial.print(".");
77-
byte versionLow = myGNSS.getProtocolVersionLow();
78-
Serial.print(versionLow);
72+
if (myGNSS.getModuleInfo())
73+
{
74+
Serial.print(F("FWVER: "));
75+
Serial.print(myGNSS.getFirmwareVersionHigh());
76+
Serial.print(F("."));
77+
Serial.println(myGNSS.getFirmwareVersionLow());
78+
79+
Serial.print(F("Firmware: "));
80+
Serial.println(myGNSS.getFirmwareType());
81+
82+
Serial.print(F("PROTVER: "));
83+
Serial.print(myGNSS.getProtocolVersionHigh());
84+
Serial.print(F("."));
85+
Serial.println(myGNSS.getProtocolVersionLow());
86+
87+
Serial.print(F("MOD: "));
88+
Serial.println(myGNSS.getModuleName());
89+
}
90+
else
91+
Serial.println(F("Error: could not read module info!"));
7992
}
8093

8194
void loop()
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/*
2+
Using the SFE_UBLOX_GNSS_SUPER class
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: January 20th, 2023
6+
License: MIT. See license file for more information.
7+
8+
This example shows how to use the SFE_UBLOX_GNSS_SUPER class.
9+
It allows you to write multi-purpose code that can:
10+
* Detect what hardware the code is running on
11+
* Select the correct GNSS interface (I2C/SPI/Serial) for that hardware
12+
13+
Feel like supporting open source hardware?
14+
Buy a board from SparkFun!
15+
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
16+
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
17+
SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037
18+
SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719
19+
SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344
20+
21+
Hardware Connections:
22+
Plug a Qwiic cable into the GNSS and a BlackBoard
23+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
24+
Open the serial monitor at 115200 baud to see the output
25+
*/
26+
27+
#include <Wire.h> // Needed for I2C to GNSS
28+
#include <SPI.h> // Needed for SPI to GNSS
29+
30+
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
31+
32+
// Create an object of the GNSS super-class
33+
SFE_UBLOX_GNSS_SUPER theGNSS;
34+
35+
// The super class supports I2C, SPI and Serial.
36+
// Create a global enum that defines which interface to use
37+
typedef enum {
38+
GNSS_IS_I2C,
39+
GNSS_IS_SPI,
40+
GNSS_IS_SERIAL
41+
} GNSS_INTERFACE;
42+
GNSS_INTERFACE theGNSSinterface;
43+
44+
// Define which Serial port the GNSS is (or could be) connected to:
45+
#define gnssSerial Serial1 // Use hardware Serial1 to connect to the GNSS
46+
uint32_t gnssBaudRate = 38400; // Define what Baud Rate to use. Both F9 and M10 devices default to 38400.
47+
48+
// If the GNSS is (or could be) connected via SPI, we need to define the port and the Chip Select pin:
49+
#define gnssSPI SPI // Use SPI to connect to the GNSS
50+
const int gnssSPICS = 4; // Define the Chip Select pin for the SPI interface - Pin 4 is the "free" pin on Thing Plus C
51+
52+
// Define which Wire (I2C) port the GNSS is (or could be) connected to:
53+
#define gnssWire Wire // Use Wire to connect to the GNSS
54+
const uint8_t gnssI2CAddress = 0x42; // Define the GNSS I2C address. The default is usually 0x42. (NEO-D9S uses 0x43)
55+
56+
void setup()
57+
{
58+
delay(1000);
59+
60+
Serial.begin(115200);
61+
Serial.println("SFE_UBLOX_GNSS_SUPER example");
62+
63+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
64+
// Define which interface to test.
65+
// The code could auto-detect what board it is running on, e.g. by measuring the
66+
// voltage on an analog pin (defined by a pair of resistors) or reading the board
67+
// type from EEPROM, and then set theGNSSinterface to match.
68+
69+
theGNSSinterface = GNSS_IS_I2C; // Select I2C for this test
70+
71+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
72+
// Now prepare the correct hardware interface for GNSS communication
73+
74+
if (theGNSSinterface == GNSS_IS_SERIAL)
75+
{
76+
gnssSerial.begin(gnssBaudRate); // Begin the Serial port
77+
}
78+
else if (theGNSSinterface == GNSS_IS_SPI)
79+
{
80+
pinMode(gnssSPICS, OUTPUT); // Pull the chip select pin high
81+
digitalWrite(gnssSPICS, HIGH);
82+
SPI.begin();
83+
}
84+
else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
85+
{
86+
Wire.begin(); // Begin the Wire port
87+
//Wire.setClock(400000);
88+
}
89+
90+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
91+
// Enable debug messages if required
92+
93+
//theGNSS.enableDebugging(Serial); // Uncomment this line to enable debug messages on Serial
94+
95+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
96+
// Now begin the GNSS
97+
98+
bool beginSuccess = false;
99+
100+
if (theGNSSinterface == GNSS_IS_SERIAL)
101+
{
102+
beginSuccess = theGNSS.begin(gnssSerial);
103+
}
104+
105+
else if (theGNSSinterface == GNSS_IS_SPI)
106+
{
107+
beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS); // SPI, default to 4MHz
108+
109+
//beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS, 4000000); // Custom
110+
111+
//SPISettings customSPIsettings = SPISettings(4000000, MSBFIRST, SPI_MODE0);
112+
//beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS, customSPIsettings); // Custom
113+
}
114+
115+
else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
116+
{
117+
beginSuccess = theGNSS.begin(gnssWire, gnssI2CAddress);
118+
}
119+
120+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
121+
// Check begin was successful
122+
123+
if (beginSuccess == false)
124+
{
125+
Serial.println(F("u-blox GNSS not detected. Please check wiring. Freezing..."));
126+
while (1)
127+
{
128+
; // Do nothing more
129+
}
130+
}
131+
132+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
133+
// Disable the NMEA messages, just to show how to do it on the three interfaces:
134+
135+
if (theGNSSinterface == GNSS_IS_SERIAL)
136+
{
137+
// Assume we're connected to UART1. Could be UART2
138+
theGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART1 port to output UBX only (turn off NMEA noise)
139+
}
140+
else if (theGNSSinterface == GNSS_IS_SPI)
141+
{
142+
theGNSS.setSPIOutput(COM_TYPE_UBX); //Set the SPI port to output UBX only (turn off NMEA noise)
143+
}
144+
else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
145+
{
146+
theGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
147+
}
148+
149+
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
150+
// Read the module info
151+
152+
if (theGNSS.getModuleInfo()) // This line is optional. getModuleName() etc. will read the info if required
153+
{
154+
Serial.print(F("The GNSS module is: "));
155+
Serial.println(theGNSS.getModuleName());
156+
157+
Serial.print(F("The firmware type is: "));
158+
Serial.println(theGNSS.getFirmwareType());
159+
160+
Serial.print(F("The firmware version is: "));
161+
Serial.print(theGNSS.getFirmwareVersionHigh());
162+
Serial.print(F("."));
163+
Serial.println(theGNSS.getFirmwareVersionLow());
164+
165+
Serial.print(F("The protocol version is: "));
166+
Serial.print(theGNSS.getProtocolVersionHigh());
167+
Serial.print(F("."));
168+
Serial.println(theGNSS.getProtocolVersionLow());
169+
}
170+
}
171+
172+
void loop()
173+
{
174+
// Request (poll) the position, velocity and time (PVT) information.
175+
// The module only responds when a new position is available. Default is once per second.
176+
// getPVT() returns true when new data is received.
177+
if (theGNSS.getPVT() == true)
178+
{
179+
int32_t latitude = theGNSS.getLatitude();
180+
Serial.print(F("Lat: "));
181+
Serial.print(latitude);
182+
183+
int32_t longitude = theGNSS.getLongitude();
184+
Serial.print(F(" Long: "));
185+
Serial.print(longitude);
186+
Serial.print(F(" (degrees * 10^-7)"));
187+
188+
int32_t altitude = theGNSS.getAltitudeMSL(); // Altitude above Mean Sea Level
189+
Serial.print(F(" Alt: "));
190+
Serial.print(altitude);
191+
Serial.print(F(" (mm)"));
192+
193+
Serial.println();
194+
}
195+
}

keywords.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
SFE_UBLOX_GNSS KEYWORD1
1010
SFE_UBLOX_GNSS_SPI KEYWORD1
1111
SFE_UBLOX_GNSS_SERIAL KEYWORD1
12+
SFE_UBLOX_GNSS_SUPER KEYWORD1
1213
DevUBLOXGNSS KEYWORD1
1314

1415
ubxPacket KEYWORD1
@@ -185,7 +186,12 @@ setDGNSSConfiguration KEYWORD2
185186

186187
getProtocolVersionHigh KEYWORD2
187188
getProtocolVersionLow KEYWORD2
189+
getFirmwareVersionHigh KEYWORD2
190+
getFirmwareVersionLow KEYWORD2
191+
getFirmwareType KEYWORD2
192+
getModuleName KEYWORD2
188193
getProtocolVersion KEYWORD2
194+
getModuleInfo KEYWORD2
189195

190196
addGeofence KEYWORD2
191197
clearGeofences KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS v3
2-
version=3.0.0
2+
version=3.0.1
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

0 commit comments

Comments
 (0)