Skip to content

v3.0.1 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Reading the protocol version of a u-blox module
Reading the protocol and firmware versions of a u-blox module
By: Nathan Seidle
SparkFun Electronics
Date: January 3rd, 2019
Expand Down Expand Up @@ -32,27 +32,43 @@
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
SFE_UBLOX_GNSS myGNSS;

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

void setup()
{
delay(1000);

Serial.begin(115200);
Serial.println("SparkFun u-blox Example");

Wire.begin();

//myGNSS.enableDebugging(Serial); // Uncomment this line to enable debug messages on Serial

if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}

Serial.print(F("Version: "));
byte versionHigh = myGNSS.getProtocolVersionHigh();
Serial.print(versionHigh);
Serial.print(".");
byte versionLow = myGNSS.getProtocolVersionLow();
Serial.print(versionLow);
if (myGNSS.getModuleInfo())
{
Serial.print(F("FWVER: "));
Serial.print(myGNSS.getFirmwareVersionHigh()); // Returns uint8_t
Serial.print(F("."));
Serial.println(myGNSS.getFirmwareVersionLow()); // Returns uint8_t

Serial.print(F("Firmware: "));
Serial.println(myGNSS.getFirmwareType()); // Returns HPG, SPG etc. as (const char *)

Serial.print(F("PROTVER: "));
Serial.print(myGNSS.getProtocolVersionHigh()); // Returns uint8_t
Serial.print(F("."));
Serial.println(myGNSS.getProtocolVersionLow()); // Returns uint8_t

Serial.print(F("MOD: "));
Serial.println(myGNSS.getModuleName()); // Returns ZED-F9P, MAX-M10S etc. as (const char *)
}
else
Serial.println(F("Error: could not read module info!"));
}

void loop()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Reading the protocol version of a u-blox module
Reading the protocol and firmware versions of a u-blox module
By: Nathan Seidle
SparkFun Electronics
Date: January 3rd, 2019
Expand Down Expand Up @@ -32,21 +32,20 @@

#include <SoftwareSerial.h>

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

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

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

void setup()
{
delay(1000);

Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");

Serial.println("Trying 38400 baud");
Expand All @@ -70,12 +69,26 @@ void setup()
}
}

Serial.print(F("Version: "));
byte versionHigh = myGNSS.getProtocolVersionHigh();
Serial.print(versionHigh);
Serial.print(".");
byte versionLow = myGNSS.getProtocolVersionLow();
Serial.print(versionLow);
if (myGNSS.getModuleInfo())
{
Serial.print(F("FWVER: "));
Serial.print(myGNSS.getFirmwareVersionHigh());
Serial.print(F("."));
Serial.println(myGNSS.getFirmwareVersionLow());

Serial.print(F("Firmware: "));
Serial.println(myGNSS.getFirmwareType());

Serial.print(F("PROTVER: "));
Serial.print(myGNSS.getProtocolVersionHigh());
Serial.print(F("."));
Serial.println(myGNSS.getProtocolVersionLow());

Serial.print(F("MOD: "));
Serial.println(myGNSS.getModuleName());
}
else
Serial.println(F("Error: could not read module info!"));
}

void loop()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
/*
Using the SFE_UBLOX_GNSS_SUPER class
By: Paul Clark
SparkFun Electronics
Date: January 20th, 2023
License: MIT. See license file for more information.

This example shows how to use the SFE_UBLOX_GNSS_SUPER class.
It allows you to write multi-purpose code that can:
* Detect what hardware the code is running on
* Select the correct GNSS interface (I2C/SPI/Serial) for that hardware

Feel like supporting open source hardware?
Buy a board from SparkFun!
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037
SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719
SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344

Hardware Connections:
Plug a Qwiic cable into the GNSS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/

#include <Wire.h> // Needed for I2C to GNSS
#include <SPI.h> // Needed for SPI to GNSS

#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3

// Create an object of the GNSS super-class
SFE_UBLOX_GNSS_SUPER theGNSS;

// The super class supports I2C, SPI and Serial.
// Create a global enum that defines which interface to use
typedef enum {
GNSS_IS_I2C,
GNSS_IS_SPI,
GNSS_IS_SERIAL
} GNSS_INTERFACE;
GNSS_INTERFACE theGNSSinterface;

// Define which Serial port the GNSS is (or could be) connected to:
#define gnssSerial Serial1 // Use hardware Serial1 to connect to the GNSS
uint32_t gnssBaudRate = 38400; // Define what Baud Rate to use. Both F9 and M10 devices default to 38400.

// If the GNSS is (or could be) connected via SPI, we need to define the port and the Chip Select pin:
#define gnssSPI SPI // Use SPI to connect to the GNSS
const int gnssSPICS = 4; // Define the Chip Select pin for the SPI interface - Pin 4 is the "free" pin on Thing Plus C

// Define which Wire (I2C) port the GNSS is (or could be) connected to:
#define gnssWire Wire // Use Wire to connect to the GNSS
const uint8_t gnssI2CAddress = 0x42; // Define the GNSS I2C address. The default is usually 0x42. (NEO-D9S uses 0x43)

void setup()
{
delay(1000);

Serial.begin(115200);
Serial.println("SFE_UBLOX_GNSS_SUPER example");

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Define which interface to test.
// The code could auto-detect what board it is running on, e.g. by measuring the
// voltage on an analog pin (defined by a pair of resistors) or reading the board
// type from EEPROM, and then set theGNSSinterface to match.

theGNSSinterface = GNSS_IS_I2C; // Select I2C for this test

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Now prepare the correct hardware interface for GNSS communication

if (theGNSSinterface == GNSS_IS_SERIAL)
{
gnssSerial.begin(gnssBaudRate); // Begin the Serial port
}
else if (theGNSSinterface == GNSS_IS_SPI)
{
pinMode(gnssSPICS, OUTPUT); // Pull the chip select pin high
digitalWrite(gnssSPICS, HIGH);
SPI.begin();
}
else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
{
Wire.begin(); // Begin the Wire port
//Wire.setClock(400000);
}

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Enable debug messages if required

//theGNSS.enableDebugging(Serial); // Uncomment this line to enable debug messages on Serial

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Now begin the GNSS

bool beginSuccess = false;

if (theGNSSinterface == GNSS_IS_SERIAL)
{
beginSuccess = theGNSS.begin(gnssSerial);
}

else if (theGNSSinterface == GNSS_IS_SPI)
{
beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS); // SPI, default to 4MHz

//beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS, 4000000); // Custom

//SPISettings customSPIsettings = SPISettings(4000000, MSBFIRST, SPI_MODE0);
//beginSuccess = theGNSS.begin(gnssSPI, gnssSPICS, customSPIsettings); // Custom
}

else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
{
beginSuccess = theGNSS.begin(gnssWire, gnssI2CAddress);
}

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Check begin was successful

if (beginSuccess == false)
{
Serial.println(F("u-blox GNSS not detected. Please check wiring. Freezing..."));
while (1)
{
; // Do nothing more
}
}

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Disable the NMEA messages, just to show how to do it on the three interfaces:

if (theGNSSinterface == GNSS_IS_SERIAL)
{
// Assume we're connected to UART1. Could be UART2
theGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART1 port to output UBX only (turn off NMEA noise)
}
else if (theGNSSinterface == GNSS_IS_SPI)
{
theGNSS.setSPIOutput(COM_TYPE_UBX); //Set the SPI port to output UBX only (turn off NMEA noise)
}
else // if (theGNSSinterface == GNSS_IS_I2C) // Catch-all. Default to I2C
{
theGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
}

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Read the module info

if (theGNSS.getModuleInfo()) // This line is optional. getModuleName() etc. will read the info if required
{
Serial.print(F("The GNSS module is: "));
Serial.println(theGNSS.getModuleName());

Serial.print(F("The firmware type is: "));
Serial.println(theGNSS.getFirmwareType());

Serial.print(F("The firmware version is: "));
Serial.print(theGNSS.getFirmwareVersionHigh());
Serial.print(F("."));
Serial.println(theGNSS.getFirmwareVersionLow());

Serial.print(F("The protocol version is: "));
Serial.print(theGNSS.getProtocolVersionHigh());
Serial.print(F("."));
Serial.println(theGNSS.getProtocolVersionLow());
}
}

void loop()
{
// Request (poll) the position, velocity and time (PVT) information.
// The module only responds when a new position is available. Default is once per second.
// getPVT() returns true when new data is received.
if (theGNSS.getPVT() == true)
{
int32_t latitude = theGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);

int32_t longitude = theGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));

int32_t altitude = theGNSS.getAltitudeMSL(); // Altitude above Mean Sea Level
Serial.print(F(" Alt: "));
Serial.print(altitude);
Serial.print(F(" (mm)"));

Serial.println();
}
}
6 changes: 6 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
SFE_UBLOX_GNSS KEYWORD1
SFE_UBLOX_GNSS_SPI KEYWORD1
SFE_UBLOX_GNSS_SERIAL KEYWORD1
SFE_UBLOX_GNSS_SUPER KEYWORD1
DevUBLOXGNSS KEYWORD1

ubxPacket KEYWORD1
Expand Down Expand Up @@ -185,7 +186,12 @@ setDGNSSConfiguration KEYWORD2

getProtocolVersionHigh KEYWORD2
getProtocolVersionLow KEYWORD2
getFirmwareVersionHigh KEYWORD2
getFirmwareVersionLow KEYWORD2
getFirmwareType KEYWORD2
getModuleName KEYWORD2
getProtocolVersion KEYWORD2
getModuleInfo KEYWORD2

addGeofence KEYWORD2
clearGeofences KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS v3
version=3.0.0
version=3.0.1
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
Loading