Skip to content
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

v2.2.25 #208

Merged
merged 13 commits into from
Oct 10, 2023
5 changes: 3 additions & 2 deletions .github/workflows/compile-sketch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Compile Sketch

on:
# - push
- pull_request

pull_request:
workflow_dispatch:

jobs:
compile-sketch:
Expand Down Expand Up @@ -100,6 +100,7 @@ jobs:
- source-path: ./
sketch-paths: |
- examples/Example20_SendCustomCommand
# - examples/NEO-M8P-2/Example2_StartRTCMBase_virtual/Example2_StartRTCMBase_virtual
enable-warnings-report: true
enable-deltas-report: true
# verbose: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
Note: compiles OK with v2.0 but is currently untested

Send UBX binary commands to enable RTCM sentences on u-blox NEO-M8P-2 module
By: Nathan Seidle
SparkFun Electronics
Date: September 7th, 2018
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

This example does all steps to configure and enable a NEO-M8P-2 as a base station:
Begin Survey-In
Once we've achieved 2m accuracy and 300s have passed, survey is complete
Enable four RTCM messages
Begin outputting RTCM bytes

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106

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 <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS

class MY_SFE_UBLOX_GNSS : public SFE_UBLOX_GNSS
{
//This function gets called from the SparkFun u-blox Arduino Library.
//As each RTCM byte comes in you can specify what to do with it
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
virtual void processRTCM_v(uint8_t incoming)
{
//Let's just pretty-print the HEX values for now
if (rtcmFrameCounter % 16 == 0) Serial.println();
Serial.print(F(" "));
if (incoming < 0x10) Serial.print(F("0"));
Serial.print(incoming, HEX);
}
};

MY_SFE_UBLOX_GNSS myGNSS;

void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println(F("u-blox NEO-M8P-2 base station example"));

Wire.begin();
Wire.setClock(400000); //Increase I2C clock speed to 400kHz

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);
}

myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); // Ensure RTCM3 is enabled
myGNSS.saveConfiguration(); //Save the current settings to flash and BBR

while (Serial.available()) Serial.read(); //Clear any latent chars in serial buffer
Serial.println(F("Press any key to send commands to begin Survey-In"));
while (Serial.available() == 0) ; //Wait for user to press a key

bool response;

//Check if Survey is in Progress before initiating one
// From v2.0, the data from getSurveyStatus (UBX-NAV-SVIN) is returned in UBX_NAV_SVIN_t packetUBXNAVSVIN
// Please see u-blox_structs.h for the full definition of UBX_NAV_SVIN_t
// You can either read the data from packetUBXNAVSVIN directly
// or can use the helper functions: getSurveyInActive; getSurveyInValid; getSurveyInObservationTime; and getSurveyInMeanAccuracy
response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)

if (response == false) // Check if fresh data was received
{
Serial.println(F("Failed to get Survey In status. Freezing..."));
while (1); //Freeze
}

if (myGNSS.getSurveyInActive() == true) // Use the helper function
{
Serial.print(F("Survey already in progress."));
}
else
{
//Start survey
response = myGNSS.enableSurveyMode(300, 2.000); //Enable Survey in, 300 seconds, 2.0m
if (response == false)
{
Serial.println(F("Survey start failed. Freezing..."));
while (1);
}
Serial.println(F("Survey started. This will run until 300s has passed and less than 2m accuracy is achieved."));
}

while(Serial.available()) Serial.read(); //Clear buffer

//Begin waiting for survey to complete
while (myGNSS.getSurveyInValid() == false) // Call the helper function
{
if(Serial.available())
{
byte incoming = Serial.read();
if(incoming == 'x')
{
//Stop survey mode
response = myGNSS.disableSurveyMode(); //Disable survey
Serial.println(F("Survey stopped"));
break;
}
}

// From v2.0, the data from getSurveyStatus (UBX-NAV-SVIN) is returned in UBX_NAV_SVIN_t packetUBXNAVSVIN
// Please see u-blox_structs.h for the full definition of UBX_NAV_SVIN_t
// You can either read the data from packetUBXNAVSVIN directly
// or can use the helper functions: getSurveyInActive; getSurveyInValid; getSurveyInObservationTime; and getSurveyInMeanAccuracy
response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
if (response == true) // Check if fresh data was received
{
Serial.print(F("Press x to end survey - "));
Serial.print(F("Time elapsed: "));
Serial.print((String)myGNSS.getSurveyInObservationTime());

Serial.print(F(" Accuracy: "));
Serial.print((String)myGNSS.getSurveyInMeanAccuracy());
Serial.println();
}
else
{
Serial.println(F("SVIN request failed"));
}

delay(1000);
}
Serial.println(F("Survey valid!"));

response = true;
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_I2C, 1);
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_I2C, 1);
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds

if (response == true)
{
Serial.println(F("RTCM messages enabled"));
}
else
{
Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?"));
while (1); //Freeze
}

Serial.println(F("Base survey complete! RTCM now broadcasting."));
}

void loop()
{
myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in.

delay(250); //Don't pound too hard on the I2C bus
}
18 changes: 18 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ checkUbloxSPI KEYWORD2

process KEYWORD2
processNMEA KEYWORD2
processNMEA_v KEYWORD2
processRTCMframe KEYWORD2
processRTCMframe_v KEYWORD2
processRTCM KEYWORD2
processRTCM_v KEYWORD2
processUBX KEYWORD2
processUBXpacket KEYWORD2

Expand Down Expand Up @@ -563,6 +566,7 @@ getConfirmedDate KEYWORD2
getConfirmedTime KEYWORD2
getFixType KEYWORD2
getGnssFixOk KEYWORD2
getNAVPVTPSMMode KEYWORD2
getDiffSoln KEYWORD2
getHeadVehValid KEYWORD2
getCarrierSolutionType KEYWORD2
Expand Down Expand Up @@ -677,6 +681,9 @@ getLatestNMEAGNZDA KEYWORD2
setNMEAGNZDAcallback KEYWORD2
setNMEAGNZDAcallbackPtr KEYWORD2

setupPowerMode KEYWORD2
setPowerManagement KEYWORD2

extractLong KEYWORD2
extractSignedLong KEYWORD2
extractInt KEYWORD2
Expand Down Expand Up @@ -889,3 +896,14 @@ SFE_UBLOX_MAIN_TALKER_ID_GQ LITERAL1

SFE_UBLOX_DGNSS_MODE_FLOAT LITERAL1
SFE_UBLOX_DGNSS_MODE_FIXED LITERAL1

SFE_UBLOX_PMS_MODE_FULLPOWER LITERAL1
SFE_UBLOX_PMS_MODE_BALANCED LITERAL1
SFE_UBLOX_PMS_MODE_INTERVAL LITERAL1
SFE_UBLOX_PMS_MODE_AGGRESSIVE_1HZ LITERAL1
SFE_UBLOX_PMS_MODE_AGGRESSIVE_2HZ LITERAL1
SFE_UBLOX_PMS_MODE_AGGRESSIVE_4HZ LITERAL1
SFE_UBLOX_PMS_MODE_INVALID LITERAL1

SFE_UBLOX_CFG_RXM_CONTINUOUS LITERAL1
SFE_UBLOX_CFG_RXM_POWERSAVE LITERAL1
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 Arduino Library
version=2.2.24
version=2.2.25
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
Loading
Loading