The SparkFun u-blox GNSS v3 library allows communication with u-blox GNSS modules via the I²C interface. It supports NMEA and UBX protocols.
If you wants to configure the GPS system (base and rover) you can do it on U_center see 2025_I_AV_GNSS_HWSETUP_DDF
This library is compatible with u-blox F9 and M10 modules, such as the ZED-F9P or MAX-M10S.
WireThe Wire library in Arduino is used to communicate with devices using the I²C (Inter-Integrated Circuit) protocol.
These Methods are not useful for us because they are already implemented in the SparkFun u-blox GNSS library, we just have to include it in our code (#include <Wire.h>), see the example
begin() Initializes I²C as a master (usually in setup()).beginTransmission(address) Starts communication with a device at the given I²C address.write(data) Sends one or more bytes of data.endTransmission() Ends the transmission and actually sends the data.requestFrom(address, quantity) Requests bytes from a slave device.read() Reads the bytes received.setClock(frequency) Sets the I²C clock speed (e.g., 100000 for 100 kHz).SFE_UBLOX_GNSSFor I²C communication.
bool begin() // Setup I²C object and pass into the superclass. int8_t getSIV(); // Returns number of sats used in fix
int32_t getLongitude(); // Returns the current longitude in degrees * 10-7. Auto selects between HighPrecision and Regular depending on ability of module.
int32_t getLatitude(); // Returns the current latitude in degrees * 10^-7. Auto selects between HighPrecision and Regular depending on ability of module.
int32_t getAltitude(); // Returns the current altitude in mm above ellipsoid
int32_t getAltitudeMSL(); // Returns the current altitude in mm above mean sea level
int32_t getHorizontalAccEst();
int32_t getVerticalAccEst();
int32_t getNedNorthVel();
int32_t getNedEastVel();
int32_t getNedDownVel();
int32_t getGroundSpeed(); // Returns speed in mm/s
int32_t getHeading(); // Returns heading in degrees * 10^-5
uint32_t getSpeedAccEst();
uint32_t getHeadingAccEst();
uint16_t getPDOP(); // Returns positional dillution of precision * 10^-2 (dimensionless)
uint8_t getCarrierSolutionType(); // Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
uint8_t getFixType(); // Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
bool setI2COutput();// Configure I2C port to output UBX, NMEA, RTCM3, SPARTN or a combination thereof ex : COM_TYPE_UBX
bool setNavigationFrequency();// Set the number of nav solutions sent per second
bool setAutoPVT();// Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
void setI2CpollingWait(); // Allow the user to change the I2C polling wait if required
Two very useful functions for us are setI2CpollingWait() and setNavigationFrequency() because we need to have the data in a non-blocking way, which we can do by setting a very low pollingWait
SFE_UBLOX_GNSS_SERIALFor serial communication (UART).
It might be a good idea to implement this class (see the test report : 2025_I_AV_GNSS_DELAYS_TR). For the rest, this class works exactly like SFE_UBLOX_GNSS, the only two functions to change in the example code are setI2COutput() -> setUART1Output() and setI2CpollingWait() does not seem to have an equivalent for UART (perhaps an oversight) but you can always pass the pollingwaitetime as a parameter to the functions: getLongitude(pollingWait) it works for all get functions
SFE_UBLOX_GNSS_SPIFor SPI communication. (not used)
SFE_UBLOX_GNSS class.begin() function#include <Wire.h>
#include <SparkFun_u-blox_GNSS_v3.h>
SFE_UBLOX_GNSS myGNSS; //or SFE_UBLOX_GNSS_SERIAL
void setup() {
Wire.begin();
Serial.begin(115200);
while (!Serial);
if (myGNSS.begin() == false) {
Serial.println("GNSS not detected. Check wiring.");
while (1);
}
myGNSS.setI2CpollingWait(5); // we set the maximum waiting time to have the GPS data in ms
myGNSS.setI2COutput(COM_TYPE_UBX); // Set the output to UBX protocol
//myGNSS.setUART1Output() // for UART
myGNSS.setNavigationFrequency(5); // Set the update frequency to 1 Hz
}
void loop() {
Serial.print("Latitude: ");
Serial.println(myGNSS.getLatitude());
Serial.print("Longitude: ");
Serial.println(myGNSS.getLongitude());
delay(1000);
}