├── .gitattributes ├── .github └── workflows │ └── compile-sketch.yml ├── .gitignore ├── Adding_New_Messages.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── README.md ├── Theory.md ├── Utils ├── UBX_Integrity_Checker.py └── UBX_RAWX_Aligner.py ├── examples ├── AssistNow │ ├── AssistNow_Autonomous │ │ ├── Example1_AssistNowAutonomous │ │ │ └── Example1_AssistNowAutonomous.ino │ │ ├── Example2_AssistNowAutonomous_DatabaseRead │ │ │ └── Example2_AssistNowAutonomous_DatabaseRead.ino │ │ └── Example3_AssistNowAutonomous_DatabaseWrite │ │ │ ├── Example3_AssistNowAutonomous_DatabaseWrite.ino │ │ │ ├── database.h │ │ │ └── secrets.h │ ├── AssistNow_Offline │ │ └── Example1_AssistNowOffline │ │ │ ├── Example1_AssistNowOffline.ino │ │ │ └── secrets.h │ ├── AssistNow_Online │ │ ├── Example1_AssistNowOnline │ │ │ ├── Example1_AssistNowOnline.ino │ │ │ └── secrets.h │ │ ├── Example2_AssistNowOnline_TimeDelay │ │ │ ├── Example2_AssistNowOnline_TimeDelay.ino │ │ │ └── secrets.h │ │ ├── Example3_AssistNowOnline_PositionAssist │ │ │ ├── Example3_AssistNowOnline_PositionAssist.ino │ │ │ └── secrets.h │ │ ├── Example4_AssistNowOnline_Serial │ │ │ ├── Example4_AssistNowOnline_Serial.ino │ │ │ └── secrets.h │ │ └── Example5_AssistNowOnline_MQTT │ │ │ ├── Example5_AssistNowOnline_MQTT.ino │ │ │ └── secrets.h │ └── README.md ├── Automatic_NMEA │ ├── Example1_getLatestNMEAGPGGA │ │ └── Example1_getLatestNMEAGPGGA.ino │ ├── Example2_NMEA_GGA_Callbacks │ │ └── Example2_NMEA_GGA_Callbacks.ino │ ├── Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA │ │ └── Example3_getLatestNMEA_GPGGA-VTG-RMC-ZDA.ino │ └── Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks │ │ └── Example4_NMEA_GGA_VTG_RMC_ZDA_Callbacks.ino ├── Callbacks │ ├── CallbackExample10_ESF_RAW │ │ └── CallbackExample10_ESF_RAW.ino │ ├── CallbackExample11_ESF_RAW_In_Loop │ │ └── CallbackExample11_ESF_RAW_In_Loop.ino │ ├── CallbackExample12_ESF_MEAS_In_Loop │ │ └── CallbackExample12_ESF_MEAS_In_Loop.ino │ ├── CallbackExample1_NAV_PVT │ │ └── CallbackExample1_NAV_PVT.ino │ ├── CallbackExample2_NAV_ODO │ │ └── CallbackExample2_NAV_ODO.ino │ ├── CallbackExample3_TIM_TM2 │ │ └── CallbackExample3_TIM_TM2.ino │ ├── CallbackExample4_HNR │ │ └── CallbackExample4_HNR.ino │ ├── CallbackExample5_ESF │ │ └── CallbackExample5_ESF.ino │ ├── CallbackExample6_RAWX │ │ └── CallbackExample6_RAWX.ino │ ├── CallbackExample7_NAV_SAT │ │ └── CallbackExample7_NAV_SAT.ino │ ├── CallbackExample8_NAV_SVIN │ │ └── CallbackExample8_NAV_SVIN.ino │ └── CallbackExample9_UseCallbackDataInLoop │ │ └── CallbackExample9_UseCallbackDataInLoop.ino ├── Data_Logging │ ├── DataLoggingExample1_NAV_PVT │ │ └── DataLoggingExample1_NAV_PVT.ino │ ├── DataLoggingExample2_TIM_TM2 │ │ └── DataLoggingExample2_TIM_TM2.ino │ ├── DataLoggingExample3_RXM_SFRBX_and_RAWX │ │ └── DataLoggingExample3_RXM_SFRBX_and_RAWX.ino │ ├── DataLoggingExample4_RXM_without_Callbacks │ │ └── DataLoggingExample4_RXM_without_Callbacks.ino │ ├── DataLoggingExample5_Fast_RXM │ │ └── DataLoggingExample5_Fast_RXM.ino │ ├── DataLoggingExample6_NMEA │ │ └── DataLoggingExample6_NMEA.ino │ └── DataLoggingExample7_OpenLogESP32_SPI_SDIO │ │ └── DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino ├── Dead_Reckoning │ ├── Example1_calibrateSensor │ │ └── Example1_calibrateSensor.ino │ ├── Example2_getIMUData │ │ └── Example2_getIMUData.ino │ ├── Example3_getSensorStatus │ │ └── Example3_getSensorStatus.ino │ ├── Example4_vehicleDynamics │ │ └── Example4_vehicleDynamics.ino │ ├── Example5_getHNRData │ │ └── Example5_getHNRData.ino │ ├── Example6_getAutoHNRData │ │ └── Example6_getAutoHNRData.ino │ ├── Example7_setESFAutoAlignment │ │ └── Example7_setESFAutoAlignment.ino │ └── Example8_getNAVPVAT │ │ └── Example8_getNAVPVAT.ino ├── Example10_AltitudeMSL │ └── Example10_AltitudeMSL.ino ├── Example11_ResetModule │ ├── Example1_FactoryDefaultviaI2C │ │ └── Example1_FactoryDefaultviaI2C.ino │ └── Example2_FactoryDefaultsviaSerial │ │ └── Example2_FactoryDefaultsviaSerial.ino ├── Example12_UseUart │ └── Example12_UseUart.ino ├── Example13_PVT │ ├── Example1_AutoPVT │ │ └── Example1_AutoPVT.ino │ ├── Example2_AutoPVT_ExplicitUpdate │ │ └── Example2_AutoPVT_ExplicitUpdate.ino │ ├── Example3_AutoPVTviaUart │ │ └── Example3_AutoPVTviaUart.ino │ └── Example4_AssumeAutoPVTviaUart │ │ └── Example4_AssumeAutoPVTviaUart.ino ├── Example14_DebugOutput │ └── Example14_DebugOutput.ino ├── Example15_GetDateTime │ └── Example15_GetDateTime.ino ├── Example16_Nanosecond_MaxOutput │ └── Example16_Nanosecond_MaxOutput.ino ├── Example16_PartialSecond_MaxOutput │ └── Example16_PartialSecond_MaxOutput.ino ├── Example17_Geofence │ └── Example17_Geofence.ino ├── Example18_PowerSaveMode │ └── Example18_PowerSaveMode.ino ├── Example19_DynamicModel │ └── Example19_DynamicModel.ino ├── Example1_BasicNMEARead │ └── Example1_BasicNMEARead.ino ├── Example20_SendCustomCommand │ └── Example20_SendCustomCommand.ino ├── Example21_ModuleInfo │ └── Example21_ModuleInfo.ino ├── Example22_PowerOff │ └── Example22_PowerOff.ino ├── Example23_TimePulseParameters │ ├── Example23_TimePulse_BulletTime │ │ └── Example23_TimePulse_BulletTime.ino │ ├── Example23_TimePulse_Frequency │ │ └── Example23_TimePulse_Frequency.ino │ └── Example23_TimePulse_Period │ │ └── Example23_TimePulse_Period.ino ├── Example24_GetUnixEpochAndMicros │ └── Example24_GetUnixEpochAndMicros.ino ├── Example25_MeasurementAndNavigationRate │ └── Example25_MeasurementAndNavigationRate.ino ├── Example26_End │ └── Example26_End.ino ├── Example27_MultipleRates │ └── Example27_MultipleRates.ino ├── Example28_GetLeapSecondInfo │ └── Example28_GetLeapSecondInfo.ino ├── Example29_JammingInformation │ └── Example29_JammingInformation.ino ├── Example2_NMEAParsing │ └── Example2_NMEAParsing.ino ├── Example30_NEO-D9S │ └── Example30_NEO-D9S.ino ├── Example31_Great_Circle_Distance │ └── Example31_Great_Circle_Distance.ino ├── Example32_NEO-D9C │ └── Example32_NEO-D9C.ino ├── Example3_GetPosition │ └── Example3_GetPosition.ino ├── Example4_FixType │ └── Example4_FixType.ino ├── Example5_SpeedHeadingPrecision │ └── Example5_SpeedHeadingPrecision.ino ├── Example6_EnableNMEASentences │ └── Example6_EnableNMEASentences.ino ├── Example7_OutputRate │ └── Example7_OutputRate.ino ├── Example8_GetProtocolVersion │ └── Example8_GetProtocolVersion.ino ├── Example8_GetProtocolVersion_Serial │ └── Example8_GetProtocolVersion_Serial.ino ├── Example9_ChangeI2CAddress │ └── Example9_ChangeI2CAddress.ino ├── NEO-M8P-2 │ ├── Example1_EnableRTCM │ │ └── Example1_EnableRTCM.ino │ ├── Example2_StartRTCMBase │ │ └── Example2_StartRTCMBase.ino │ ├── Example2_StartRTCMBase_virtual │ │ └── Example2_StartRTCMBase_virtual.ino │ ├── Example3_BaseWithLCD │ │ └── Example3_BaseWithLCD.ino │ ├── Example4_MovingBase_Base │ │ └── Example4_MovingBase_Base.ino │ └── Example5_MovingBase_Rover │ │ └── Example5_MovingBase_Rover.ino ├── SPI │ ├── Example1_GetPosition │ │ └── Example1_GetPosition.ino │ └── Example2_AutoPVT │ │ └── Example2_AutoPVT.ino └── ZED-F9P │ ├── Example10_GetHighPrecisionPositionAndAccuracy │ └── Example10_GetHighPrecisionPositionAndAccuracy.ino │ ├── Example11_GetHighPrecisionPositionUsingDouble │ └── Example11_GetHighPrecisionPositionUsingDouble.ino │ ├── Example12_setStaticPosition │ └── Example12_setStaticPosition.ino │ ├── Example13_autoHPPOSLLH │ └── Example13_autoHPPOSLLH.ino │ ├── Example13_autoHPPOSLLH_with_Callback │ └── Example13_autoHPPOSLLH_with_Callback.ino │ ├── Example14_NTRIPServer │ ├── Example14_NTRIPServer.ino │ └── secrets.h │ ├── Example15_NTRIPClient │ ├── Example15_NTRIPClient.ino │ └── secrets.h │ ├── Example16_NTRIPClient_WithGGA │ ├── Example16_NTRIPClient_WithGGA.ino │ └── secrets.h │ ├── Example17_NTRIPClient_With_GGA_Callback │ ├── Example17_NTRIPClient_With_GGA_Callback.ino │ └── secrets.h │ ├── Example18_PointPerfectClient │ ├── Example18_PointPerfectClient.ino │ └── secrets.h │ ├── Example19_LBand_Corrections_with_NEO-D9S │ ├── Example19_LBand_Corrections_with_NEO-D9S.ino │ └── secrets.h │ ├── Example1_GetPositionAccuracy │ └── Example1_GetPositionAccuracy.ino │ ├── Example20_PMP_with_L-Band_Keys_via_MQTT │ ├── Example20_PMP_with_L-Band_Keys_via_MQTT.ino │ └── secrets.h │ ├── Example21_GetHighPrecisionECEFUsingDouble │ └── Example21_GetHighPrecisionECEFUsingDouble.ino │ ├── Example22_QZSSL6_Corrections_with_NEO-D9C │ └── Example22_QZSSL6_Corrections_with_NEO-D9C.ino │ ├── Example23_getRXMRAWX │ └── Example23_getRXMRAWX.ino │ ├── Example2_ValConfigurationMethod │ └── Example2_ValConfigurationMethod.ino │ ├── Example3_StartRTCMBase │ └── Example3_StartRTCMBase.ino │ ├── Example4_BaseWithLCD │ └── Example4_BaseWithLCD.ino │ ├── Example5_RelativePositioningInformation │ └── Example5_RelativePositioningInformation.ino │ ├── Example6_GetVal │ └── Example6_GetVal.ino │ ├── Example7_SetVal │ └── Example7_SetVal.ino │ ├── Example8_GetSetPortSettings │ └── Example8_GetSetPortSettings.ino │ └── Example9_multiSetVal │ └── Example9_multiSetVal.ino ├── img └── Contributing.JPG ├── keys ├── F9-HPS-1.21_InterfaceDescription_UBX-21019746_keys_sorted.txt ├── NEO-D9S_InterfaceDescription_UBX-19048765_keys_sorted.txt ├── ZED-F9T-10B_InterfaceDescription_UBX-20033631_keys_sorted.txt ├── u-blox-D9-QZS-1.01_InterfaceDescription_UBX-21031777_keys_sorted.txt ├── u-blox-F9-HPG-1.30_InterfaceDescription_UBX-21046737_keys_sorted.txt └── u-blox_config_keys_sorted.txt ├── keywords.txt ├── library.properties └── src ├── SparkFun_u-blox_GNSS_Arduino_Library.cpp ├── SparkFun_u-blox_GNSS_Arduino_Library.h ├── u-blox_config_keys.h └── u-blox_structs.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/compile-sketch.yml: -------------------------------------------------------------------------------- 1 | name: Compile Sketch 2 | 3 | on: 4 | # - push 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | compile-sketch: 10 | runs-on: ubuntu-latest 11 | 12 | strategy: 13 | fail-fast: false 14 | 15 | matrix: 16 | board: 17 | # Uno 18 | # https://github.com/arduino/ArduinoCore-avr/blob/master/boards.txt 19 | - fqbn: arduino:avr:uno 20 | platforms: | 21 | - name: arduino:avr 22 | source-url: https://downloads.arduino.cc/packages/package_index.json 23 | 24 | # ESP32 25 | # https://github.com/espressif/arduino-esp32/blob/master/boards.txt 26 | - fqbn: esp32:esp32:esp32 27 | platforms: | 28 | - name: esp32:esp32 29 | source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json 30 | 31 | # ESP32-S2 32 | # https://github.com/espressif/arduino-esp32/blob/master/boards.txt 33 | - fqbn: esp32:esp32:esp32s2 34 | platforms: | 35 | - name: esp32:esp32 36 | source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json 37 | 38 | # ESP32-C3 39 | # https://github.com/espressif/arduino-esp32/blob/master/boards.txt 40 | - fqbn: esp32:esp32:esp32c3 41 | platforms: | 42 | - name: esp32:esp32 43 | source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json 44 | 45 | # Artemis / Apollo3 46 | # https://github.com/sparkfun/Arduino_Apollo3/blob/main/boards.txt 47 | - fqbn: SparkFun:apollo3:sfe_artemis_atp 48 | platforms: | 49 | - name: SparkFun:apollo3 50 | source-url: https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json 51 | 52 | # ESP8266 53 | # https://github.com/esp8266/Arduino/blob/master/boards.txt 54 | - fqbn: esp8266:esp8266:thingdev 55 | platforms: | 56 | - name: esp8266:esp8266 57 | source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json 58 | 59 | # SAMD21 60 | # https://github.com/arduino/ArduinoCore-samd/blob/master/boards.txt 61 | - fqbn: arduino:samd:mkr1000 62 | platforms: | 63 | - name: arduino:samd 64 | # source-url: https://downloads.arduino.cc/packages/package_index.json 65 | 66 | # Nano BLE 33 / nRF52840 67 | # https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt 68 | - fqbn: arduino:mbed:nano33ble 69 | platforms: | 70 | - name: arduino:mbed 71 | # source-url: https://downloads.arduino.cc/packages/package_index.json 72 | 73 | # RP2040 74 | # https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt 75 | - fqbn: rp2040:rp2040:sparkfun_promicrorp2040 76 | platforms: | 77 | - name: rp2040:rp2040 78 | source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json 79 | 80 | # STM32 81 | # https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt 82 | - fqbn: STMicroelectronics:stm32:GenF4 83 | platforms: | 84 | - name: STMicroelectronics:stm32 85 | source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json 86 | 87 | steps: 88 | - name: Checkout 89 | uses: actions/checkout@v2 90 | 91 | - name: Branch name 92 | run: echo running on branch ${GITHUB_REF##*/} 93 | 94 | - name: Compile Sketch 95 | uses: arduino/compile-sketches@v1 96 | with: 97 | platforms: ${{ matrix.board.platforms }} 98 | fqbn: ${{ matrix.board.fqbn }} 99 | libraries: | 100 | - source-path: ./ 101 | sketch-paths: | 102 | - examples/Example20_SendCustomCommand 103 | enable-warnings-report: true 104 | enable-deltas-report: true 105 | # verbose: true 106 | 107 | # outputs: 108 | # report-artifact-name: ${{ steps.report-artifact-name.outputs.report-artifact-name }} 109 | 110 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio Code files 2 | .vscode 3 | 4 | # Windows image file caches 5 | Thumbs.db 6 | ehthumbs.db 7 | 8 | # Folder config file 9 | Desktop.ini 10 | 11 | # Recycle Bin used on file shares 12 | $RECYCLE.BIN/ 13 | 14 | # Windows Installer files 15 | *.cab 16 | *.msi 17 | *.msm 18 | *.msp 19 | 20 | # Windows shortcuts 21 | *.lnk 22 | 23 | # ========================= 24 | # Operating System Files 25 | # ========================= 26 | 27 | # OSX 28 | # ========================= 29 | 30 | .DS_Store 31 | .AppleDouble 32 | .LSOverride 33 | 34 | # Thumbnails 35 | ._* 36 | 37 | # Files that might appear in the root of a volume 38 | .DocumentRevisions-V100 39 | .fseventsd 40 | .Spotlight-V100 41 | .TemporaryItems 42 | .Trashes 43 | .VolumeIcon.icns 44 | 45 | # Directories potentially created on remote AFP share 46 | .AppleDB 47 | .AppleDesktop 48 | Network Trash Folder 49 | Temporary Items 50 | .apdisk 51 | 52 | # VIM backup files 53 | *~ 54 | [._]*.un~ 55 | *.swp 56 | 57 | # Zephyr build files 58 | examples/Zephyr/*/build/* -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB SOURCES src/*.cpp) 2 | idf_component_register( 3 | SRCS ${SOURCES} 4 | INCLUDE_DIRS src 5 | REQUIRES arduino 6 | ) 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | Thank you so *much* for offering to help out. We truly appreciate it. 4 | 5 | If you'd like to contribute, start by searching through the [issues](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/issues) and [pull requests](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/pulls) to see whether someone else has raised a similar idea or question. 6 | Please check the [closed issues](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/issues?q=is%3Aissue+is%3Aclosed) 7 | and [closed pull requests](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/pulls?q=is%3Apr+is%3Aclosed) too - you may find that your issue or feature has already been discussed. 8 | 9 | If you decide to add a feature to this library, please create a PR and follow these best practices: 10 | 11 | * Change as little as possible. Do not submit a PR that changes 100 lines of whitespace. Break up into multiple PRs if necessary. 12 | * If you've added a new feature document it with a simple example sketch. This serves both as a test of your PR and as a quick way for users to quickly learn how to use your new feature. 13 | * If you add new functions also add them to _keywords.txt_ so that they are properly highlighted in Arduino. [Read more](https://www.arduino.cc/en/Hacking/libraryTutorial). 14 | * **Important:** Please submit your PR using the [release_candidate branch](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/tree/release_candidate). That way, we can merge and test your PR quickly without changing the _master_ branch 15 | 16 | ![Contributing.JPG](./img/Contributing.JPG) 17 | 18 | ## Style guide 19 | 20 | Please read and follow the [Arduino API style guide](https://www.arduino.cc/en/Reference/APIStyleGuide). Also read and consider the [Arduino style guide](https://www.arduino.cc/en/Reference/StyleGuide). 21 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Subject of the issue 2 | Describe your issue here. If you reference a datasheet please specify which one and in which section (ie, the protocol manual, section 5.1.2). Additionally, screenshots are easy to paste into github. 3 | 4 | ### Your workbench 5 | * What development board or microcontroller are you using? 6 | * What version of hardware or breakout board are you using? 7 | * How is the breakout board wired to your microcontroller? 8 | * How is everything being powered? 9 | * Are there any additional details that may help us help you? 10 | 11 | ### Steps to reproduce 12 | Tell us how to reproduce this issue. Please post stripped down example code demonstrating your issue. 13 | 14 | ### Expected behavior 15 | Tell us what should happen 16 | 17 | ### Actual behavior 18 | Tell us what happens instead 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | SparkFun License Information 2 | ============================ 3 | 4 | SparkFun uses two different licenses for our files — one for hardware and one for code. 5 | 6 | Hardware 7 | --------- 8 | 9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).** 10 | 11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 12 | 13 | You are free to: 14 | 15 | Share — copy and redistribute the material in any medium or format 16 | Adapt — remix, transform, and build upon the material 17 | for any purpose, even commercially. 18 | The licensor cannot revoke these freedoms as long as you follow the license terms. 19 | Under the following terms: 20 | 21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 24 | Notices: 25 | 26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 28 | 29 | 30 | Code 31 | -------- 32 | 33 | **SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).** 34 | 35 | The MIT License (MIT) 36 | 37 | Copyright (c) 2016 SparkFun Electronics 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a copy 40 | of this software and associated documentation files (the "Software"), to deal 41 | in the Software without restriction, including without limitation the rights 42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the Software is 44 | furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included in all 47 | copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 55 | SOFTWARE. 56 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Autonomous/Example3_AssistNowAutonomous_DatabaseWrite/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Offline/Example1_AssistNowOffline/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Online/Example1_AssistNowOnline/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Online/Example2_AssistNowOnline_TimeDelay/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Online/Example3_AssistNowOnline_PositionAssist/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Online/Example4_AssistNowOnline_Serial/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //Your AssistNow token 6 | const char myAssistNowToken[] = "58XXXXXXXXXXXXXXXXXXYQ"; 7 | -------------------------------------------------------------------------------- /examples/AssistNow/AssistNow_Online/Example5_AssistNowOnline_MQTT/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = ""; 3 | const char password[] = ""; 4 | 5 | // Below infomation you can set after signing up with u-blox Thingstream portal 6 | // and after add a new New PointPerfect Thing 7 | // https://portal.thingstream.io/app/location-services/things 8 | // in the new PointPerfect Thing you go to the credentials page and copy past the values and certificate into this. 9 | 10 | // -> Credentials -> Hostname 11 | const char AWS_IOT_ENDPOINT[] = "pp.services.u-blox.com"; 12 | const unsigned short AWS_IOT_PORT = 8883; 13 | // -> Credentials -> AssistNow (MGA) topic 14 | const char MQTT_TOPIC_ASSISTNOW[] = "/pp/ubx/mga"; 15 | 16 | // -> Credentials -> Client Id 17 | static const char MQTT_CLIENT_ID[] = ""; 18 | 19 | // -> Credentials -> Amazon Root Certificate 20 | static const char AWS_CERT_CA[] PROGMEM = R"EOF( 21 | -----BEGIN CERTIFICATE----- 22 | 23 | -----END CERTIFICATE----- 24 | )EOF"; 25 | 26 | // -> Credentials -> Client Certificate 27 | static const char AWS_CERT_CRT[] PROGMEM = R"KEY( 28 | -----BEGIN CERTIFICATE----- 29 | 30 | -----END CERTIFICATE----- 31 | )KEY"; 32 | 33 | // Get this from Thingstream Portal 34 | // -> Credentials -> Client Key 35 | static const char AWS_CERT_PRIVATE[] PROGMEM = R"KEY( 36 | -----BEGIN RSA PRIVATE KEY----- 37 | 38 | -----END RSA PRIVATE KEY----- 39 | )KEY"; 40 | -------------------------------------------------------------------------------- /examples/Callbacks/CallbackExample1_NAV_PVT/CallbackExample1_NAV_PVT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send position reports over I2C and display them using a callback 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: December 30th, 2020 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the u-blox GNSS to send navigation reports automatically 10 | and access the data via a callback. No more polling! 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | SAM-M8Q: https://www.sparkfun.com/products/15106 17 | 18 | Hardware Connections: 19 | Plug a Qwiic cable into the GPS and a BlackBoard 20 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GPS 25 | 26 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | // Callback: printPVTdata will be called when new NAV PVT data arrives 30 | // See u-blox_structs.h for the full definition of UBX_NAV_PVT_data_t 31 | // _____ You can use any name you like for the callback. Use the same name when you call setAutoPVTcallback 32 | // / _____ This _must_ be UBX_NAV_PVT_data_t 33 | // | / _____ You can use any name you like for the struct 34 | // | | / 35 | // | | | 36 | void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) 37 | { 38 | Serial.println(); 39 | 40 | Serial.print(F("Time: ")); // Print the time 41 | uint8_t hms = ubxDataStruct->hour; // Print the hours 42 | if (hms < 10) Serial.print(F("0")); // Print a leading zero if required 43 | Serial.print(hms); 44 | Serial.print(F(":")); 45 | hms = ubxDataStruct->min; // Print the minutes 46 | if (hms < 10) Serial.print(F("0")); // Print a leading zero if required 47 | Serial.print(hms); 48 | Serial.print(F(":")); 49 | hms = ubxDataStruct->sec; // Print the seconds 50 | if (hms < 10) Serial.print(F("0")); // Print a leading zero if required 51 | Serial.print(hms); 52 | Serial.print(F(".")); 53 | unsigned long millisecs = ubxDataStruct->iTOW % 1000; // Print the milliseconds 54 | if (millisecs < 100) Serial.print(F("0")); // Print the trailing zeros correctly 55 | if (millisecs < 10) Serial.print(F("0")); 56 | Serial.print(millisecs); 57 | 58 | long latitude = ubxDataStruct->lat; // Print the latitude 59 | Serial.print(F(" Lat: ")); 60 | Serial.print(latitude); 61 | 62 | long longitude = ubxDataStruct->lon; // Print the longitude 63 | Serial.print(F(" Long: ")); 64 | Serial.print(longitude); 65 | Serial.print(F(" (degrees * 10^-7)")); 66 | 67 | long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level 68 | Serial.print(F(" Height above MSL: ")); 69 | Serial.print(altitude); 70 | Serial.println(F(" (mm)")); 71 | } 72 | 73 | void setup() 74 | { 75 | Serial.begin(115200); 76 | while (!Serial); //Wait for user to open terminal 77 | Serial.println("SparkFun u-blox Example"); 78 | 79 | Wire.begin(); 80 | 81 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 82 | 83 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 84 | { 85 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 86 | while (1); 87 | } 88 | 89 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 90 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 91 | 92 | myGNSS.setNavigationFrequency(2); //Produce two solutions per second 93 | 94 | myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata 95 | } 96 | 97 | void loop() 98 | { 99 | myGNSS.checkUblox(); // Check for the arrival of new data and process it. 100 | myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed. 101 | 102 | Serial.print("."); 103 | delay(50); 104 | } 105 | -------------------------------------------------------------------------------- /examples/Callbacks/CallbackExample2_NAV_ODO/CallbackExample2_NAV_ODO.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send odometer reports over I2C and display the data using a callback 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: March 20th, 2023 6 | License: MIT. See license file for more information. 7 | 8 | This example shows how to configure the u-blox GNSS to send odometer reports automatically 9 | and display the data via a callback. No more polling! 10 | 11 | Feel like supporting open source hardware? 12 | Buy a board from SparkFun! 13 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 14 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 15 | SAM-M8Q: https://www.sparkfun.com/products/15106 16 | 17 | Hardware Connections: 18 | Plug a Qwiic cable into the GPS and a BlackBoard 19 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 20 | Open the serial monitor at 115200 baud to see the output 21 | */ 22 | 23 | #include //Needed for I2C to GPS 24 | 25 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 26 | SFE_UBLOX_GNSS myGNSS; 27 | 28 | // Callback: printODOdata will be called when new NAV ODO data arrives 29 | // See u-blox_structs.h for the full definition of UBX_NAV_ODO_data_t 30 | // _____ You can use any name you like for the callback. Use the same name when you call setAutoNAVODOcallback 31 | // / _____ This _must_ be UBX_NAV_ODO_data_t 32 | // | / _____ You can use any name you like for the struct 33 | // | | / 34 | // | | | 35 | void printODOdata(UBX_NAV_ODO_data_t *ubxDataStruct) 36 | { 37 | Serial.println(); 38 | 39 | Serial.print(F("TOW: ")); // Print the Time Of Week 40 | unsigned long iTOW = ubxDataStruct->iTOW; // iTOW is in milliseconds 41 | Serial.print(iTOW); 42 | Serial.print(F(" (ms)")); 43 | 44 | Serial.print(F(" Distance: ")); 45 | unsigned long distance = ubxDataStruct->distance; // Print the distance 46 | Serial.print(distance); 47 | Serial.print(F(" (m)")); 48 | 49 | Serial.print(F(" Total Distance: ")); 50 | unsigned long totalDistance = ubxDataStruct->totalDistance; // Print the total distance 51 | Serial.print(totalDistance); 52 | Serial.println(F(" (m)")); 53 | } 54 | 55 | void setup() 56 | { 57 | delay(1000); 58 | 59 | Serial.begin(115200); 60 | while (!Serial); //Wait for user to open terminal 61 | Serial.println("SparkFun u-blox Example"); 62 | 63 | Wire.begin(); 64 | 65 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 66 | 67 | while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 68 | { 69 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring.")); 70 | } 71 | 72 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 73 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 74 | 75 | myGNSS.setNavigationFrequency(1); //Produce one solution per second 76 | 77 | //By default, the odometer is disabled. We need to enable it. 78 | //We can enable it using the default settings: 79 | myGNSS.enableOdometer(); 80 | 81 | //Or we can configure it using our own settings, by performing a read-modify-write: 82 | uint8_t flags; // Odometer/Low-speed COG filter flags 83 | uint8_t odoCfg; // Odometer filter settings 84 | uint8_t cogMaxSpeed; // Speed below which course-over-ground (COG) is computed with the low-speed COG filter : m/s * 0.1 85 | uint8_t cogMaxPosAcc; // Maximum acceptable position accuracy for computing COG with the low-speed COG filter 86 | uint8_t velLpGain; // Velocity low-pass filter level 87 | uint8_t cogLpGain; // COG low-pass filter level 88 | 89 | if (myGNSS.getOdometerConfig(&flags, &odoCfg, &cogMaxSpeed, &cogMaxPosAcc, &velLpGain, &cogLpGain)) 90 | { 91 | flags = UBX_CFG_ODO_USE_ODO; // Enable the odometer 92 | odoCfg = UBX_CFG_ODO_CAR; // Use the car profile (others are RUN, CYCLE, SWIM, CUSTOM) 93 | myGNSS.setOdometerConfig(flags, odoCfg, cogMaxSpeed, cogMaxPosAcc, velLpGain, cogLpGain); // Set the configuration 94 | } 95 | else 96 | Serial.println("Could not read odometer config!"); 97 | 98 | //myGNSS.resetOdometer(); //Uncomment this line to reset the odometer 99 | 100 | myGNSS.setAutoNAVODOcallbackPtr(&printODOdata); // Enable automatic NAV ODO messages with callback to printODOdata 101 | } 102 | 103 | void loop() 104 | { 105 | myGNSS.checkUblox(); // Check for the arrival of new data and process it. 106 | myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed. 107 | 108 | Serial.print("."); 109 | delay(50); 110 | } 111 | -------------------------------------------------------------------------------- /examples/Callbacks/CallbackExample6_RAWX/CallbackExample6_RAWX.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send RXM RZWX reports over I2C and display them using a callback 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: March 11th, 2021 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the u-blox GNSS to send RXM RAWX reports automatically 10 | and access the data via a callback. No more polling! 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | 16 | Hardware Connections: 17 | Plug a Qwiic cable into the GPS and a BlackBoard 18 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 19 | Open the serial monitor at 115200 baud to see the output 20 | */ 21 | 22 | #include //Needed for I2C to GPS 23 | 24 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 25 | SFE_UBLOX_GNSS myGNSS; 26 | 27 | // Callback: newRAWX will be called when new RXM RAWX data arrives 28 | // See u-blox_structs.h for the full definition of UBX_RXMRAWX_data_t 29 | // _____ You can use any name you like for the callback. Use the same name when you call setAutoRXMRAWXcallback 30 | // / _____ This _must_ be UBX_RXM_RAWX_data_t 31 | // | / _____ You can use any name you like for the struct 32 | // | | / 33 | // | | | 34 | void newRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct) 35 | { 36 | Serial.println(); 37 | 38 | Serial.print(F("New RAWX data received. It contains ")); 39 | Serial.print(ubxDataStruct->header.numMeas); // Print numMeas (Number of measurements / blocks) 40 | Serial.println(F(" data blocks:")); 41 | 42 | for (uint8_t block = 0; block < ubxDataStruct->header.numMeas; block++) // For each block 43 | { 44 | Serial.print(F("GNSS ID: ")); 45 | if (ubxDataStruct->blocks[block].gnssId < 100) Serial.print(F(" ")); // Align the gnssId 46 | if (ubxDataStruct->blocks[block].gnssId < 10) Serial.print(F(" ")); // Align the gnssId 47 | Serial.print(ubxDataStruct->blocks[block].gnssId); 48 | Serial.print(F(" SV ID: ")); 49 | if (ubxDataStruct->blocks[block].svId < 100) Serial.print(F(" ")); // Align the svId 50 | if (ubxDataStruct->blocks[block].svId < 10) Serial.print(F(" ")); // Align the svId 51 | Serial.print(ubxDataStruct->blocks[block].svId); 52 | 53 | if (sizeof(double) == 8) // Check if our processor supports 64-bit double 54 | { 55 | // Convert prMes from uint8_t[8] to 64-bit double 56 | // prMes is little-endian 57 | double pseudorange; 58 | memcpy(&pseudorange, &ubxDataStruct->blocks[block].prMes, 8); 59 | Serial.print(F(" PR: ")); 60 | Serial.print(pseudorange, 3); 61 | 62 | // Convert cpMes from uint8_t[8] to 64-bit double 63 | // cpMes is little-endian 64 | double carrierPhase; 65 | memcpy(&carrierPhase, &ubxDataStruct->blocks[block].cpMes, 8); 66 | Serial.print(F(" m CP: ")); 67 | Serial.print(carrierPhase, 3); 68 | Serial.print(F(" cycles")); 69 | } 70 | Serial.println(); 71 | } 72 | } 73 | 74 | void setup() 75 | { 76 | Serial.begin(115200); 77 | while (!Serial); //Wait for user to open terminal 78 | Serial.println("SparkFun u-blox Example"); 79 | 80 | Wire.begin(); 81 | 82 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 83 | 84 | myGNSS.disableUBX7Fcheck(); // RAWX data can legitimately contain 0x7F, so we need to disable the "7F" check in checkUbloxI2C 85 | 86 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 87 | { 88 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 89 | while (1); 90 | } 91 | 92 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 93 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 94 | 95 | myGNSS.setNavigationFrequency(1); //Produce one solution per second (RAWX produces a _lot_ of data!) 96 | 97 | myGNSS.setAutoRXMRAWXcallbackPtr(&newRAWX); // Enable automatic RXM RAWX messages with callback to newRAWX 98 | } 99 | 100 | void loop() 101 | { 102 | myGNSS.checkUblox(); // Check for the arrival of new data and process it. 103 | myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed. 104 | 105 | Serial.print("."); 106 | delay(50); 107 | } 108 | -------------------------------------------------------------------------------- /examples/Callbacks/CallbackExample7_NAV_SAT/CallbackExample7_NAV_SAT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send NAV SAT reports over I2C and display them using a callback 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: December 1st, 2021 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the u-blox GNSS to send NAV SAT reports automatically 10 | and access the data via a callback. No more polling! 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | 16 | Hardware Connections: 17 | Plug a Qwiic cable into the GPS and a BlackBoard 18 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 19 | Open the serial monitor at 115200 baud to see the output 20 | */ 21 | 22 | #include //Needed for I2C to GPS 23 | 24 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 25 | SFE_UBLOX_GNSS myGNSS; 26 | 27 | // Callback: newNAVSAT will be called when new NAV SAT data arrives 28 | // See u-blox_structs.h for the full definition of UBX_NAV_SAT_data_t 29 | // _____ You can use any name you like for the callback. Use the same name when you call setAutoNAVSATcallback 30 | // / _____ This _must_ be UBX_NAV_SAT_data_t 31 | // | / _____ You can use any name you like for the struct 32 | // | | / 33 | // | | | 34 | void newNAVSAT(UBX_NAV_SAT_data_t *ubxDataStruct) 35 | { 36 | Serial.println(); 37 | 38 | Serial.print(F("New NAV SAT data received. It contains data for ")); 39 | Serial.print(ubxDataStruct->header.numSvs); 40 | if (ubxDataStruct->header.numSvs == 1) 41 | Serial.println(F(" SV.")); 42 | else 43 | Serial.println(F(" SVs.")); 44 | 45 | // Just for giggles, print the signal strength for each SV as a barchart 46 | for (uint16_t block = 0; block < ubxDataStruct->header.numSvs; block++) // For each SV 47 | { 48 | switch (ubxDataStruct->blocks[block].gnssId) // Print the GNSS ID 49 | { 50 | case 0: 51 | Serial.print(F("GPS ")); 52 | break; 53 | case 1: 54 | Serial.print(F("SBAS ")); 55 | break; 56 | case 2: 57 | Serial.print(F("Galileo ")); 58 | break; 59 | case 3: 60 | Serial.print(F("BeiDou ")); 61 | break; 62 | case 4: 63 | Serial.print(F("IMES ")); 64 | break; 65 | case 5: 66 | Serial.print(F("QZSS ")); 67 | break; 68 | case 6: 69 | Serial.print(F("GLONASS ")); 70 | break; 71 | default: 72 | Serial.print(F("UNKNOWN ")); 73 | break; 74 | } 75 | 76 | Serial.print(ubxDataStruct->blocks[block].svId); // Print the SV ID 77 | 78 | if (ubxDataStruct->blocks[block].svId < 10) Serial.print(F(" ")); 79 | else if (ubxDataStruct->blocks[block].svId < 100) Serial.print(F(" ")); 80 | else Serial.print(F(" ")); 81 | 82 | // Print the signal strength as a bar chart 83 | for (uint8_t cno = 0; cno < ubxDataStruct->blocks[block].cno; cno++) 84 | Serial.print(F("=")); 85 | 86 | Serial.println(); 87 | } 88 | } 89 | 90 | void setup() 91 | { 92 | Serial.begin(115200); 93 | while (!Serial); //Wait for user to open terminal 94 | Serial.println("SparkFun u-blox Example"); 95 | 96 | Wire.begin(); 97 | 98 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 99 | 100 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 101 | { 102 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 103 | while (1); 104 | } 105 | 106 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 107 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 108 | 109 | myGNSS.setNavigationFrequency(1); //Produce one solution per second 110 | 111 | myGNSS.setAutoNAVSATcallbackPtr(&newNAVSAT); // Enable automatic NAV SAT messages with callback to newNAVSAT 112 | } 113 | 114 | void loop() 115 | { 116 | myGNSS.checkUblox(); // Check for the arrival of new data and process it. 117 | myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed. 118 | 119 | Serial.print("."); 120 | delay(50); 121 | } 122 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example1_calibrateSensor/Example1_calibrateSensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Elias Santistevan 3 | SparkFun Electronics 4 | Date: May, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | Feel like supporting open source hardware? 9 | Buy a board from SparkFun! 10 | NEO-M8U: https://www.sparkfun.com/products/16329 11 | ZED-F9R: https://www.sparkfun.com/products/16344 12 | 13 | Hardware Connections: 14 | Plug a Qwiic cable into the GNSS and a Redboard Qwiic 15 | If you don't have a platform with a Qwiic connection use the 16 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 17 | Open the serial monitor at 115200 baud to see the output 18 | 19 | To take advantage of the internal IMU of either the Dead Reckoning GNSS 20 | boards (ZED-F9R, NEO-M8U), you must first calibrate it. This includes securing the GNSS module 21 | to your vehicle so that it is stable within 2 degrees and that the frame of 22 | reference of the board is consistent with the picture outlined in the 23 | Receiver-Description-Prot-Spec Datasheet under Automotive/Untethered Dead 24 | Reckoning. You may also check either the ZED-F9R or NEO-M8U Hookup Guide for 25 | more information. After the board is secure, you'll need to put the module 26 | through certain conditions for proper calibration: acceleration, turning, 27 | stopping for a few minutes, getting to a speed over 30km/h all under a clear sky 28 | with good GNSS signal. This example simply looks at the 29 | "fusionMode" status which indicates whether the SparkFun Dead Reckoning is 30 | initializing - 0, calibrated - 1, or if an error has occurred - 2,3. 31 | */ 32 | 33 | #include //Needed for I2C to GNSS 34 | 35 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 36 | SFE_UBLOX_GNSS myGNSS; 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | while (!Serial); //Wait for user to open terminal 42 | Serial.println(F("SparkFun u-blox Example")); 43 | 44 | Wire.begin(); 45 | 46 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 47 | { 48 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 49 | while (1); 50 | } 51 | 52 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 53 | 54 | //myGNSS.resetIMUalignment(); // Uncomment this line to reset the IMU alignment 55 | } 56 | 57 | void loop() 58 | { 59 | // ESF data is produced at the navigation rate, so by default we'll get fresh data once per second 60 | if (myGNSS.getEsfInfo()) // Poll new ESF STATUS data 61 | { 62 | Serial.print(F("Fusion Mode: ")); 63 | Serial.print(myGNSS.packetUBXESFSTATUS->data.fusionMode); 64 | if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 0) 65 | Serial.println(F(" Sensor is initializing...")); 66 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 1) 67 | Serial.println(F(" Sensor is calibrated!")); 68 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 2) 69 | Serial.println(F(" Sensor fusion is suspended!")); 70 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 3) 71 | Serial.println(F(" Sensor fusion is disabled!")); 72 | } 73 | 74 | delay(250); 75 | } 76 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example2_getIMUData/Example2_getIMUData.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Elias Santistevan 3 | SparkFun Electronics 4 | Date: May, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | Feel like supporting open source hardware? 9 | Buy a board from SparkFun! 10 | NEO-M8U: https://www.sparkfun.com/products/16329 11 | ZED-F9R: https://www.sparkfun.com/products/16344 12 | 13 | Hardware Connections: 14 | Plug a Qwiic cable into the GNSS and a Redboard Qwiic 15 | If you don't have a platform with a Qwiic connection use the 16 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 17 | Open the serial monitor at 115200 baud to see the output 18 | 19 | After calibrating the module, also known as "Fusion Mode", you can get 20 | data directly from the IMU. This data is integrated directly into the GNSS 21 | output, but is provided by the module as well. 22 | 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | while (!Serial); //Wait for user to open terminal 34 | Serial.println(F("SparkFun u-blox Example")); 35 | 36 | Wire.begin(); 37 | 38 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 39 | { 40 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 41 | while (1); 42 | } 43 | 44 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 45 | 46 | if (myGNSS.getEsfInfo()){ 47 | 48 | Serial.print(F("Fusion Mode: ")); 49 | Serial.println(myGNSS.packetUBXESFSTATUS->data.fusionMode); 50 | 51 | if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 1){ 52 | Serial.println(F("Fusion Mode is Initialized!")); 53 | } 54 | else { 55 | Serial.println(F("Fusion Mode is either disabled or not initialized!")); 56 | Serial.println(F("Please see the previous example for more information.")); 57 | } 58 | } 59 | } 60 | 61 | void loop() 62 | { 63 | // ESF data is produced at the navigation rate, so by default we'll get fresh data once per second 64 | if (myGNSS.getEsfIns()) // Poll new ESF INS data 65 | { 66 | Serial.print(F("X Ang Rate: ")); 67 | Serial.print(myGNSS.packetUBXESFINS->data.xAngRate); 68 | Serial.print(F(" Y Ang Rate: ")); 69 | Serial.print(myGNSS.packetUBXESFINS->data.yAngRate); 70 | Serial.print(F(" Z Ang Rate: ")); 71 | Serial.print(myGNSS.packetUBXESFINS->data.zAngRate); 72 | Serial.print(F(" X Accel: ")); 73 | Serial.print(myGNSS.packetUBXESFINS->data.xAccel); 74 | Serial.print(F(" Y Accel: ")); 75 | Serial.print(myGNSS.packetUBXESFINS->data.yAccel); 76 | Serial.print(F(" Z Accel: ")); 77 | Serial.print(myGNSS.packetUBXESFINS->data.zAccel); 78 | 79 | // These values also have "validity checks" that can be provided by the 80 | // ublox library by reading bitfield0 81 | Serial.print(F(" Validity: ")); 82 | Serial.print(myGNSS.packetUBXESFINS->data.bitfield0.bits.xAngRateValid); 83 | Serial.print(myGNSS.packetUBXESFINS->data.bitfield0.bits.yAngRateValid); 84 | Serial.print(myGNSS.packetUBXESFINS->data.bitfield0.bits.zAngRateValid); 85 | Serial.print(myGNSS.packetUBXESFINS->data.bitfield0.bits.xAccelValid); 86 | Serial.print(myGNSS.packetUBXESFINS->data.bitfield0.bits.yAccelValid); 87 | Serial.println(myGNSS.packetUBXESFINS->data.bitfield0.bits.zAccelValid); 88 | } 89 | 90 | delay(250); 91 | } 92 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example4_vehicleDynamics/Example4_vehicleDynamics.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Elias Santistevan 3 | SparkFun Electronics 4 | Date: May, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | Feel like supporting open source hardware? 9 | Buy a board from SparkFun! 10 | NEO-M8U: https://www.sparkfun.com/products/16329 11 | ZED-F9R: https://www.sparkfun.com/products/16344 12 | 13 | Hardware Connections: 14 | Plug a Qwiic cable into the GNSS and a Redboard Qwiic 15 | If you don't have a platform with a Qwiic connection use the 16 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 17 | Open the serial monitor at 115200 baud to see the output 18 | 19 | getEsfAlignment (UBX-ESF-ALG) reports the status and alignment angles of the IMU within the vehicle. 20 | These define the rotation of the IMU frame within the vehicle (installation frame) - not the heading 21 | of the vehicle itself. The vehicle attitude solution is reported separately by getNAVATT (UBX-NAV-ATT). 22 | 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | while (!Serial); //Wait for user to open terminal 34 | Serial.println(F("SparkFun u-blox Example")); 35 | 36 | Wire.begin(); 37 | 38 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 39 | { 40 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 41 | while (1); 42 | } 43 | 44 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 45 | 46 | myGNSS.setESFAutoAlignment(true); //Enable Automatic IMU-mount Alignment 47 | 48 | if (myGNSS.getEsfInfo()){ 49 | 50 | Serial.print(F("Fusion Mode: ")); 51 | Serial.println(myGNSS.packetUBXESFSTATUS->data.fusionMode); 52 | 53 | if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 1){ 54 | Serial.println(F("Fusion Mode is Initialized!")); 55 | } 56 | else { 57 | Serial.println(F("Fusion Mode is either disabled or not initialized!")); 58 | Serial.println(F("Please see the previous example for more information.")); 59 | } 60 | } 61 | } 62 | 63 | void loop() 64 | { 65 | // ESF data is produced at the navigation rate, so by default we'll get fresh data once per second 66 | if (myGNSS.getEsfAlignment()) // Poll new ESF ALG data 67 | { 68 | Serial.print(F("IMU-Mount Alignment: On/Off: ")); 69 | Serial.print(myGNSS.packetUBXESFALG->data.flags.bits.autoMntAlgOn); 70 | Serial.print(F(" Status: ")); 71 | Serial.print(myGNSS.packetUBXESFALG->data.flags.bits.status); 72 | Serial.print(F(" Roll: ")); 73 | Serial.print(myGNSS.getESFroll(), 2); // Use the helper function to get the roll in degrees 74 | Serial.print(F(" Pitch: ")); 75 | Serial.print(myGNSS.getESFpitch(), 2); // Use the helper function to get the pitch in degrees 76 | Serial.print(F(" Yaw: ")); 77 | Serial.print(myGNSS.getESFyaw(), 2); // Use the helper function to get the yaw in degrees 78 | Serial.print(F(" Errors: ")); 79 | Serial.print(myGNSS.packetUBXESFALG->data.error.bits.tiltAlgError); 80 | Serial.print(myGNSS.packetUBXESFALG->data.error.bits.yawAlgError); 81 | Serial.println(myGNSS.packetUBXESFALG->data.error.bits.angleError); 82 | } 83 | 84 | if (myGNSS.getNAVATT()) // Poll new NAV ATT data 85 | { 86 | Serial.print(F("Vehicle Attitude: Roll: ")); 87 | Serial.print(myGNSS.getATTroll(), 2); // Use the helper function to get the roll in degrees 88 | Serial.print(F(" Pitch: ")); 89 | Serial.print(myGNSS.getATTpitch(), 2); // Use the helper function to get the pitch in degrees 90 | Serial.print(F(" Heading: ")); 91 | Serial.println(myGNSS.getATTheading(), 2); // Use the helper function to get the heading in degrees 92 | } 93 | 94 | delay(250); 95 | } 96 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example5_getHNRData/Example5_getHNRData.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Paul Clark 3 | SparkFun Electronics 4 | Date: December, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example configures the High Navigation Rate on the NEO-M8U and then 9 | polls and displays the attitude solution, vehicle dynamics information 10 | and high rate position, velocity and time. 11 | 12 | This example polls the high rate data. 13 | (The next example uses "autoHNR" to receive the HNR data automatically.) 14 | 15 | Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary: 16 | https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | NEO-M8U: https://www.sparkfun.com/products/16329 21 | 22 | Hardware Connections: 23 | Plug a Qwiic cable into the GPS and a Redboard Qwiic 24 | If you don't have a platform with a Qwiic connection use the 25 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | 28 | */ 29 | 30 | #include //Needed for I2C to GPS 31 | 32 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while (!Serial); //Wait for user to open terminal 39 | Serial.println(F("SparkFun u-blox Example")); 40 | 41 | Wire.begin(); 42 | 43 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial 44 | 45 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 46 | { 47 | Serial.println(F("Warning! u-blox GPS did not begin correctly.")); 48 | Serial.println(F("(This may be because the I2C port is busy with HNR messages.)")); 49 | } 50 | 51 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 52 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 53 | 54 | if (myGNSS.setHNRNavigationRate(10) == true) //Set the High Navigation Rate to 10Hz 55 | Serial.println(F("setHNRNavigationRate was successful")); 56 | else 57 | Serial.println(F("setHNRNavigationRate was NOT successful")); 58 | 59 | myGNSS.setAutoHNRATT(false); //Make sure auto HNR attitude messages are disabled 60 | myGNSS.setAutoHNRINS(false); //Make sure auto HNR vehicle dynamics messages are disabled 61 | myGNSS.setAutoHNRPVT(false); //Make sure auto HNR PVT messages are disabled 62 | } 63 | 64 | void loop() 65 | { 66 | // Poll and print selected HNR data 67 | if (myGNSS.getHNRAtt(125) == true) // Request HNR Att data using a 125ms timeout 68 | { 69 | Serial.print(F("Roll: ")); 70 | Serial.print(myGNSS.getHNRroll(), 2); // Use the helper function to get the roll in degrees 71 | Serial.print(F(" Pitch: ")); 72 | Serial.print(myGNSS.getHNRpitch(), 2); // Use the helper function to get the pitch in degrees 73 | Serial.print(F(" Heading: ")); 74 | Serial.println(myGNSS.getHNRheading(), 2); // Use the helper function to get the heading in degrees 75 | } 76 | if (myGNSS.getHNRDyn(125) == true) // Request HNR Dyn data using a 125ms timeout 77 | { 78 | Serial.print(F("xAccel: ")); 79 | Serial.print(myGNSS.packetUBXHNRINS->data.xAccel); 80 | Serial.print(F(" yAccel: ")); 81 | Serial.print(myGNSS.packetUBXHNRINS->data.yAccel); 82 | Serial.print(F(" zAccel: ")); 83 | Serial.println(myGNSS.packetUBXHNRINS->data.zAccel); 84 | } 85 | if (myGNSS.getHNRPVT(125) == true) // Request HNR PVT data using a 125ms timeout 86 | { 87 | Serial.print(F("ns: ")); 88 | Serial.print(myGNSS.packetUBXHNRPVT->data.nano); 89 | Serial.print(F(" Lat: ")); 90 | Serial.print(myGNSS.packetUBXHNRPVT->data.lat); 91 | Serial.print(F(" Lon: ")); 92 | Serial.println(myGNSS.packetUBXHNRPVT->data.lon); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example6_getAutoHNRData/Example6_getAutoHNRData.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Paul Clark 3 | SparkFun Electronics 4 | Date: December, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example configures the High Navigation Rate on the NEO-M8U and then 9 | reads and displays the attitude solution, vehicle dynamics information 10 | and high rate position, velocity and time. 11 | 12 | This example uses "autoHNR" to receive the HNR data automatically. 13 | 14 | Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary: 15 | https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | NEO-M8U: https://www.sparkfun.com/products/16329 20 | 21 | Hardware Connections: 22 | Plug a Qwiic cable into the GPS and a Redboard Qwiic 23 | If you don't have a platform with a Qwiic connection use the 24 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 25 | Open the serial monitor at 115200 baud to see the output 26 | 27 | */ 28 | 29 | #include //Needed for I2C to GPS 30 | 31 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | bool usingAutoHNRAtt = false; 35 | bool usingAutoHNRDyn = false; 36 | bool usingAutoHNRPVT = false; 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | while (!Serial); //Wait for user to open terminal 42 | Serial.println(F("SparkFun u-blox Example")); 43 | 44 | Wire.begin(); 45 | 46 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial 47 | 48 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 49 | { 50 | Serial.println(F("Warning! u-blox GPS did not begin correctly.")); 51 | Serial.println(F("(This may be because the I2C port is busy with HNR messages.)")); 52 | } 53 | 54 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 55 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 56 | 57 | if (myGNSS.setHNRNavigationRate(10) == true) //Set the High Navigation Rate to 10Hz 58 | Serial.println(F("setHNRNavigationRate was successful")); 59 | else 60 | Serial.println(F("setHNRNavigationRate was NOT successful")); 61 | 62 | usingAutoHNRAtt = myGNSS.setAutoHNRATT(true); //Attempt to enable auto HNR attitude messages 63 | if (usingAutoHNRAtt) 64 | Serial.println(F("AutoHNRATT successful")); 65 | 66 | usingAutoHNRDyn = myGNSS.setAutoHNRINS(true); //Attempt to enable auto HNR vehicle dynamics messages 67 | if (usingAutoHNRDyn) 68 | Serial.println(F("AutoHNRINS successful")); 69 | 70 | usingAutoHNRPVT = myGNSS.setAutoHNRPVT(true); //Attempt to enable auto HNR PVT messages 71 | if (usingAutoHNRPVT) 72 | Serial.println(F("AutoHNRPVT successful")); 73 | } 74 | 75 | void loop() 76 | { 77 | if (usingAutoHNRAtt && (myGNSS.getHNRAtt() == true)) // If setAutoHNRAtt was successful and new data is available 78 | { 79 | Serial.print(F("Roll: ")); // Print selected data 80 | Serial.print(myGNSS.getHNRroll(), 2); // Use the helper function to get the roll in degrees 81 | Serial.print(F(" Pitch: ")); 82 | Serial.print(myGNSS.getHNRpitch(), 2); // Use the helper function to get the pitch in degrees 83 | Serial.print(F(" Heading: ")); 84 | Serial.println(myGNSS.getHNRheading(), 2); // Use the helper function to get the heading in degrees 85 | myGNSS.flushHNRATT(); // Mark data as stale 86 | } 87 | if (usingAutoHNRDyn && (myGNSS.getHNRDyn() == true)) // If setAutoHNRDyn was successful and new data is available 88 | { 89 | Serial.print(F("xAccel: ")); // Print selected data 90 | Serial.print(myGNSS.packetUBXHNRINS->data.xAccel); 91 | Serial.print(F(" yAccel: ")); 92 | Serial.print(myGNSS.packetUBXHNRINS->data.yAccel); 93 | Serial.print(F(" zAccel: ")); 94 | Serial.println(myGNSS.packetUBXHNRINS->data.zAccel); 95 | myGNSS.flushHNRINS(); // Mark data as stale 96 | } 97 | if (usingAutoHNRPVT && (myGNSS.getHNRPVT() == true)) // If setAutoHNRPVT was successful and new data is available 98 | { 99 | Serial.print(F("ns: ")); // Print selected data 100 | Serial.print(myGNSS.packetUBXHNRPVT->data.nano); 101 | Serial.print(F(" Lat: ")); 102 | Serial.print(myGNSS.packetUBXHNRPVT->data.lat); 103 | Serial.print(F(" Lon: ")); 104 | Serial.println(myGNSS.packetUBXHNRPVT->data.lon); 105 | myGNSS.flushHNRPVT(); // Mark data as stale 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /examples/Dead_Reckoning/Example7_setESFAutoAlignment/Example7_setESFAutoAlignment.ino: -------------------------------------------------------------------------------- 1 | /* 2 | By: Nathan Seidle 3 | SparkFun Electronics 4 | Date: August, 2021 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example configures the AutoAlignment option for the IMU. 9 | The ZED-F9R Integration guide recommends enabling Auto Alignment once 10 | the device has been attached to the vehicle's frame. 11 | Enabling auto-alignment will cause the the sensor fusion status 12 | to begin initialization. After driving around a few turns, the sensors 13 | should enter 'Calibrated' state. See example 1 for fusion state or 14 | monitor UBX-ESF-STATUS. 15 | 16 | As of writing the ZED-F9R is using HPS v1.2 firmware. Please update using u-center if necessary. 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | ZED-F9R: https://www.sparkfun.com/products/16344 21 | ZED-F9R pHat: https://www.sparkfun.com/products/16475 22 | NEO-M8U: https://www.sparkfun.com/products/16329 23 | 24 | Hardware Connections: 25 | Plug a Qwiic cable into the GPS and a Redboard Qwiic 26 | If you don't have a platform with a Qwiic connection use the 27 | SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/17912) 28 | Open the serial monitor at 115200 baud to see the output 29 | 30 | */ 31 | 32 | #include //Needed for I2C to GPS 33 | 34 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 35 | SFE_UBLOX_GNSS myGNSS; 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | while (!Serial); //Wait for user to open terminal 41 | Serial.println(F("SparkFun u-blox Example")); 42 | 43 | Wire.begin(); 44 | 45 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial 46 | 47 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 48 | { 49 | Serial.println(F("Warning! u-blox GPS did not begin correctly.")); 50 | Serial.println(F("(This may be because the I2C port is busy with HNR messages.)")); 51 | } 52 | 53 | bool esfAutoAlignment = myGNSS.getESFAutoAlignment(); 54 | Serial.print(F("esfAutoAlignment: ")); 55 | if (esfAutoAlignment == true) 56 | Serial.println(F("True")); 57 | else 58 | Serial.println(F("False")); 59 | 60 | myGNSS.setESFAutoAlignment(true); //Enable UBX-CFG-ESFALG Automatic IMU-mount Alignment 61 | 62 | myGNSS.setAutoHNRATT(false); //Make sure auto HNR attitude messages are disabled 63 | myGNSS.setAutoHNRINS(false); //Make sure auto HNR vehicle dynamics messages are disabled 64 | myGNSS.setAutoHNRPVT(false); //Make sure auto HNR PVT messages are disabled 65 | 66 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 67 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 68 | } 69 | 70 | void loop() 71 | { 72 | // ESF data is produced at the navigation rate, so by default we'll get fresh data once per second 73 | if (myGNSS.getEsfInfo()) // Poll new ESF STATUS data 74 | { 75 | Serial.print(F("Fusion Mode: ")); 76 | Serial.print(myGNSS.packetUBXESFSTATUS->data.fusionMode); 77 | if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 0) 78 | Serial.println(F(" Sensor is initializing...")); 79 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 1) 80 | Serial.println(F(" Sensor is calibrated!")); 81 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 2) 82 | Serial.println(F(" Sensor fusion is suspended!")); 83 | else if (myGNSS.packetUBXESFSTATUS->data.fusionMode == 3) 84 | Serial.println(F(" Sensor fusion is disabled!")); 85 | } 86 | 87 | // Poll and print selected HNR data 88 | if (myGNSS.getHNRAtt(125) == true) // Request HNR Att data using a 125ms timeout 89 | { 90 | Serial.print(F("Roll: ")); 91 | Serial.print(myGNSS.getHNRroll(), 2); // Use the helper function to get the roll in degrees 92 | Serial.print(F(" Pitch: ")); 93 | Serial.print(myGNSS.getHNRpitch(), 2); // Use the helper function to get the pitch in degrees 94 | Serial.print(F(" Heading: ")); 95 | Serial.println(myGNSS.getHNRheading(), 2); // Use the helper function to get the heading in degrees 96 | } 97 | if (myGNSS.getHNRDyn(125) == true) // Request HNR Dyn data using a 125ms timeout 98 | { 99 | Serial.print(F("xAccel: ")); 100 | Serial.print(myGNSS.packetUBXHNRINS->data.xAccel); 101 | Serial.print(F(" yAccel: ")); 102 | Serial.print(myGNSS.packetUBXHNRINS->data.yAccel); 103 | Serial.print(F(" zAccel: ")); 104 | Serial.println(myGNSS.packetUBXHNRINS->data.zAccel); 105 | } 106 | if (myGNSS.getHNRPVT(125) == true) // Request HNR PVT data using a 125ms timeout 107 | { 108 | Serial.print(F("ns: ")); 109 | Serial.print(myGNSS.packetUBXHNRPVT->data.nano); 110 | Serial.print(F(" Lat: ")); 111 | Serial.print(myGNSS.packetUBXHNRPVT->data.lat); 112 | Serial.print(F(" Lon: ")); 113 | Serial.println(myGNSS.packetUBXHNRPVT->data.lon); 114 | } 115 | 116 | } -------------------------------------------------------------------------------- /examples/Example10_AltitudeMSL/Example10_AltitudeMSL.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading two altitudes - Mean Sea Level and Ellipsode 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its lat/long/altitude. 10 | 11 | getAltitude() reports mm above ellipsode model of the globe. There are some 12 | instances where altitude above Mean Sea Level is better. This example shows how 13 | to use getAltitudeMSL(). The difference varies but is ~20m. 14 | Ellipsoid model: https://www.esri.com/news/arcuser/0703/geoid1of3.html 15 | Difference between Ellipsoid Model and Mean Sea Level: https://eos-gnss.com/elevation-for-beginners/ 16 | 17 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 18 | 19 | Feel like supporting open source hardware? 20 | Buy a board from SparkFun! 21 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 22 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 23 | SAM-M8Q: https://www.sparkfun.com/products/15106 24 | 25 | Hardware Connections: 26 | Plug a Qwiic cable into the GNSS and a BlackBoard 27 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 28 | Open the serial monitor at 115200 baud to see the output 29 | */ 30 | 31 | #include //Needed for I2C to GNSS 32 | 33 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 34 | SFE_UBLOX_GNSS myGNSS; 35 | 36 | long lastTime = 0; //Tracks the passing of 2000ms (2 seconds) 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | while (!Serial); //Wait for user to open terminal 42 | Serial.println("SparkFun u-blox Example"); 43 | 44 | Wire.begin(); 45 | 46 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 47 | { 48 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 49 | while (1); 50 | } 51 | } 52 | 53 | void loop() 54 | { 55 | //Query module only every second. Doing it more often will just cause I2C traffic. 56 | //The module only responds when a new position is available 57 | if (millis() - lastTime > 1000) 58 | { 59 | lastTime = millis(); //Update the timer 60 | 61 | long latitude = myGNSS.getLatitude(); 62 | Serial.print(F("Lat: ")); 63 | Serial.print(latitude); 64 | 65 | long longitude = myGNSS.getLongitude(); 66 | Serial.print(F(" Long: ")); 67 | Serial.print(longitude); 68 | Serial.print(F(" (degrees * 10^-7)")); 69 | 70 | long altitude = myGNSS.getAltitude(); 71 | Serial.print(F(" Alt: ")); 72 | Serial.print(altitude); 73 | Serial.print(F(" (mm)")); 74 | 75 | long altitudeMSL = myGNSS.getAltitudeMSL(); 76 | Serial.print(F(" AltMSL: ")); 77 | Serial.print(altitudeMSL); 78 | Serial.print(F(" (mm)")); 79 | 80 | Serial.println(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C/Example1_FactoryDefaultviaI2C.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send command to reset module over I2C 3 | By: Nathan Seidle 4 | Date: January 29rd, 2019 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example shows how to reset the U-Blox module to factory defaults over I2C. 9 | 10 | Feel like supporting open source hardware? 11 | Buy a board from SparkFun! 12 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 13 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 14 | SAM-M8Q: https://www.sparkfun.com/products/15106 15 | 16 | Hardware Connections: 17 | Plug a Qwiic cable into the GNSS and a BlackBoard 18 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 19 | Open the serial monitor at 115200 baud to see the output 20 | */ 21 | 22 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 23 | SFE_UBLOX_GNSS myGNSS; 24 | 25 | void setup() 26 | { 27 | Serial.begin(115200); 28 | while (!Serial); //Wait for user to open terminal 29 | Serial.println("SparkFun u-blox Example"); 30 | 31 | Wire.begin(); 32 | 33 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 34 | { 35 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 36 | while (1); 37 | } 38 | 39 | while (Serial.available()) Serial.read(); //Trash any incoming chars 40 | Serial.println("Press a key to reset module to factory defaults"); 41 | while (Serial.available() == false) ; //Wait for user to send character 42 | 43 | myGNSS.factoryReset(); //Reset everything: baud rate, I2C address, update rate, everything. 44 | 45 | delay(5000); // Wait while the module restarts 46 | 47 | while (myGNSS.begin() == false) //Attempt to re-connect 48 | { 49 | delay(1000); 50 | Serial.println(F("Attempting to re-connect to u-blox GNSS...")); 51 | } 52 | 53 | Serial.println("Unit has now been factory reset. Freezing..."); 54 | while(1); // Do nothing more 55 | } 56 | 57 | void loop() 58 | { 59 | 60 | } 61 | -------------------------------------------------------------------------------- /examples/Example11_ResetModule/Example2_FactoryDefaultsviaSerial/Example2_FactoryDefaultsviaSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Test baud rate changes on serial, factory reset, and hard reset. 3 | By: Thorsten von Eicken 4 | Date: January 29rd, 2019 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example shows how to reset the U-Blox module to factory defaults over serial. 9 | 10 | Feel like supporting open source hardware? 11 | Buy a board from SparkFun! 12 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 13 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 14 | SAM-M8Q: https://www.sparkfun.com/products/15106 15 | 16 | Hardware Connections: 17 | Connect the U-Blox serial port to Serial1 18 | If you're using a Uno or don't have a 2nd serial port (Serial1), use SoftwareSerial instead (see below) 19 | Open the serial monitor at 115200 baud to see the output 20 | */ 21 | 22 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 23 | SFE_UBLOX_GNSS myGNSS; 24 | 25 | #include 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 | 35 | int state = 0; // steps through auto-baud, reset, etc states 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | while (!Serial); //Wait for user to open terminal 41 | Serial.println("SparkFun u-blox Example"); 42 | 43 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 44 | } 45 | 46 | void loop() 47 | { 48 | Serial.print("===== STATE "); 49 | Serial.println(state); 50 | switch (state) { 51 | case 0: // auto-baud connection, then switch to 38400 and save config 52 | do { 53 | Serial.println("GNSS: trying 38400 baud"); 54 | mySerial.begin(38400); 55 | if (myGNSS.begin(mySerial)) break; 56 | 57 | delay(100); 58 | Serial.println("GNSS: trying 9600 baud"); 59 | mySerial.begin(9600); 60 | if (myGNSS.begin(mySerial)) { 61 | Serial.println("GNSS: connected at 9600 baud, switching to 38400"); 62 | myGNSS.setSerialRate(38400); 63 | delay(100); 64 | } else { 65 | delay(2000); //Wait a bit before trying again to limit the Serial output flood 66 | } 67 | } while(1); 68 | myGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only 69 | myGNSS.saveConfiguration(); //Save the current settings to flash and BBR 70 | Serial.println("GNSS serial connected, saved config"); 71 | state++; 72 | break; 73 | case 1: // hardReset, expect to see GNSS back at 38400 baud 74 | Serial.println("Issuing hardReset (cold start)"); 75 | myGNSS.hardReset(); 76 | delay(2000); 77 | mySerial.begin(38400); 78 | if (myGNSS.begin(mySerial)) { 79 | Serial.println("Success."); 80 | state++; 81 | } else { 82 | Serial.println("*** GNSS did not respond at 38400 baud, starting over."); 83 | state = 0; 84 | } 85 | break; 86 | case 2: // factoryReset, expect to see GNSS back at defaultRate baud 87 | Serial.println("Issuing factoryReset"); 88 | myGNSS.factoryReset(); 89 | delay(5000); // takes more than one second... a loop to resync would be best 90 | mySerial.begin(defaultRate); 91 | if (myGNSS.begin(mySerial)) { 92 | Serial.println("Success."); 93 | state++; 94 | } else { 95 | Serial.println("*** GNSS did not come back at defaultRate baud, starting over."); 96 | state = 0; 97 | } 98 | break; 99 | case 3: // print version info 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: "); 103 | Serial.print(myGNSS.getProtocolVersionHigh()); 104 | Serial.print('.'); 105 | Serial.println(myGNSS.getProtocolVersionLow()); 106 | Serial.println("All finished! Freezing..."); 107 | while(1); 108 | } 109 | delay(1000); 110 | } 111 | -------------------------------------------------------------------------------- /examples/Example12_UseUart/Example12_UseUart.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading lat and long via UBX binary commands using UART @38400 baud - free from I2C 3 | By: Nathan Seidle, Adapted from Example3_GetPosition by Thorsten von Eicken 4 | SparkFun Electronics 5 | Date: January 28rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the library and U-Blox for serial port use as well as 10 | switching the module from the default 9600 baud to 38400. 11 | 12 | Note: Long/lat are large numbers because they are * 10^7. To convert lat/long 13 | to something google maps understands simply divide the numbers by 10,000,000. We 14 | do this so that we don't have to use floating point numbers. 15 | 16 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 21 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 22 | SAM-M8Q: https://www.sparkfun.com/products/15106 23 | 24 | Hardware Connections: 25 | Connect the U-Blox serial TX pin to Uno pin 10 26 | Connect the U-Blox serial RX pin to Uno pin 11 27 | Open the serial monitor at 115200 baud to see the output 28 | */ 29 | 30 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 31 | SFE_UBLOX_GNSS myGNSS; 32 | 33 | #include 34 | SoftwareSerial mySerial(10, 11); // RX, TX. Pin 10 on Uno goes to TX pin on GNSS module. 35 | 36 | long lastTime = 0; //Simple local timer. Limits amount of I2C traffic to u-blox module. 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | while (!Serial); //Wait for user to open terminal 42 | Serial.println("SparkFun u-blox Example"); 43 | 44 | //Assume that the U-Blox GNSS is running at 9600 baud (the default) or at 38400 baud. 45 | //Loop until we're in sync and then ensure it's at 38400 baud. 46 | do { 47 | Serial.println("GNSS: trying 38400 baud"); 48 | mySerial.begin(38400); 49 | if (myGNSS.begin(mySerial) == true) break; 50 | 51 | delay(100); 52 | Serial.println("GNSS: trying 9600 baud"); 53 | mySerial.begin(9600); 54 | if (myGNSS.begin(mySerial) == true) { 55 | Serial.println("GNSS: connected at 9600 baud, switching to 38400"); 56 | myGNSS.setSerialRate(38400); 57 | delay(100); 58 | } else { 59 | //myGNSS.factoryReset(); 60 | delay(2000); //Wait a bit before trying again to limit the Serial output 61 | } 62 | } while(1); 63 | Serial.println("GNSS serial connected"); 64 | 65 | myGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART port to output UBX only 66 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 67 | myGNSS.saveConfiguration(); //Save the current settings to flash and BBR 68 | } 69 | 70 | void loop() 71 | { 72 | //Query module only every second. Doing it more often will just cause I2C traffic. 73 | //The module only responds when a new position is available 74 | if (millis() - lastTime > 1000) 75 | { 76 | lastTime = millis(); //Update the timer 77 | 78 | long latitude = myGNSS.getLatitude(); 79 | Serial.print(F("Lat: ")); 80 | Serial.print(latitude); 81 | 82 | long longitude = myGNSS.getLongitude(); 83 | Serial.print(F(" Long: ")); 84 | Serial.print(longitude); 85 | Serial.print(F(" (degrees * 10^-7)")); 86 | 87 | long altitude = myGNSS.getAltitude(); 88 | Serial.print(F(" Alt: ")); 89 | Serial.print(altitude); 90 | Serial.print(F(" (mm)")); 91 | 92 | byte SIV = myGNSS.getSIV(); 93 | Serial.print(F(" SIV: ")); 94 | Serial.print(SIV); 95 | 96 | Serial.println(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /examples/Example13_PVT/Example2_AutoPVT_ExplicitUpdate/Example2_AutoPVT_ExplicitUpdate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send position reports over I2C, with explicit data parsing calls 3 | By: Nathan Seidle Thorsten von Eicken and Felix Jirka 4 | SparkFun Electronics 5 | Date: July 1st, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the U-Blox GNSS the send navigation reports automatically 10 | and retrieving the latest one via checkUblox when available. 11 | This eliminates the implicit update in getPVT when accessing data fields twice. 12 | Also this reduces the memory overhead of a separate buffer while introducing a slight error by inconsistencies because of the unsynchronized updates (on a multi core system). 13 | 14 | This can be used over serial or over I2C, this example shows the I2C use. With serial the GNSS 15 | simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in 16 | size?) where it can be retrieved in the next I2C poll. 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 21 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 22 | SAM-M8Q: https://www.sparkfun.com/products/15106 23 | 24 | Hardware Connections: 25 | Plug a Qwiic cable into the GNSS and a BlackBoard 26 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 27 | Open the serial monitor at 115200 baud to see the output 28 | */ 29 | 30 | #include //Needed for I2C to GNSS 31 | 32 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while (!Serial) 39 | ; //Wait for user to open terminal 40 | Serial.println("SparkFun u-blox Example"); 41 | 42 | Wire.begin(); 43 | 44 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1) 48 | ; 49 | } 50 | 51 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 52 | myGNSS.setNavigationFrequency(2); //Produce two solutions per second 53 | myGNSS.setAutoPVT(true, false); //Tell the GNSS to "send" each solution and the lib not to update stale data implicitly 54 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 55 | } 56 | 57 | /* 58 | Calling getPVT would return false now (compare to previous example where it would return true), so we just use the data provided 59 | If you are using a threaded OS eg. FreeRTOS on an ESP32, the explicit mode of autoPVT allows you to use the data provided on both cores and inside multiple threads 60 | The data update in background creates an inconsistent state, but that should not cause issues for most applications as they usually won't change the GNSS location significantly within a 2Hz - 5Hz update rate. 61 | Also you could oversample (10Hz - 20Hz) the data to smooth out such issues... 62 | */ 63 | void loop() 64 | { 65 | static uint16_t counter = 0; 66 | 67 | if (counter % 10 == 0) 68 | { 69 | // update your AHRS filter here for a ~100Hz update rate 70 | // GNSS data will be quasi static but data from your IMU will be changing 71 | } 72 | // debug output each half second 73 | if (counter % 500 == 0) 74 | { 75 | Serial.println(); 76 | long latitude = myGNSS.getLatitude(); 77 | Serial.print(F("Lat: ")); 78 | Serial.print(latitude); 79 | 80 | long longitude = myGNSS.getLongitude(); 81 | Serial.print(F(" Long: ")); 82 | Serial.print(longitude); 83 | Serial.print(F(" (degrees * 10^-7)")); 84 | 85 | long altitude = myGNSS.getAltitude(); 86 | Serial.print(F(" Alt: ")); 87 | Serial.print(altitude); 88 | Serial.print(F(" (mm)")); 89 | 90 | byte SIV = myGNSS.getSIV(); 91 | Serial.print(F(" SIV: ")); 92 | Serial.print(SIV); 93 | 94 | Serial.println(); 95 | } 96 | // call checkUblox all 50ms to capture the GNSS data 97 | if (counter % 50 == 0) 98 | { 99 | myGNSS.checkUblox(); 100 | } 101 | delay(1); 102 | counter++; 103 | } 104 | -------------------------------------------------------------------------------- /examples/Example13_PVT/Example3_AutoPVTviaUart/Example3_AutoPVTviaUart.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send position reports over Serial 3 | By: Nathan Seidle, Adapted from Example11 by Felix Jirka 4 | SparkFun Electronics 5 | Date: July 2nd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the U-Blox GNSS the send navigation reports automatically 10 | and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GNSS 11 | produces a fresh navigation solution at the expense of returning a slighly old solution. 12 | 13 | This can be used over serial or over I2C, this example shows the Serial use. With serial the GNSS 14 | simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in 15 | size?) where it can be retrieved in the next I2C poll. 16 | 17 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 18 | 19 | Feel like supporting open source hardware? 20 | Buy a board from SparkFun! 21 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 22 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 23 | SAM-M8Q: https://www.sparkfun.com/products/15106 24 | 25 | Hardware Connections: 26 | Plug a Qwiic cable into the GNSS and a BlackBoard 27 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 28 | Open the serial monitor at 115200 baud to see the output 29 | */ 30 | 31 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | #include 35 | 36 | //#define mySerial Serial2 // Uncomment this line to connect via Serial2 37 | // - or - 38 | SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin. 39 | 40 | //#define baudRate 9600 // Uncomment this line to select 9600 Baud for the M8 41 | // - or - 42 | #define baudRate 38400 // Uncomment this line to select 38400 Baud for the F9 43 | 44 | void setup() 45 | { 46 | Serial.begin(115200); 47 | while (!Serial); //Wait for user to open terminal 48 | Serial.println("SparkFun u-blox Example"); 49 | 50 | mySerial.begin(baudRate); // Start the Serial port 51 | 52 | if (myGNSS.begin(mySerial) == false) //Connect to the u-blox module using Serial 53 | { 54 | Serial.println(F("u-blox GNSS not detected. Please check wiring. Freezing.")); 55 | while (1); 56 | } 57 | 58 | myGNSS.setUART1Output(COM_TYPE_UBX); //Set the UART1 port to output UBX only (turn off NMEA noise) 59 | myGNSS.setNavigationFrequency(2); //Produce two solutions per second 60 | myGNSS.setAutoPVT(true); //Tell the GNSS to "send" each solution 61 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 62 | } 63 | 64 | void loop() 65 | { 66 | // getPVT will return true if there actually is a fresh navigation solution available. 67 | // Important note: the PVT message is 100 bytes long. We need to call getPVT often enough 68 | // to prevent serial buffer overflows on boards like the original RedBoard / UNO. 69 | // At 38400 Baud, the 100 PVT bytes will arrive in 26ms. 70 | // On the RedBoard, we need to call getPVT every 5ms to keep up. 71 | if (myGNSS.getPVT()) 72 | { 73 | Serial.println(); 74 | 75 | long latitude = myGNSS.getLatitude(); 76 | Serial.print(F("Lat: ")); 77 | Serial.print(latitude); 78 | 79 | long longitude = myGNSS.getLongitude(); 80 | Serial.print(F(" Long: ")); 81 | Serial.print(longitude); 82 | Serial.print(F(" (degrees * 10^-7)")); 83 | 84 | long altitude = myGNSS.getAltitude(); 85 | Serial.print(F(" Alt: ")); 86 | Serial.print(altitude); 87 | Serial.print(F(" (mm)")); 88 | 89 | byte SIV = myGNSS.getSIV(); 90 | Serial.print(F(" SIV: ")); 91 | Serial.print(SIV); 92 | 93 | Serial.println(); 94 | } 95 | else 96 | { 97 | delay(5); // Delay for 5ms only 98 | 99 | static int counter = 0; // Print a dot every 50ms 100 | counter++; 101 | if (counter > 10) 102 | { 103 | Serial.print("."); 104 | counter = 0; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /examples/Example13_PVT/Example4_AssumeAutoPVTviaUart/Example4_AssumeAutoPVTviaUart.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading lat and long via UBX binary commands using an RX-only UART 3 | By: Nathan Seidle, Adapted from Example11 by Felix Jirka 4 | SparkFun Electronics 5 | Date: July 2nd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the library for serial port use with a single wire connection using the assumeAutoPVT method. 10 | Saving your pins for other stuff :-) 11 | 12 | This example only works correctly if the module has already been configured is sending PVT messages via its UART1 TX pin. 13 | Run the previous example to enable the auto PVT messages if you need to. 14 | 15 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Preconditions: 24 | U-Blox module is configured to send cyclical PVT message 25 | 26 | Hardware Connections: 27 | Connect the U-Blox serial TX pin to Rx of Serial2 (default: GPIO16) on your ESP32 28 | Or, switch to SoftwareSerial 29 | Open the serial monitor at 115200 baud to see the output 30 | */ 31 | 32 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | #include 36 | 37 | //#define mySerial Serial2 // Uncomment this line to connect via Serial2 38 | // - or - 39 | SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin. 40 | 41 | //#define baudRate 9600 // Uncomment this line to select 9600 Baud for the M8 42 | // - or - 43 | #define baudRate 38400 // Uncomment this line to select 38400 Baud for the F9 44 | 45 | void setup() 46 | { 47 | Serial.begin(115200); 48 | while (!Serial); //Wait for user to open terminal 49 | Serial.println("SparkFun u-blox Example"); 50 | 51 | //Use any Serial port with at least a RX Pin connected or a receive only version of SoftwareSerial here 52 | //Assume that the U-Blox GNSS is running at baudRate baud 53 | mySerial.begin(baudRate); 54 | // No need to check return value as internal call to isConnected() will not succeed 55 | myGNSS.begin(mySerial); 56 | 57 | // Tell the library we are expecting the module to send PVT messages by itself to our Rx pin. 58 | // You can set second parameter to "false" if you want to control the parsing and eviction of the data (need to call checkUblox cyclically) 59 | myGNSS.assumeAutoPVT(true, true); 60 | 61 | } 62 | 63 | void loop() 64 | { 65 | // If implicit updates are enabled, calling getPVT will trigger parsing of the incoming messages 66 | // and return true once a PVT message has been parsed. 67 | // In case you want to use explicit updates, wrap this in a timer and call checkUblox() 68 | // as often as needed, not to overflow your UART buffers. 69 | // 70 | // Important note: the PVT message is 100 bytes long. We need to call getPVT often enough 71 | // to prevent serial buffer overflows on boards like the original RedBoard / UNO. 72 | // At 38400 Baud, the 100 PVT bytes will arrive in 26ms. 73 | // On the RedBoard, we need to call getPVT every 5ms to keep up. 74 | if (myGNSS.getPVT()) 75 | { 76 | Serial.println(); 77 | 78 | long latitude = myGNSS.getLatitude(); 79 | Serial.print(F("Lat: ")); 80 | Serial.print(latitude); 81 | 82 | long longitude = myGNSS.getLongitude(); 83 | Serial.print(F(" Long: ")); 84 | Serial.print(longitude); 85 | Serial.print(F(" (degrees * 10^-7)")); 86 | 87 | long altitude = myGNSS.getAltitude(); 88 | Serial.print(F(" Alt: ")); 89 | Serial.print(altitude); 90 | Serial.print(F(" (mm)")); 91 | 92 | byte SIV = myGNSS.getSIV(); 93 | Serial.print(F(" SIV: ")); 94 | Serial.print(SIV); 95 | 96 | Serial.println(); 97 | } 98 | else 99 | { 100 | delay(5); // Delay for 5ms only 101 | 102 | static int counter = 0; // Print a dot every 50ms 103 | counter++; 104 | if (counter > 10) 105 | { 106 | Serial.print("."); 107 | counter = 0; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /examples/Example14_DebugOutput/Example14_DebugOutput.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Debug Output 3 | By: Nathan Seidle, Adapted from Example3_GetPosition by Thorsten von Eicken 4 | SparkFun Electronics 5 | Date: January 28rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the debug output from the library. 10 | Debug shows various packet and status outputs. These prints can be directed 11 | towards Serial (as in Serial.print) or any other port (Serial1, SerialUSB, etc). 12 | 13 | You can also limit the debug messages to the "critical" ones by adding an extra argument. 14 | 15 | The debug messages can be disabled again by calling disableDebugging() 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a BlackBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 30 | SFE_UBLOX_GNSS myGNSS; 31 | 32 | unsigned long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 33 | int counter = 0; // Disable the debug messages when counter reaches 20 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while (!Serial); //Wait for user to open terminal 39 | Serial.println("SparkFun u-blox Example"); 40 | 41 | Wire.begin(); 42 | 43 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 44 | { 45 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 46 | while (1); 47 | } 48 | 49 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 50 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 51 | 52 | myGNSS.enableDebugging(); //Enable all the debug messages over Serial (default) 53 | 54 | //myGNSS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB 55 | 56 | //myGNSS.enableDebugging(Serial, true); //Enable only the critical debug messages over Serial 57 | 58 | } 59 | 60 | void loop() 61 | { 62 | //Query module only every second. Doing it more often will just cause I2C traffic. 63 | //The module only responds when a new position is available 64 | if (millis() - lastTime > 1000) 65 | { 66 | lastTime = millis(); //Update the timer 67 | 68 | long latitude = myGNSS.getLatitude(); 69 | Serial.print(F("Lat: ")); 70 | Serial.print(latitude); 71 | 72 | long longitude = myGNSS.getLongitude(); 73 | Serial.print(F(" Long: ")); 74 | Serial.print(longitude); 75 | Serial.print(F(" (degrees * 10^-7)")); 76 | 77 | long altitude = myGNSS.getAltitude(); 78 | Serial.print(F(" Alt: ")); 79 | Serial.print(altitude); 80 | Serial.print(F(" (mm)")); 81 | 82 | byte SIV = myGNSS.getSIV(); 83 | Serial.print(F(" SIV: ")); 84 | Serial.print(SIV); 85 | 86 | Serial.print(F(" ")); 87 | Serial.print(myGNSS.getYear()); 88 | Serial.print(F("-")); 89 | Serial.print(myGNSS.getMonth()); 90 | Serial.print(F("-")); 91 | Serial.print(myGNSS.getDay()); 92 | Serial.print(F(" ")); 93 | Serial.print(myGNSS.getHour()); 94 | Serial.print(F(":")); 95 | Serial.print(myGNSS.getMinute()); 96 | Serial.print(F(":")); 97 | Serial.println(myGNSS.getSecond()); 98 | 99 | Serial.println(); 100 | 101 | counter++; // Increment counter 102 | if (counter == 20) 103 | { 104 | myGNSS.disableDebugging(); // Disable the debug messages when counter reaches 20 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /examples/Example15_GetDateTime/Example15_GetDateTime.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Getting time and date using u-blox commands 3 | By: davidallenmann 4 | SparkFun Electronics 5 | Date: April 16th, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for the current time and date. We also 10 | turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic 11 | dramatically. 12 | 13 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 14 | 15 | Feel like supporting open source hardware? 16 | Buy a board from SparkFun! 17 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 18 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 19 | SAM-M8Q: https://www.sparkfun.com/products/15106 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 //Needed for I2C to GNSS 28 | 29 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 30 | SFE_UBLOX_GNSS myGNSS; 31 | 32 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 33 | 34 | void setup() 35 | { 36 | Serial.begin(115200); 37 | while (!Serial) 38 | ; //Wait for user to open terminal 39 | Serial.println("SparkFun u-blox Example"); 40 | 41 | Wire.begin(); 42 | 43 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 44 | { 45 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 46 | while (1) 47 | ; 48 | } 49 | 50 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 51 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 52 | } 53 | 54 | void loop() 55 | { 56 | //Query module only every second. Doing it more often will just cause I2C traffic. 57 | //The module only responds when a new position is available 58 | if (millis() - lastTime > 1000) 59 | { 60 | lastTime = millis(); //Update the timer 61 | 62 | long latitude = myGNSS.getLatitude(); 63 | Serial.print(F("Lat: ")); 64 | Serial.print(latitude); 65 | 66 | long longitude = myGNSS.getLongitude(); 67 | Serial.print(F(" Long: ")); 68 | Serial.print(longitude); 69 | Serial.print(F(" (degrees * 10^-7)")); 70 | 71 | long altitude = myGNSS.getAltitude(); 72 | Serial.print(F(" Alt: ")); 73 | Serial.print(altitude); 74 | Serial.print(F(" (mm)")); 75 | 76 | byte SIV = myGNSS.getSIV(); 77 | Serial.print(F(" SIV: ")); 78 | Serial.print(SIV); 79 | 80 | Serial.println(); 81 | Serial.print(myGNSS.getYear()); 82 | Serial.print("-"); 83 | Serial.print(myGNSS.getMonth()); 84 | Serial.print("-"); 85 | Serial.print(myGNSS.getDay()); 86 | Serial.print(" "); 87 | Serial.print(myGNSS.getHour()); 88 | Serial.print(":"); 89 | Serial.print(myGNSS.getMinute()); 90 | Serial.print(":"); 91 | Serial.print(myGNSS.getSecond()); 92 | 93 | Serial.print(" Time is "); 94 | if (myGNSS.getTimeValid() == false) 95 | { 96 | Serial.print("not "); 97 | } 98 | Serial.print("valid Date is "); 99 | if (myGNSS.getDateValid() == false) 100 | { 101 | Serial.print("not "); 102 | } 103 | Serial.print("valid"); 104 | 105 | Serial.println(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /examples/Example16_Nanosecond_MaxOutput/Example16_Nanosecond_MaxOutput.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Getting time and date using u-blox commands 3 | By: davidallenmann 4 | SparkFun Electronics 5 | Date: April 16th, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for the current time and date. We also 10 | turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic 11 | dramatically. 12 | 13 | Note: you will need to set your Serial Monitor to 500000 Baud to see the output 14 | 15 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a BlackBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //Needed for I2C to GNSS 30 | 31 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 35 | 36 | void setup() 37 | { 38 | Serial.begin(500000); //Increase serial speed to maximize 39 | while (!Serial) 40 | ; //Wait for user to open terminal 41 | Serial.println("SparkFun u-blox Example"); 42 | 43 | Wire.begin(); 44 | Wire.setClock(400000); // Increase I2C clock speed to 400kHz 45 | 46 | //myGNSS.enableDebugging(); //Uncomment this line to enable debug messages over Serial 47 | 48 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 49 | { 50 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 51 | while (1) 52 | ; 53 | } 54 | 55 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 56 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 57 | 58 | myGNSS.setNavigationFrequency(5); //Set output to 5 times a second 59 | 60 | byte rate = myGNSS.getNavigationFrequency(); //Get the update rate of this module 61 | Serial.print("Current update rate: "); 62 | Serial.println(rate); 63 | } 64 | 65 | void loop() 66 | { 67 | // Calling getPVT returns true if there actually is a fresh navigation solution available. 68 | if (myGNSS.getPVT()) 69 | { 70 | lastTime = millis(); //Update the timer 71 | 72 | long latitude = myGNSS.getLatitude(); 73 | Serial.print(F("Lat: ")); 74 | Serial.print(latitude); 75 | 76 | long longitude = myGNSS.getLongitude(); 77 | Serial.print(F(" Long: ")); 78 | Serial.print(longitude); 79 | Serial.print(F(" (degrees * 10^-7)")); 80 | 81 | long altitude = myGNSS.getAltitude(); 82 | Serial.print(F(" Alt: ")); 83 | Serial.print(altitude); 84 | Serial.print(F(" (mm)")); 85 | 86 | byte SIV = myGNSS.getSIV(); 87 | Serial.print(F(" SIV: ")); 88 | Serial.print(SIV); 89 | 90 | Serial.print(" "); 91 | Serial.print(myGNSS.getYear()); 92 | Serial.print("-"); 93 | Serial.print(myGNSS.getMonth()); 94 | Serial.print("-"); 95 | Serial.print(myGNSS.getDay()); 96 | Serial.print(" "); 97 | Serial.print(myGNSS.getHour()); 98 | Serial.print(":"); 99 | Serial.print(myGNSS.getMinute()); 100 | Serial.print(":"); 101 | Serial.print(myGNSS.getSecond()); 102 | Serial.print(" nanoseconds: "); 103 | Serial.print(myGNSS.getNanosecond()); // Nanoseconds can be negative 104 | 105 | myGNSS.flushPVT(); 106 | 107 | Serial.println(); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /examples/Example16_PartialSecond_MaxOutput/Example16_PartialSecond_MaxOutput.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Getting time and date using u-blox commands 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: April 16th, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to use the Millisecond and Nanosecond output as well as increase the 10 | I2C speed (100 to 400kHz), and serial output (115200 to 500kbps). 11 | 12 | Note: you will need to set your Serial Monitor to 500000 Baud to see the output 13 | 14 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 15 | 16 | Feel like supporting open source hardware? 17 | Buy a board from SparkFun! 18 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 19 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 20 | SAM-M8Q: https://www.sparkfun.com/products/15106 21 | 22 | Hardware Connections: 23 | Plug a Qwiic cable into the GNSS and a BlackBoard 24 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 25 | Open the serial monitor at 115200 baud to see the output 26 | */ 27 | 28 | #include //Needed for I2C to GNSS 29 | 30 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 31 | SFE_UBLOX_GNSS myGNSS; 32 | 33 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 34 | 35 | void setup() 36 | { 37 | Serial.begin(500000); //Increase serial speed to maximize 38 | while (!Serial) 39 | ; //Wait for user to open terminal 40 | Serial.println("SparkFun u-blox Example"); 41 | 42 | Wire.begin(); 43 | Wire.setClock(400000); // Increase I2C clock speed to 400kHz 44 | 45 | //myGNSS.enableDebugging(); //Uncomment this line to enable debug messages over Serial 46 | 47 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 48 | { 49 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 50 | while (1) 51 | ; 52 | } 53 | 54 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 55 | 56 | // Note: not all u-blox modules can output solutions at 10Hz - or not while tracking all satellite constellations 57 | // If the rate drops back to 1Hz, you're asking too much of your module 58 | myGNSS.setNavigationFrequency(10); //Set output to 10 times a second 59 | 60 | byte rate = myGNSS.getNavigationFrequency(); //Get the update rate of this module 61 | Serial.print("Current update rate:"); 62 | Serial.println(rate); 63 | 64 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 65 | } 66 | 67 | void loop() 68 | { 69 | // Calling getPVT returns true if there actually is a fresh navigation solution available. 70 | if (myGNSS.getPVT()) 71 | { 72 | lastTime = millis(); //Update the timer 73 | 74 | long latitude = myGNSS.getLatitude(); 75 | Serial.print(F("Lat: ")); 76 | Serial.print(latitude); 77 | 78 | long longitude = myGNSS.getLongitude(); 79 | Serial.print(F(" Long: ")); 80 | Serial.print(longitude); 81 | Serial.print(F(" (degrees * 10^-7)")); 82 | 83 | long altitude = myGNSS.getAltitude(); 84 | Serial.print(F(" Alt: ")); 85 | Serial.print(altitude); 86 | Serial.print(F(" (mm)")); 87 | 88 | byte SIV = myGNSS.getSIV(); 89 | Serial.print(F(" SIV: ")); 90 | Serial.print(SIV); 91 | 92 | Serial.print(" "); 93 | Serial.print(myGNSS.getYear()); 94 | Serial.print("-"); 95 | Serial.print(myGNSS.getMonth()); 96 | Serial.print("-"); 97 | Serial.print(myGNSS.getDay()); 98 | Serial.print(" "); 99 | Serial.print(myGNSS.getHour()); 100 | Serial.print(":"); 101 | Serial.print(myGNSS.getMinute()); 102 | Serial.print(":"); 103 | Serial.print(myGNSS.getSecond()); 104 | Serial.print("."); 105 | //Pretty print leading zeros 106 | int mseconds = myGNSS.getMillisecond(); 107 | if (mseconds < 100) 108 | Serial.print("0"); 109 | if (mseconds < 10) 110 | Serial.print("0"); 111 | Serial.print(mseconds); 112 | 113 | Serial.print(" nanoseconds: "); 114 | Serial.print(myGNSS.getNanosecond()); 115 | 116 | Serial.println(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /examples/Example19_DynamicModel/Example19_DynamicModel.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Set Dynamic Model 3 | By: Paul Clark (PaulZC) 4 | Date: April 22nd, 2020 5 | 6 | Based extensively on Example3_GetPosition 7 | By: Nathan Seidle 8 | SparkFun Electronics 9 | Date: January 3rd, 2019 10 | License: MIT. See license file for more information but you can 11 | basically do whatever you want with this code. 12 | 13 | This example shows how to change the u-blox module's dynamic platform model and then 14 | query its lat/long/altitude. We also turn off the NMEA output on the I2C port. 15 | This decreases the amount of I2C traffic dramatically. 16 | 17 | Possible values for the dynamic model are: PORTABLE, STATIONARY, PEDESTRIAN, AUTOMOTIVE, 18 | SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE 19 | 20 | Note: Long/lat are large numbers because they are * 10^7. To convert lat/long 21 | to something google maps understands simply divide the numbers by 10,000,000. We 22 | do this so that we don't have to use floating point numbers. 23 | 24 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 25 | 26 | Feel like supporting open source hardware? 27 | Buy a board from SparkFun! 28 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 29 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 30 | SAM-M8Q: https://www.sparkfun.com/products/15106 31 | 32 | Hardware Connections: 33 | Plug a Qwiic cable into the GNSS and a BlackBoard 34 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 35 | Open the serial monitor at 115200 baud to see the output 36 | */ 37 | 38 | #include //Needed for I2C to GNSS 39 | 40 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 41 | SFE_UBLOX_GNSS myGNSS; 42 | 43 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 44 | 45 | void setup() 46 | { 47 | Serial.begin(115200); 48 | while (!Serial) 49 | ; //Wait for user to open terminal 50 | Serial.println(F("SparkFun u-blox Example")); 51 | 52 | Wire.begin(); 53 | 54 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages 55 | 56 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 57 | { 58 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 59 | while (1) 60 | ; 61 | } 62 | 63 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 64 | 65 | // If we are going to change the dynamic platform model, let's do it here. 66 | // Possible values are: 67 | // PORTABLE, STATIONARY, PEDESTRIAN, AUTOMOTIVE, SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE 68 | 69 | if (myGNSS.setDynamicModel(DYN_MODEL_PORTABLE) == false) // Set the dynamic model to PORTABLE 70 | { 71 | Serial.println(F("*** Warning: setDynamicModel failed ***")); 72 | } 73 | else 74 | { 75 | Serial.println(F("Dynamic platform model changed successfully!")); 76 | } 77 | 78 | // Let's read the new dynamic model to see if it worked 79 | uint8_t newDynamicModel = myGNSS.getDynamicModel(); 80 | if (newDynamicModel == DYN_MODEL_UNKNOWN) 81 | { 82 | Serial.println(F("*** Warning: getDynamicModel failed ***")); 83 | } 84 | else 85 | { 86 | Serial.print(F("The new dynamic model is: ")); 87 | Serial.println(newDynamicModel); 88 | } 89 | 90 | //myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR 91 | } 92 | 93 | void loop() 94 | { 95 | //Query module only every second. Doing it more often will just cause I2C traffic. 96 | //The module only responds when a new position is available 97 | if (millis() - lastTime > 1000) 98 | { 99 | lastTime = millis(); //Update the timer 100 | 101 | long latitude = myGNSS.getLatitude(); 102 | Serial.print(F("Lat: ")); 103 | Serial.print(latitude); 104 | 105 | long longitude = myGNSS.getLongitude(); 106 | Serial.print(F(" Long: ")); 107 | Serial.print(longitude); 108 | Serial.print(F(" (degrees * 10^-7)")); 109 | 110 | long altitude = myGNSS.getAltitude(); 111 | Serial.print(F(" Alt: ")); 112 | Serial.print(altitude); 113 | Serial.print(F(" (mm)")); 114 | 115 | Serial.println(); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /examples/Example1_BasicNMEARead/Example1_BasicNMEARead.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Read NMEA sentences over I2C using u-blox module SAM-M8Q, NEO-M8P, ZED-F9P, etc 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: August 22nd, 2018 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example reads the NMEA setences from the u-blox module over I2c and outputs 10 | them to the serial port 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | SAM-M8Q: https://www.sparkfun.com/products/15106 17 | 18 | Hardware Connections: 19 | Plug a Qwiic cable into the GNSS and a BlackBoard 20 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GNSS 25 | 26 | #include //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | void setup() 30 | { 31 | Serial.begin(115200); 32 | Serial.println("SparkFun u-blox Example"); 33 | 34 | Wire.begin(); 35 | 36 | if (myGNSS.begin() == false) 37 | { 38 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 39 | while (1); 40 | } 41 | 42 | myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA); //Set the I2C port to output both NMEA and UBX messages 43 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 44 | 45 | //This will pipe all NMEA sentences to the serial port so we can see them 46 | myGNSS.setNMEAOutputPort(Serial); 47 | } 48 | 49 | void loop() 50 | { 51 | myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in. 52 | 53 | delay(250); //Don't pound too hard on the I2C bus 54 | } 55 | -------------------------------------------------------------------------------- /examples/Example22_PowerOff/Example22_PowerOff.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Powering off a ublox GNSS module 3 | By: bjorn 4 | unsurv.org 5 | Date: July 20th, 2020 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows you how to turn off the ublox module to lower the power consumption. 10 | There are two functions: one just specifies a duration in milliseconds the other also specifies a pin on the GNSS device to wake it up with. 11 | By driving a voltage from LOW to HIGH or HIGH to LOW on the chosen module pin you wake the device back up. 12 | Note: Doing so on the INT0 pin when using the regular powerOff(durationInMs) function will wake the device anyway. (tested on SAM-M8Q) 13 | Note: While powered off, you should not query the device for data or it might wake up. This can be used to wake the device but is not recommended. 14 | Works best when also putting your microcontroller to sleep. 15 | 16 | Feel like supporting open source hardware? 17 | Buy a board from SparkFun! 18 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 19 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 20 | SAM-M8Q: https://www.sparkfun.com/products/15106 21 | 22 | Hardware Connections: 23 | Plug a Qwiic cable into the GNSS and a BlackBoard. 24 | To force the device to wake up you need to connect to a pin (for example INT0) seperately on the module. 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 30 | SFE_UBLOX_GNSS myGNSS; 31 | 32 | // define a digital pin capable of driving HIGH and LOW 33 | #define WAKEUP_PIN 5 34 | 35 | // Possible GNSS interrupt pins for powerOffWithInterrupt are: 36 | // VAL_RXM_PMREQ_WAKEUPSOURCE_UARTRX = uartrx 37 | // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0 = extint0 (default) 38 | // VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT1 = extint1 39 | // VAL_RXM_PMREQ_WAKEUPSOURCE_SPICS = spics 40 | // These values can be or'd (|) together to enable interrupts on multiple pins 41 | 42 | void wakeUp() { 43 | 44 | Serial.print("-- waking up module via pin " + String(WAKEUP_PIN)); 45 | Serial.println(" on your microcontroller --"); 46 | 47 | digitalWrite(WAKEUP_PIN, LOW); 48 | delay(1000); 49 | digitalWrite(WAKEUP_PIN, HIGH); 50 | delay(1000); 51 | digitalWrite(WAKEUP_PIN, LOW); 52 | } 53 | 54 | 55 | void setup() { 56 | 57 | pinMode(WAKEUP_PIN, OUTPUT); 58 | digitalWrite(WAKEUP_PIN, LOW); 59 | 60 | Serial.begin(115200); 61 | while (!Serial); //Wait for user to open terminal 62 | Serial.println("SparkFun u-blox Example"); 63 | 64 | Wire.begin(); 65 | 66 | //myGNSS.enableDebugging(); // Enable debug messages 67 | 68 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 69 | { 70 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 71 | while (1); 72 | } 73 | 74 | // Powering off for 20s, you should see the power consumption drop. 75 | Serial.println("-- Powering off module for 20s --"); 76 | 77 | myGNSS.powerOff(20000); 78 | //myGNSS.powerOffWithInterrupt(20000, VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0); 79 | 80 | delay(10000); 81 | 82 | // After 10 seconds wake the device via the specified pin on your microcontroller and module. 83 | wakeUp(); 84 | } 85 | 86 | void loop() { 87 | //Do nothing 88 | } 89 | -------------------------------------------------------------------------------- /examples/Example23_TimePulseParameters/Example23_TimePulse_Frequency/Example23_TimePulse_Frequency.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Time Pulse Parameters - Frequency 3 | By: Paul Clark (PaulZC) 4 | Date: January 13th, 2021 5 | 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS) 10 | pin to produce a 1kHz squarewave 11 | 12 | The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481) 13 | has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an 14 | accurate frequency or clock source for your latest project? This is the product for you! 15 | 16 | Feel like supporting open source hardware? 17 | Buy a board from SparkFun! 18 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 19 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 20 | SAM-M8Q: https://www.sparkfun.com/products/15106 21 | 22 | Hardware Connections: 23 | Plug a Qwiic cable into the GNSS and a BlackBoard 24 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 25 | Open the serial monitor at 115200 baud to see the output 26 | */ 27 | 28 | #include //Needed for I2C to GNSS 29 | 30 | #include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS 31 | SFE_UBLOX_GNSS myGNSS; 32 | 33 | void setup() 34 | { 35 | Serial.begin(115200); 36 | while (!Serial) 37 | ; //Wait for user to open terminal 38 | Serial.println(F("SparkFun u-blox Example")); 39 | 40 | Wire.begin(); 41 | 42 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages 43 | 44 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1) 48 | ; 49 | } 50 | 51 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 52 | 53 | // Create storage for the time pulse parameters 54 | UBX_CFG_TP5_data_t timePulseParameters; 55 | 56 | // Get the time pulse parameters 57 | if (myGNSS.getTimePulseParameters(&timePulseParameters) == false) 58 | { 59 | Serial.println(F("getTimePulseParameters failed! Freezing...")); 60 | while (1) ; // Do nothing more 61 | } 62 | 63 | // Print the CFG TP5 version 64 | Serial.print(F("UBX_CFG_TP5 version: ")); 65 | Serial.println(timePulseParameters.version); 66 | 67 | timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin 68 | //timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one 69 | 70 | // We can configure the time pulse pin to produce a defined frequency or period 71 | // Here is how to set the frequency: 72 | 73 | // While the module is _locking_ to GNSS time, make it generate 2kHz 74 | timePulseParameters.freqPeriod = 2000; // Set the frequency/period to 2000Hz 75 | timePulseParameters.pulseLenRatio = 0x55555555; // Set the pulse ratio to 1/3 * 2^32 to produce 33:67 mark:space 76 | 77 | // When the module is _locked_ to GNSS time, make it generate 1kHz 78 | timePulseParameters.freqPeriodLock = 1000; // Set the frequency/period to 1000Hz 79 | timePulseParameters.pulseLenRatioLock = 0x80000000; // Set the pulse ratio to 1/2 * 2^32 to produce 50:50 mark:space 80 | 81 | timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.) 82 | timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time 83 | timePulseParameters.flags.bits.isFreq = 1; // Tell the module that we want to set the frequency (not the period) 84 | timePulseParameters.flags.bits.isLength = 0; // Tell the module that pulseLenRatio is a ratio / duty cycle (* 2^-32) - not a length (in us) 85 | timePulseParameters.flags.bits.polarity = 1; // Tell the module that we want the rising edge at the top of second. (Set to 0 for falling edge.) 86 | 87 | // Now set the time pulse parameters 88 | if (myGNSS.setTimePulseParameters(&timePulseParameters) == false) 89 | { 90 | Serial.println(F("setTimePulseParameters failed!")); 91 | } 92 | else 93 | { 94 | Serial.println(F("Success!")); 95 | } 96 | } 97 | 98 | void loop() 99 | { 100 | // Nothing to do here 101 | } 102 | -------------------------------------------------------------------------------- /examples/Example23_TimePulseParameters/Example23_TimePulse_Period/Example23_TimePulse_Period.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Time Pulse Parameters - Period 3 | By: Paul Clark (PaulZC) 4 | Date: January 13th, 2021 5 | 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to change the time pulse parameters and configure the TIMEPULSE (PPS) 10 | pin to produce a 1 second pulse every 30 seconds. What's really cool is that if you run this 11 | example on two GNSS boards, the pulses are precisely synchronised! 12 | 13 | The SparkFun GPS-RTK-SMA Breakout - ZED-F9P (Qwiic) (https://www.sparkfun.com/products/16481) 14 | has solder pads which will let you connect an SMA connector to the TIMEPULSE signal. Need an 15 | accurate timelapse camera shutter signal? This is the product for you! 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a BlackBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //Needed for I2C to GNSS 30 | 31 | #include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | void setup() 35 | { 36 | Serial.begin(115200); 37 | while (!Serial) 38 | ; //Wait for user to open terminal 39 | Serial.println(F("SparkFun u-blox Example")); 40 | 41 | Wire.begin(); 42 | 43 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages 44 | 45 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 46 | { 47 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 48 | while (1) 49 | ; 50 | } 51 | 52 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 53 | 54 | // Create storage for the time pulse parameters 55 | UBX_CFG_TP5_data_t timePulseParameters; 56 | 57 | // Get the time pulse parameters 58 | if (myGNSS.getTimePulseParameters(&timePulseParameters) == false) 59 | { 60 | Serial.println(F("getTimePulseParameters failed! Freezing...")); 61 | while (1) ; // Do nothing more 62 | } 63 | 64 | // Print the CFG TP5 version 65 | Serial.print(F("UBX_CFG_TP5 version: ")); 66 | Serial.println(timePulseParameters.version); 67 | 68 | timePulseParameters.tpIdx = 0; // Select the TIMEPULSE pin 69 | //timePulseParameters.tpIdx = 1; // Or we could select the TIMEPULSE2 pin instead, if the module has one 70 | 71 | // We can configure the time pulse pin to produce a defined frequency or period 72 | // Here is how to set the period: 73 | 74 | // Let's say that we want our 1 pulse every 30 seconds to be as accurate as possible. So, let's tell the module 75 | // to generate no signal while it is _locking_ to GNSS time. We want the signal to start only when the module is 76 | // _locked_ to GNSS time. 77 | timePulseParameters.freqPeriod = 0; // Set the frequency/period to zero 78 | timePulseParameters.pulseLenRatio = 0; // Set the pulse ratio to zero 79 | 80 | // When the module is _locked_ to GNSS time, make it generate a 1 second pulse every 30 seconds 81 | // (Although the period can be a maximum of 2^32 microseconds (over one hour), the upper limit appears to be around 33 seconds) 82 | timePulseParameters.freqPeriodLock = 30000000; // Set the period to 30,000,000 us 83 | timePulseParameters.pulseLenRatioLock = 1000000; // Set the pulse length to 1,000,000 us 84 | 85 | timePulseParameters.flags.bits.active = 1; // Make sure the active flag is set to enable the time pulse. (Set to 0 to disable.) 86 | timePulseParameters.flags.bits.lockedOtherSet = 1; // Tell the module to use freqPeriod while locking and freqPeriodLock when locked to GNSS time 87 | timePulseParameters.flags.bits.isFreq = 0; // Tell the module that we want to set the period (not the frequency) 88 | timePulseParameters.flags.bits.isLength = 1; // Tell the module that pulseLenRatio is a length (in us) - not a duty cycle 89 | timePulseParameters.flags.bits.polarity = 1; // Tell the module that we want the rising edge at the top of second. (Set to 0 for falling edge.) 90 | 91 | // Now set the time pulse parameters 92 | if (myGNSS.setTimePulseParameters(&timePulseParameters) == false) 93 | { 94 | Serial.println(F("setTimePulseParameters failed!")); 95 | } 96 | else 97 | { 98 | Serial.println(F("Success!")); 99 | } 100 | 101 | // Finally, save the time pulse parameters in battery-backed memory so the pulse will automatically restart at power on 102 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); // Save the configuration 103 | } 104 | 105 | void loop() 106 | { 107 | // Nothing to do here 108 | } 109 | -------------------------------------------------------------------------------- /examples/Example24_GetUnixEpochAndMicros/Example24_GetUnixEpochAndMicros.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Getting Unix Epoch Time and micros using u-blox commands 3 | By: UT2UH 4 | Date: March 31th, 2021 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example shows how to query a u-blox module for the current time and date as Unix Epoch uint32_t type to avoid time.h dependency. 9 | We also turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic dramatically. 10 | 11 | Note: this example works best on modules like the ZED_F9P. Modules like the ZOE_M8Q do not support confirmedTime. 12 | 13 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 14 | 15 | Feel like supporting open source hardware? 16 | Buy a board from SparkFun! 17 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 18 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 19 | SAM-M8Q: https://www.sparkfun.com/products/15106 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 //Needed for I2C to GNSS 28 | 29 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 30 | SFE_UBLOX_GNSS myGNSS; 31 | 32 | 33 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while (!Serial) 39 | ; //Wait for user to open terminal 40 | Serial.println("SparkFun u-blox Example"); 41 | 42 | Wire.begin(); 43 | 44 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1) 48 | ; 49 | } 50 | 51 | // Uncomment the next line if you need to completely reset your module 52 | //myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts 53 | 54 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 55 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 56 | 57 | Serial.println(F("Compare Unix Epoch given with reference one from https://www.epochconverter.com/")); 58 | 59 | } 60 | 61 | void loop() 62 | { 63 | //Query module only every second. Doing it more often will just cause I2C traffic. 64 | //The module only responds when a new position is available 65 | if (millis() - lastTime > 1000) 66 | { 67 | lastTime = millis(); //Update the timer 68 | 69 | // getUnixEpoch marks the PVT data as stale so you will get Unix time and PVT time on alternate seconds 70 | 71 | uint32_t us; //microseconds returned by getUnixEpoch() 72 | uint32_t epoch = myGNSS.getUnixEpoch(); 73 | Serial.print(F("Unix Epoch rounded: ")); 74 | Serial.print(epoch, DEC); 75 | epoch = myGNSS.getUnixEpoch(us); 76 | Serial.print(F(" Exact Unix Epoch: ")); 77 | Serial.print(epoch, DEC); 78 | Serial.print(F(" micros: ")); 79 | Serial.println(us, DEC); 80 | 81 | Serial.print(myGNSS.getYear()); 82 | Serial.print(F("-")); 83 | Serial.print(myGNSS.getMonth()); 84 | Serial.print(F("-")); 85 | Serial.print(myGNSS.getDay()); 86 | Serial.print(F(" ")); 87 | Serial.print(myGNSS.getHour()); 88 | Serial.print(F(":")); 89 | Serial.print(myGNSS.getMinute()); 90 | Serial.print(F(":")); 91 | Serial.print(myGNSS.getSecond()); 92 | 93 | Serial.print(F(" Time is ")); 94 | if (myGNSS.getTimeFullyResolved() == false) 95 | { 96 | Serial.print(F("not fully resolved but ")); 97 | } else { 98 | Serial.print(F("fully resolved and ")); 99 | } 100 | if (myGNSS.getTimeValid() == false) 101 | { 102 | Serial.print(F("not ")); 103 | } 104 | Serial.print(F("valid ")); 105 | if (myGNSS.getConfirmedTime() == false) 106 | { 107 | Serial.print(F("but not ")); 108 | } else { 109 | Serial.print(F("and ")); 110 | } 111 | Serial.print(F("confirmed")); 112 | 113 | byte SIV = myGNSS.getSIV(); 114 | Serial.print(F(" SIV: ")); 115 | Serial.println(SIV); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /examples/Example25_MeasurementAndNavigationRate/Example25_MeasurementAndNavigationRate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Demonstrate get/setMeasurementRate and get/setNavigationRate 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: March 30th, 2021 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to slow down the measurement and navigation rates. 10 | This should run on any GNSS module but has only been tested on the ZED_F9P and ZOE_M8Q. 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | SAM-M8Q: https://www.sparkfun.com/products/15106 17 | 18 | Hardware Connections: 19 | Plug a Qwiic cable into the GNSS and a BlackBoard 20 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GNSS 25 | 26 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | unsigned long lastTime = 0; //Simple local timer. Used to calc the message interval. 30 | 31 | void setup() 32 | { 33 | Serial.begin(115200); 34 | while (!Serial); //Wait for user to open terminal 35 | Serial.println("SparkFun u-blox Example"); 36 | 37 | Wire.begin(); 38 | 39 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 40 | 41 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 42 | { 43 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 44 | while (1); 45 | } 46 | 47 | // Uncomment the next line if you need to completely reset your module 48 | //myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts 49 | 50 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 51 | 52 | // Begin by printing the current measurement rate and navigation rate 53 | 54 | uint16_t rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module 55 | Serial.print("Current measurement interval (ms): "); 56 | Serial.println(rate); 57 | 58 | rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module 59 | Serial.print("Current navigation ratio (cycles): "); 60 | Serial.println(rate); 61 | 62 | // The measurement rate is the elapsed time between GNSS measurements, which defines the rate 63 | // e.g. 100 ms => 10 Hz, 1000 ms => 1 Hz, 10000 ms => 0.1 Hz. 64 | // Let's set the measurement rate (interval) to 5 seconds = 5000 milliseconds 65 | if (myGNSS.setMeasurementRate(5000) == false) 66 | { 67 | Serial.println(F("Could not set the measurement rate. Freezing.")); 68 | while (1); 69 | } 70 | 71 | // setMeasurementRate will set i2cPollingWait to a quarter of the interval 72 | // Let's override that so we can poll the module more frequently and avoid timeouts 73 | myGNSS.setI2CpollingWait(25); // Set i2cPollingWait to 25ms 74 | 75 | // The navigation rate is the ratio between the number of measurements and the number of navigation solutions 76 | // e.g. 5 means five measurements for every navigation solution. Maximum value is 127 77 | // Let's set the navigation rate (ratio) to 12 to produce a solution every minute 78 | if (myGNSS.setNavigationRate(12) == false) 79 | { 80 | Serial.println(F("Could not set the navigation rate. Freezing.")); 81 | while (1); 82 | } 83 | 84 | // Read and print the updated measurement rate and navigation rate 85 | 86 | rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module 87 | Serial.print("New measurement interval (ms): "); 88 | Serial.println(rate); 89 | 90 | rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module 91 | Serial.print("New navigation ratio (cycles): "); 92 | Serial.println(rate); 93 | 94 | lastTime = millis(); 95 | } 96 | 97 | void loop() 98 | { 99 | // i2cPollingWait will prevent us from thrashing the I2C bus 100 | 101 | if (myGNSS.getPVT()) //Check for new Position, Velocity, Time data. getPVT returns true if new data is available. 102 | { 103 | long latitude = myGNSS.getLatitude(); 104 | Serial.print(F("Lat: ")); 105 | Serial.print(latitude); 106 | 107 | long longitude = myGNSS.getLongitude(); 108 | Serial.print(F(" Long: ")); 109 | Serial.print(longitude); 110 | 111 | //Calculate the interval since the last message 112 | Serial.print(F(" Interval: ")); 113 | Serial.print(((float)(millis() - lastTime)) / 1000.0, 2); 114 | Serial.print(F("s")); 115 | 116 | Serial.println(); 117 | 118 | lastTime = millis(); //Update lastTime 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /examples/Example26_End/Example26_End.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Demonstrating how to use "end" 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: April 1st, 2021 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to use the end function. 10 | End will stop all automatic message processing and free (nearly) all used RAM. 11 | The file buffer is deleted (if it exists). 12 | 13 | Feel like supporting open source hardware? 14 | Buy a board from SparkFun! 15 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 16 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 17 | SAM-M8Q: https://www.sparkfun.com/products/15106 18 | 19 | Hardware Connections: 20 | Plug a Qwiic cable into the GNSS and a BlackBoard 21 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 22 | Open the serial monitor at 115200 baud to see the output 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | while (!Serial); //Wait for user to open terminal 34 | Serial.println("SparkFun u-blox Example"); 35 | 36 | Wire.begin(); 37 | 38 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 39 | 40 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 41 | { 42 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 43 | while (1); 44 | } 45 | 46 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 47 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 48 | 49 | myGNSS.end(); // Call end now just because we can - it won't do much as we haven't used any automatic messages 50 | } 51 | 52 | void loop() 53 | { 54 | // Allocate 128 bytes for file storage - this checks that issue #20 has been resolved 55 | // Allocating only 128 bytes will let this code run on the ATmega328P 56 | // If your processor has plenty of RAM, you can increase this to something useful like 16KB 57 | myGNSS.setFileBufferSize(128); 58 | 59 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 60 | { 61 | Serial.println(F("u-blox GNSS not detected. Freezing.")); 62 | while (1); 63 | } 64 | 65 | Serial.print(F("The file buffer size is: ")); 66 | Serial.println(myGNSS.getFileBufferSize()); 67 | 68 | // Request Position, Velocity, Time 69 | // RAM will be allocated for PVT message processing 70 | // getPVT will return true is fresh PVT data was received and processed 71 | if (myGNSS.getPVT()) 72 | { 73 | long latitude = myGNSS.getLatitude(); 74 | Serial.print(F("Lat: ")); 75 | Serial.print(latitude); 76 | 77 | long longitude = myGNSS.getLongitude(); 78 | Serial.print(F(" Long: ")); 79 | Serial.print(longitude); 80 | Serial.print(F(" (degrees * 10^-7)")); 81 | 82 | long altitude = myGNSS.getAltitude(); 83 | Serial.print(F(" Alt: ")); 84 | Serial.print(altitude); 85 | Serial.println(F(" (mm)")); 86 | } 87 | 88 | // Calling end will free the RAM allocated for file storage and PVT processing 89 | // Calling end is optional. You can comment the next line if you want to. 90 | myGNSS.end(); 91 | } 92 | -------------------------------------------------------------------------------- /examples/Example27_MultipleRates/Example27_MultipleRates.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to produce multiple messages at different rates 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: April 1st, 2021 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to configure the U-Blox GNSS to output multiple messages at different rates: 10 | PVT is output every second; 11 | POSECEF is output every five seconds; 12 | VELNED is output every ten seconds. 13 | 14 | Feel like supporting open source hardware? 15 | Buy a board from SparkFun! 16 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 17 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 18 | SAM-M8Q: https://www.sparkfun.com/products/15106 19 | 20 | Hardware Connections: 21 | Plug a Qwiic cable into the GNSS and a BlackBoard 22 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 23 | Open the serial monitor at 115200 baud to see the output 24 | */ 25 | 26 | #include //Needed for I2C to GNSS 27 | 28 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 29 | SFE_UBLOX_GNSS myGNSS; 30 | 31 | void setup() 32 | { 33 | Serial.begin(115200); 34 | while (!Serial); //Wait for user to open terminal 35 | Serial.println("SparkFun u-blox Example"); 36 | 37 | Wire.begin(); 38 | 39 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 40 | { 41 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 42 | while (1); 43 | } 44 | 45 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 46 | myGNSS.setMeasurementRate(1000); //Produce a measurement every 1000ms 47 | myGNSS.setNavigationRate(1); //Produce a navigation solution every measurement 48 | 49 | myGNSS.setAutoPVTrate(1); //Tell the GNSS to send the PVT solution every measurement 50 | myGNSS.setAutoNAVPOSECEFrate(5); //Tell the GNSS to send each POSECEF solution every 5th measurement 51 | myGNSS.setAutoNAVVELNEDrate(10); //Tell the GNSS to send each VELNED solution every 10th measurement 52 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 53 | } 54 | 55 | void loop() 56 | { 57 | // Calling getPVT returns true if there actually is a fresh navigation solution available. 58 | if (myGNSS.getPVT()) 59 | { 60 | long latitude = myGNSS.getLatitude(); 61 | Serial.print(F("Lat: ")); 62 | Serial.print(latitude); 63 | 64 | long longitude = myGNSS.getLongitude(); 65 | Serial.print(F(" Long: ")); 66 | Serial.print(longitude); 67 | Serial.print(F(" (degrees * 10^-7)")); 68 | 69 | long altitude = myGNSS.getAltitude(); 70 | Serial.print(F(" Alt: ")); 71 | Serial.print(altitude); 72 | Serial.println(F(" (mm)")); 73 | } 74 | 75 | // Calling getNAVPOSECEF returns true if there actually is a fresh position solution available. 76 | if (myGNSS.getNAVPOSECEF()) 77 | { 78 | Serial.print(F("ecefX: ")); 79 | Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefX / 100.0, 2); // convert ecefX to m 80 | 81 | Serial.print(F(" ecefY: ")); 82 | Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefY / 100.0, 2); // convert ecefY to m 83 | 84 | Serial.print(F(" ecefZ: ")); 85 | Serial.print((float)myGNSS.packetUBXNAVPOSECEF->data.ecefZ / 100.0, 2); // convert ecefY to m 86 | Serial.println(F(" (m)")); 87 | 88 | myGNSS.flushNAVPOSECEF(); //Mark all the data as read/stale so we get fresh data next time 89 | } 90 | 91 | // Calling getNAVVELNED returns true if there actually is fresh velocity data available. 92 | if (myGNSS.getNAVVELNED()) 93 | { 94 | Serial.print(F("velN: ")); 95 | Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velN / 100.0, 2); // convert velN to m/s 96 | 97 | Serial.print(F(" velE: ")); 98 | Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velE / 100.0, 2); // convert velE to m/s 99 | 100 | Serial.print(F(" velD: ")); 101 | Serial.print((float)myGNSS.packetUBXNAVVELNED->data.velD / 100.0, 2); // convert velD to m/s 102 | Serial.println(F(" (m/s)")); 103 | 104 | myGNSS.flushNAVVELNED(); //Mark all the data as read/stale so we get fresh data next time 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /examples/Example2_NMEAParsing/Example2_NMEAParsing.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Read NMEA sentences over I2C using u-blox module SAM-M8Q, NEO-M8P, etc 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: August 22nd, 2018 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example reads the NMEA characters over I2C and pipes them to MicroNMEA 10 | This example will output your current long/lat and satellites in view 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | SAM-M8Q: https://www.sparkfun.com/products/15106 17 | 18 | For more MicroNMEA info see https://github.com/stevemarple/MicroNMEA 19 | 20 | Hardware Connections: 21 | Plug a Qwiic cable into the GNSS and a BlackBoard 22 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 23 | Open the serial monitor at 115200 baud to see the output 24 | Go outside! Wait ~25 seconds and you should see your lat/long 25 | */ 26 | 27 | #include //Needed for I2C to GNSS 28 | 29 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 30 | SFE_UBLOX_GNSS myGNSS; 31 | 32 | #include //http://librarymanager/All#MicroNMEA 33 | char nmeaBuffer[100]; 34 | MicroNMEA nmea(nmeaBuffer, sizeof(nmeaBuffer)); 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | Serial.println("SparkFun u-blox Example"); 40 | 41 | Wire.begin(); 42 | 43 | if (myGNSS.begin() == false) 44 | { 45 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 46 | while (1); 47 | } 48 | 49 | myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA); //Set the I2C port to output both NMEA and UBX messages 50 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 51 | 52 | myGNSS.setProcessNMEAMask(SFE_UBLOX_FILTER_NMEA_ALL); // Make sure the library is passing all NMEA messages to processNMEA 53 | 54 | myGNSS.setProcessNMEAMask(SFE_UBLOX_FILTER_NMEA_GGA); // Or, we can be kind to MicroNMEA and _only_ pass the GGA messages to it 55 | } 56 | 57 | void loop() 58 | { 59 | myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in. 60 | 61 | if(nmea.isValid() == true) 62 | { 63 | long latitude_mdeg = nmea.getLatitude(); 64 | long longitude_mdeg = nmea.getLongitude(); 65 | 66 | Serial.print("Latitude (deg): "); 67 | Serial.println(latitude_mdeg / 1000000., 6); 68 | Serial.print("Longitude (deg): "); 69 | Serial.println(longitude_mdeg / 1000000., 6); 70 | 71 | nmea.clear(); // Clear the MicroNMEA storage to make sure we are getting fresh data 72 | } 73 | else 74 | { 75 | Serial.println("Waiting for fresh data"); 76 | } 77 | 78 | delay(250); //Don't pound too hard on the I2C bus 79 | } 80 | 81 | //This function gets called from the SparkFun u-blox Arduino Library 82 | //As each NMEA character comes in you can specify what to do with it 83 | //Useful for passing to other libraries like tinyGPS, MicroNMEA, or even 84 | //a buffer, radio, etc. 85 | void SFE_UBLOX_GNSS::processNMEA(char incoming) 86 | { 87 | //Take the incoming char from the u-blox I2C port and pass it on to the MicroNMEA lib 88 | //for sentence cracking 89 | nmea.process(incoming); 90 | } 91 | -------------------------------------------------------------------------------- /examples/Example3_GetPosition/Example3_GetPosition.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading lat and long via UBX binary commands - no more NMEA parsing! 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its lat/long/altitude. We also 10 | turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic 11 | dramatically. 12 | 13 | Note: Long/lat are large numbers because they are * 10^7. To convert lat/long 14 | to something google maps understands simply divide the numbers by 10,000,000. We 15 | do this so that we don't have to use floating point numbers. 16 | 17 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 18 | 19 | Feel like supporting open source hardware? 20 | Buy a board from SparkFun! 21 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 22 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 23 | SAM-M8Q: https://www.sparkfun.com/products/15106 24 | 25 | Hardware Connections: 26 | Plug a Qwiic cable into the GNSS and a BlackBoard 27 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 28 | Open the serial monitor at 115200 baud to see the output 29 | */ 30 | 31 | #include //Needed for I2C to GNSS 32 | 33 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 34 | SFE_UBLOX_GNSS myGNSS; 35 | 36 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 37 | 38 | void setup() 39 | { 40 | Serial.begin(115200); 41 | while (!Serial); //Wait for user to open terminal 42 | Serial.println("SparkFun u-blox Example"); 43 | 44 | Wire.begin(); 45 | 46 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 47 | 48 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 49 | { 50 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 51 | while (1); 52 | } 53 | 54 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 55 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 56 | } 57 | 58 | void loop() 59 | { 60 | //Query module only every second. Doing it more often will just cause I2C traffic. 61 | //The module only responds when a new position is available 62 | if (millis() - lastTime > 1000) 63 | { 64 | lastTime = millis(); //Update the timer 65 | 66 | long latitude = myGNSS.getLatitude(); 67 | Serial.print(F("Lat: ")); 68 | Serial.print(latitude); 69 | 70 | long longitude = myGNSS.getLongitude(); 71 | Serial.print(F(" Long: ")); 72 | Serial.print(longitude); 73 | Serial.print(F(" (degrees * 10^-7)")); 74 | 75 | long altitude = myGNSS.getAltitude(); 76 | Serial.print(F(" Alt: ")); 77 | Serial.print(altitude); 78 | Serial.print(F(" (mm)")); 79 | 80 | byte SIV = myGNSS.getSIV(); 81 | Serial.print(F(" SIV: ")); 82 | Serial.print(SIV); 83 | 84 | Serial.println(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /examples/Example4_FixType/Example4_FixType.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Get fix type and RTK fix type if available 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for fix type and RTK fix type. 10 | The fix type is as follows: 11 | 0 = no fix 12 | 1 = dead reckoning (requires external sensors) 13 | 2 = 2D (not quite enough satellites in view) 14 | 3 = 3D (the standard fix) 15 | 4 = GNSS + dead reckoning (requires external sensors) 16 | 5 = Time fix only 17 | 18 | Additionally, if we are doing RTK, we can figure out if we have a floating 19 | RTK solution or if we have been able to resolve a fixec solution (better precision). 20 | 21 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 22 | 23 | Feel like supporting open source hardware? 24 | Buy a board from SparkFun! 25 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 26 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 27 | SAM-M8Q: https://www.sparkfun.com/products/15106 28 | 29 | Hardware Connections: 30 | Plug a Qwiic cable into the GNSS and a BlackBoard 31 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 32 | Open the serial monitor at 115200 baud to see the output 33 | */ 34 | 35 | #include //Needed for I2C to GNSS 36 | 37 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 38 | SFE_UBLOX_GNSS myGNSS; 39 | 40 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 41 | 42 | void setup() 43 | { 44 | Serial.begin(115200); 45 | while (!Serial); //Wait for user to open terminal 46 | Serial.println("SparkFun u-blox Example"); 47 | 48 | Wire.begin(); 49 | //Wire.setClock(400000); //Optional. Increase I2C clock speed to 400kHz. 50 | 51 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 52 | { 53 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 54 | while (1); 55 | } 56 | } 57 | 58 | void loop() 59 | { 60 | //Query module only every second. Doing it more often will just cause I2C traffic. 61 | if (millis() - lastTime > 1000) 62 | { 63 | lastTime = millis(); //Update the timer 64 | 65 | long latitude = myGNSS.getLatitude(); 66 | Serial.print(F("Lat: ")); 67 | Serial.print(latitude); 68 | 69 | long longitude = myGNSS.getLongitude(); 70 | Serial.print(F(" Long: ")); 71 | Serial.print(longitude); 72 | 73 | long altitude = myGNSS.getAltitude(); 74 | Serial.print(F(" Alt: ")); 75 | Serial.print(altitude); 76 | 77 | byte fixType = myGNSS.getFixType(); 78 | Serial.print(F(" Fix: ")); 79 | if(fixType == 0) Serial.print(F("No fix")); 80 | else if(fixType == 1) Serial.print(F("Dead reckoning")); 81 | else if(fixType == 2) Serial.print(F("2D")); 82 | else if(fixType == 3) Serial.print(F("3D")); 83 | else if(fixType == 4) Serial.print(F("GNSS + Dead reckoning")); 84 | else if(fixType == 5) Serial.print(F("Time only")); 85 | 86 | byte RTK = myGNSS.getCarrierSolutionType(); 87 | Serial.print(" RTK: "); 88 | Serial.print(RTK); 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)")); 92 | 93 | Serial.println(); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /examples/Example5_SpeedHeadingPrecision/Example5_SpeedHeadingPrecision.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Get Speed/Heading and dilution of precision via UBX binary commands - no more NMEA parsing! 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its lat/long/altitude. 10 | 11 | Note: Long/lat are large numbers because they are * 10^7. To convert lat/long 12 | to something google maps understands simply divide the numbers by 1,000,000. We 13 | do this so that we don't have to use floating point numbers. 14 | 15 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a BlackBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //Needed for I2C to GNSS 30 | 31 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | while (!Serial); //Wait for user to open terminal 40 | Serial.println("SparkFun u-blox Example"); 41 | 42 | Wire.begin(); 43 | 44 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1); 48 | } 49 | } 50 | 51 | void loop() 52 | { 53 | //Query module only every second. Doing it more often will just cause I2C traffic. 54 | //The module only responds when a new position is available 55 | if (millis() - lastTime > 1000) 56 | { 57 | lastTime = millis(); //Update the timer 58 | 59 | long latitude = myGNSS.getLatitude(); 60 | Serial.print(F("Lat: ")); 61 | Serial.print(latitude); 62 | 63 | long longitude = myGNSS.getLongitude(); 64 | Serial.print(F(" Long: ")); 65 | Serial.print(longitude); 66 | 67 | long speed = myGNSS.getGroundSpeed(); 68 | Serial.print(F(" Speed: ")); 69 | Serial.print(speed); 70 | Serial.print(F(" (mm/s)")); 71 | 72 | long heading = myGNSS.getHeading(); 73 | Serial.print(F(" Heading: ")); 74 | Serial.print(heading); 75 | Serial.print(F(" (degrees * 10^-5)")); 76 | 77 | int pDOP = myGNSS.getPDOP(); 78 | Serial.print(F(" pDOP: ")); 79 | Serial.print(pDOP / 100.0, 2); // Convert pDOP scaling from 0.01 to 1 80 | 81 | Serial.println(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /examples/Example6_EnableNMEASentences/Example6_EnableNMEASentences.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Turn on/off various NMEA sentences. 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to turn on/off the NMEA sentences being output 10 | over UART1. We use the I2C interface on the u-blox module for configuration 11 | but you won't see any output from this sketch. You'll need to hook up 12 | a Serial Basic or other USB to Serial device to UART1 on your u-blox module 13 | to see the output. 14 | 15 | This example turns off all sentences except for the GPGGA and GPVTG sentences. 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a RedBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | Hookup a Serial Basic (https://www.sparkfun.com/products/15096) to UART1 on the u-blox module. Open a terminal at 57600bps 28 | and see GPGGA and GPVTG sentences. 29 | */ 30 | #include //Needed for I2C to GNSS 31 | 32 | #include //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | unsigned long lastGNSSsend = 0; 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); // Serial debug output over USB visible from Arduino IDE 40 | Serial.println("Example showing how to enable/disable certain NMEA sentences"); 41 | 42 | Wire.begin(); 43 | 44 | if (myGNSS.begin() == false) 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1) 48 | ; 49 | } 50 | 51 | //Disable or enable various NMEA sentences over the UART1 interface 52 | myGNSS.disableNMEAMessage(UBX_NMEA_GLL, COM_PORT_UART1); //Several of these are on by default on ublox board so let's disable them 53 | myGNSS.disableNMEAMessage(UBX_NMEA_GSA, COM_PORT_UART1); 54 | myGNSS.disableNMEAMessage(UBX_NMEA_GSV, COM_PORT_UART1); 55 | myGNSS.disableNMEAMessage(UBX_NMEA_RMC, COM_PORT_UART1); 56 | myGNSS.enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_UART1); //Only leaving GGA & VTG enabled at current navigation rate 57 | myGNSS.enableNMEAMessage(UBX_NMEA_VTG, COM_PORT_UART1); 58 | 59 | //Here's the advanced configure method 60 | //Some of the other examples in this library enable the PVT message so let's disable it 61 | myGNSS.configureMessage(UBX_CLASS_NAV, UBX_NAV_PVT, COM_PORT_UART1, 0); //Message Class, ID, and port we want to configure, sendRate of 0 (disable). 62 | 63 | myGNSS.setUART1Output(COM_TYPE_NMEA); //Turn off UBX and RTCM sentences on the UART1 interface 64 | 65 | myGNSS.setSerialRate(57600); //Set UART1 to 57600bps. 66 | 67 | //myGNSS.saveConfiguration(); //Optional: Save these settings to NVM 68 | 69 | Serial.println(F("Messages configured. NMEA now being output over the UART1 port on the u-blox module at 57600bps.")); 70 | } 71 | 72 | void loop() 73 | { 74 | if (millis() - lastGNSSsend > 200) 75 | { 76 | myGNSS.checkUblox(); //See if new data is available, but we don't want to get NMEA here. Go check UART1. 77 | lastGNSSsend = millis(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /examples/Example7_OutputRate/Example7_OutputRate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Set update rate to 10Hz 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to increase the output of the module from 1Hz to 4Hz. 10 | The max output rate various from model to model. RTFM! But you cannot do harm 11 | to the module. 12 | 13 | We also disable NMEA output on the I2C bus and use only UBX. This dramatically 14 | decreases the amount of data that needs to be transmitted. 15 | 16 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 21 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 22 | SAM-M8Q: https://www.sparkfun.com/products/15106 23 | 24 | Hardware Connections: 25 | Plug a Qwiic cable into the GNSS and a BlackBoard 26 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 27 | Open the serial monitor at 115200 baud to see the output 28 | */ 29 | 30 | #include //Needed for I2C to GNSS 31 | 32 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | unsigned long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 36 | unsigned long startTime = 0; //Used to calc the actual update rate. 37 | unsigned long updateCount = 0; //Used to calc the actual update rate. 38 | 39 | void setup() 40 | { 41 | Serial.begin(115200); 42 | while (!Serial); //Wait for user to open terminal 43 | Serial.println("SparkFun u-blox Example"); 44 | 45 | Wire.begin(); 46 | 47 | // Increase I2C clock speed to 400kHz to cope with the high navigation rate 48 | // (We normally recommend running the bus at 100kHz) 49 | Wire.setClock(400000); 50 | 51 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 52 | { 53 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 54 | while (1); 55 | } 56 | 57 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 58 | myGNSS.setNavigationFrequency(5); //Set output to 5 times a second 59 | 60 | uint8_t rate = myGNSS.getNavigationFrequency(); //Get the update rate of this module 61 | Serial.print("Current update rate: "); 62 | Serial.println(rate); 63 | 64 | startTime = millis(); 65 | } 66 | 67 | void loop() 68 | { 69 | //Query module every 25 ms. Doing it more often will just cause I2C traffic. 70 | //The module only responds when a new position is available. This is defined 71 | //by the update freq. 72 | if (millis() - lastTime > 25) 73 | { 74 | lastTime = millis(); //Update the timer 75 | 76 | long latitude = myGNSS.getLatitude(); 77 | Serial.print(F("Lat: ")); 78 | Serial.print(latitude); 79 | 80 | long longitude = myGNSS.getLongitude(); 81 | Serial.print(F(" Long: ")); 82 | Serial.print(longitude); 83 | 84 | updateCount++; 85 | 86 | //Calculate the actual update rate based on the sketch start time and the 87 | //number of updates we've received. 88 | Serial.print(F(" Rate: ")); 89 | Serial.print( updateCount / ((millis() - startTime) / 1000.0), 2); 90 | Serial.print(F("Hz")); 91 | 92 | Serial.println(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /examples/Example8_GetProtocolVersion/Example8_GetProtocolVersion.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading the protocol version of a u-blox module 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its protocol version. 10 | 11 | Various modules have various protocol version. We've seen v18 up to v27. Depending 12 | on the protocol version there are different commands available. This is a handy 13 | way to predict which commands will or won't work. 14 | 15 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 16 | 17 | Feel like supporting open source hardware? 18 | Buy a board from SparkFun! 19 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 20 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 21 | SAM-M8Q: https://www.sparkfun.com/products/15106 22 | 23 | Hardware Connections: 24 | Plug a Qwiic cable into the GNSS and a BlackBoard 25 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 26 | Open the serial monitor at 115200 baud to see the output 27 | */ 28 | 29 | #include //Needed for I2C to GNSS 30 | 31 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 32 | SFE_UBLOX_GNSS myGNSS; 33 | 34 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | while (!Serial); //Wait for user to open terminal 40 | Serial.println("SparkFun u-blox Example"); 41 | 42 | Wire.begin(); 43 | 44 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 47 | while (1); 48 | } 49 | 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); 56 | } 57 | 58 | void loop() 59 | { 60 | //Do nothing 61 | } 62 | -------------------------------------------------------------------------------- /examples/Example8_GetProtocolVersion_Serial/Example8_GetProtocolVersion_Serial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Reading the protocol version of a u-blox module 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its protocol version. 10 | 11 | Note: this may fail on boards like the UNO (ATmega328P) with modules like the ZED-F9P 12 | because getProtocolVersion returns a lot of data - more than the UNO's serial buffer can hold 13 | 14 | Various modules have various protocol version. We've seen v18 up to v27. Depending 15 | on the protocol version there are different commands available. This is a handy 16 | way to predict which commands will or won't work. 17 | 18 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 19 | 20 | Feel like supporting open source hardware? 21 | Buy a board from SparkFun! 22 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 23 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 24 | SAM-M8Q: https://www.sparkfun.com/products/15106 25 | 26 | Hardware Connections: 27 | Plug a Qwiic cable into the GNSS and a BlackBoard 28 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 29 | Open the serial monitor at 115200 baud to see the output 30 | */ 31 | 32 | #include 33 | 34 | #define mySerial Serial1 // Uncomment this line to connect via Serial1 35 | // - or - 36 | //SoftwareSerial mySerial(10, 11); // Uncomment this line to connect via SoftwareSerial(RX, TX). Connect pin 10 to GNSS TX pin. 37 | 38 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 39 | SFE_UBLOX_GNSS myGNSS; 40 | 41 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 42 | 43 | void setup() 44 | { 45 | Serial.begin(115200); 46 | while (!Serial); //Wait for user to open terminal 47 | Serial.println("SparkFun u-blox Example"); 48 | 49 | Serial.println("Trying 38400 baud"); 50 | mySerial.begin(38400); 51 | if (myGNSS.begin(mySerial)) 52 | { 53 | Serial.println("GNSS connected at 38400 baud"); 54 | } 55 | else 56 | { 57 | Serial.println("Trying 9600 baud"); 58 | mySerial.begin(9600); 59 | if (myGNSS.begin(mySerial)) 60 | { 61 | Serial.println("GNSS connected at 9600 baud"); 62 | } 63 | else 64 | { 65 | Serial.println("Could not connect to GNSS. Freezing..."); 66 | while(1); // Do nothing more 67 | } 68 | } 69 | 70 | Serial.print(F("Version: ")); 71 | byte versionHigh = myGNSS.getProtocolVersionHigh(); 72 | Serial.print(versionHigh); 73 | Serial.print("."); 74 | byte versionLow = myGNSS.getProtocolVersionLow(); 75 | Serial.print(versionLow); 76 | } 77 | 78 | void loop() 79 | { 80 | //Do nothing 81 | } 82 | -------------------------------------------------------------------------------- /examples/Example9_ChangeI2CAddress/Example9_ChangeI2CAddress.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Change the I2C address of a u-blox module using I2C 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to change the I2C address of a u-blox module 10 | 11 | Feel like supporting open source hardware? 12 | Buy a board from SparkFun! 13 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 14 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 15 | SAM-M8Q: https://www.sparkfun.com/products/15106 16 | 17 | Hardware Connections: 18 | Plug a Qwiic cable into the GNSS and a BlackBoard 19 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 20 | Open the serial monitor at 115200 baud to see the output 21 | */ 22 | 23 | #include //Needed for I2C to GNSS 24 | 25 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 26 | SFE_UBLOX_GNSS myGNSS; 27 | 28 | long lastTime = 0; //Tracks the passing of 2000ms (2 seconds) 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | while (!Serial); //Wait for user to open terminal 34 | Serial.println("SparkFun u-blox Example"); 35 | 36 | Wire.begin(); 37 | 38 | byte oldAddress = 0x42; //The default address for u-blox modules is 0x42 39 | byte newAddress = 0x3F; //Address you want to change to. Valid is 0x08 to 0x77. 40 | 41 | while (Serial.available()) Serial.read(); //Trash any incoming chars 42 | Serial.print("Press a key to change address to 0x"); 43 | Serial.println(newAddress, HEX); 44 | while (Serial.available() == false) ; //Wait for user to send character 45 | 46 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 47 | 48 | if (myGNSS.begin(Wire, oldAddress) == true) //Connect to the u-blox module using Wire port and the old address 49 | { 50 | Serial.print("GNSS found at address 0x"); 51 | Serial.println(oldAddress, HEX); 52 | 53 | myGNSS.setI2CAddress(newAddress); //Change I2C address of this device 54 | //Device's I2C address is stored to memory and loaded on each power-on 55 | 56 | delay(2000); // Allow time for the change to take 57 | 58 | if (myGNSS.begin(Wire, newAddress) == true) 59 | { 60 | myGNSS.saveConfiguration(); //Save the current settings to flash and BBR 61 | 62 | Serial.print("Address successfully changed to 0x"); 63 | Serial.println(newAddress, HEX); 64 | Serial.print("Now load another example sketch using .begin(Wire, 0x"); 65 | Serial.print(newAddress, HEX); 66 | Serial.println(") to use this GPS module"); 67 | Serial.println("Freezing..."); 68 | while (1); 69 | } 70 | } 71 | 72 | //Something went wrong, begin looking for the I2C device 73 | Serial.println("Address change probably failed. Beginning an I2C scan."); 74 | 75 | Wire.begin(); 76 | } 77 | 78 | void loop() { 79 | 80 | byte address; 81 | int nDevices; 82 | 83 | Serial.println("Scanning..."); 84 | 85 | nDevices = 0; 86 | for (address = 1; address < 127; address++ ) 87 | { 88 | Wire.beginTransmission(address); 89 | byte error = Wire.endTransmission(); 90 | 91 | if (error == 0) 92 | { 93 | Serial.print("I2C device found at address 0x"); 94 | if (address < 16) 95 | Serial.print("0"); 96 | Serial.print(address, HEX); 97 | Serial.println(" !"); 98 | 99 | nDevices++; 100 | } 101 | // else if (error == 4) 102 | // { 103 | // Serial.print("Unknown error at address 0x"); 104 | // if (address < 16) 105 | // Serial.print("0"); 106 | // Serial.println(address, HEX); 107 | // } 108 | } 109 | 110 | if (nDevices == 0) 111 | Serial.println("No I2C devices found\n"); 112 | else 113 | Serial.println("done\n"); 114 | 115 | delay(5000); // wait 5 seconds for next scan 116 | } 117 | -------------------------------------------------------------------------------- /examples/NEO-M8P-2/Example1_EnableRTCM/Example1_EnableRTCM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send UBX binary commands to enable RTCM sentences on u-blox NEO-M8P module 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: September 7th, 2018 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example sends the command to enable the four RTCM messages needed for RTK. This 10 | is the first part of a larger tutorial and example to setup an RTK base station. 11 | These commands are only accepted by the NEO-M8P module. 12 | 13 | Feel like supporting open source hardware? 14 | Buy a board from SparkFun! 15 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 16 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 17 | SAM-M8Q: https://www.sparkfun.com/products/15106 18 | 19 | Hardware Connections: 20 | Plug a Qwiic cable into the GNSS and a BlackBoard 21 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 22 | Open the serial monitor at 115200 baud to see the output 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | while(!Serial); //Wait for user to open terminal 34 | Serial.println(F("u-blox RTCM Enable Example")); 35 | 36 | Wire.begin(); 37 | Wire.setClock(400000); //Increase I2C clock speed to 400kHz 38 | 39 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 40 | { 41 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 42 | while (1); 43 | } 44 | 45 | while(Serial.available()) Serial.read(); //Clear any latent chars in serial buffer 46 | Serial.println(F("Press any key to send commands to enable RTCM 3.x")); 47 | while(Serial.available() == 0) ; //Wait for user to press a key 48 | 49 | myGNSS.setI2COutput(COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); // Ensure RTCM3 is enabled 50 | myGNSS.saveConfiguration(); //Save the current settings to flash and BBR 51 | 52 | bool response = true; 53 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second 54 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_I2C, 1); 55 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_I2C, 1); 56 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds 57 | 58 | if (response == true) 59 | { 60 | Serial.println(F("RTCM messages enabled")); 61 | } 62 | else 63 | { 64 | Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?")); 65 | while(1); //Freeze 66 | } 67 | 68 | //RTCM is now enabled but we haven't done a 'survey-in' 69 | //See example 4 for the full Base RTK setup 70 | } 71 | 72 | void loop() 73 | { 74 | myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in. 75 | 76 | delay(250); //Don't pound too hard on the I2C bus 77 | } 78 | -------------------------------------------------------------------------------- /examples/NEO-M8P-2/Example4_MovingBase_Base/Example4_MovingBase_Base.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configure the NEO-M8P-2 as a "moving base" 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: March 20th, 2023 6 | License: MIT. See license file for more information. 7 | 8 | This example configures the NEO-M8P-2 as a moving base. 9 | It will output RTCM3 1077, 1087, 1230 and 4072.0 messages on UART1. 10 | Connect UART1 TX to UART1 RX on a NEO-M8P rover. Also connect GND to GND. 11 | The next example shows how to display the relative position of the rover. 12 | 13 | Feel like supporting open source hardware? 14 | Buy a board from SparkFun! 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | 17 | Hardware Connections: 18 | Plug a Qwiic cable into the GNSS and a BlackBoard 19 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 20 | Connect UART1 TX to UART1 RX on a NEO-M8P rover. Also connect GND to GND. 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GNSS 25 | 26 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | void setup() 30 | { 31 | delay(1000); 32 | 33 | Serial.begin(115200); 34 | while(!Serial); //Wait for user to open terminal 35 | Serial.println(F("u-blox NEO-M8P Moving Base Example")); 36 | 37 | Wire.begin(); 38 | 39 | while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 40 | { 41 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring.")); 42 | } 43 | 44 | // Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate 45 | //myGNSS.factoryDefault(); delay(5000); 46 | 47 | myGNSS.setUART1Output(COM_TYPE_RTCM3); // Configure UART1 to output RTCM3 only. Disable NMEA. 48 | myGNSS.saveConfiguration(); //Save the current settings to flash and BBR 49 | 50 | bool response = true; 51 | 52 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1077, COM_PORT_UART1, 1); //Enable message 1077 on UART1 53 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1087, COM_PORT_UART1, 1); //Enable message 1087 on UART1 54 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_UART1, 1); //Enable message 1230 on UART1 55 | response &= myGNSS.enableRTCMmessage(UBX_RTCM_4072_0, COM_PORT_UART1, 1); //Enable message 4072.0 on UART1 56 | 57 | response &= myGNSS.disableSurveyMode(); //Essential - we need to set TMODE3 to Disabled to allow 4072.0 to be output 58 | 59 | if (response == true) 60 | { 61 | Serial.println(F("RTCM messages enabled")); 62 | } 63 | else 64 | { 65 | Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?")); 66 | } 67 | } 68 | 69 | void loop() 70 | { 71 | myGNSS.checkUblox(); //See if new data is available. Process bytes as they come in. 72 | 73 | delay(250); //Don't pound too hard on the I2C bus 74 | } 75 | -------------------------------------------------------------------------------- /examples/NEO-M8P-2/Example5_MovingBase_Rover/Example5_MovingBase_Rover.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Display the relative position of a NEO-M8P-2 rover 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: March 20th, 2023 6 | License: MIT. See license file for more information. 7 | 8 | This example shows how to query the module for RELPOS information in the NED frame. 9 | It assumes you already have RTCM correction data being fed to the receiver on UART1. 10 | Connect UART1 TX on the base to UART1 RX on the rover. Also connect GND to GND. 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 15 | 16 | Hardware Connections: 17 | Plug a Qwiic cable into the GNSS and a RedBoard Qwiic or BlackBoard 18 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 19 | Connect UART1 TX on the base to UART1 RX on the rover. Also connect GND to GND. 20 | Open the serial monitor at 115200 baud to see the output 21 | */ 22 | 23 | #include //Needed for I2C to GNSS 24 | 25 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 26 | SFE_UBLOX_GNSS myGNSS; 27 | 28 | void setup() 29 | { 30 | delay(1000); 31 | 32 | Serial.begin(115200); 33 | while (!Serial); //Wait for user to open terminal 34 | Serial.println("u-blox NEO-M8P Rover Example"); 35 | 36 | Wire.begin(); 37 | 38 | while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 39 | { 40 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring.")); 41 | } 42 | 43 | // Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate 44 | //myGNSS.factoryDefault(); delay(5000); 45 | 46 | // By default, UART1 Protocol In is set to NMEA + UBX + RTCM3. No changes are necessary. But we can manually configure the port if required. 47 | Serial.print(myGNSS.setPortInput(COM_PORT_UART1, COM_TYPE_UBX | COM_TYPE_RTCM3)); //Enable UBX and RTCM3 input on UART1 48 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR 49 | } 50 | 51 | void loop() 52 | { 53 | // The data from getRELPOSNED (UBX-NAV-RELPOSNED) is returned in UBX_NAV_RELPOSNED_t packetUBXNAVRELPOSNED 54 | // Please see u-blox_structs.h for the full definition of UBX_NAV_RELPOSNED_t 55 | // You can either read the data from packetUBXNAVRELPOSNED directly 56 | // or can use the helper functions: getRelPosN/E/D; getRelPosAccN/E/D 57 | // Note that NEO-M8P RELPOSNED is different to ZED-F9P. It does not contain the relative length and heading. 58 | if (myGNSS.getRELPOSNED() == true) 59 | { 60 | Serial.print("relPosN: "); 61 | Serial.println(myGNSS.getRelPosN(), 4); // Use the helper functions to get the rel. pos. as m 62 | Serial.print("relPosE: "); 63 | Serial.println(myGNSS.getRelPosE(), 4); 64 | Serial.print("relPosD: "); 65 | Serial.println(myGNSS.getRelPosD(), 4); 66 | 67 | Serial.print("relPosHPN: "); 68 | Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPN / 10, 1); //High-precision component. Convert to mm 69 | Serial.print("relPosHPE: "); 70 | Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPE / 10, 1); 71 | Serial.print("relPosHPD: "); 72 | Serial.println((float)myGNSS.packetUBXNAVRELPOSNED->data.relPosHPD / 10, 1); 73 | 74 | Serial.print("accN: "); 75 | Serial.println(myGNSS.getRelPosAccN(), 4); // Use the helper functions to get the rel. pos. accuracy as m 76 | Serial.print("accE: "); 77 | Serial.println(myGNSS.getRelPosAccE(), 4); 78 | Serial.print("accD: "); 79 | Serial.println(myGNSS.getRelPosAccD(), 4); 80 | 81 | Serial.print("gnssFixOk: "); 82 | if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.gnssFixOK == true) 83 | Serial.println("x"); 84 | else 85 | Serial.println(""); 86 | 87 | Serial.print("diffSolution: "); 88 | if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.diffSoln == true) 89 | Serial.println("x"); 90 | else 91 | Serial.println(""); 92 | 93 | Serial.print("relPosValid: "); 94 | if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.relPosValid == true) 95 | Serial.println("x"); 96 | else 97 | Serial.println(""); 98 | 99 | Serial.print("carrier Solution Type: "); 100 | if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 0) 101 | Serial.println("None"); 102 | else if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 1) 103 | Serial.println("Float"); 104 | else if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.carrSoln == 2) 105 | Serial.println("Fixed"); 106 | 107 | Serial.print("isMoving: "); 108 | if (myGNSS.packetUBXNAVRELPOSNED->data.flags.bits.isMoving == true) 109 | Serial.println("x"); 110 | else 111 | Serial.println(""); 112 | } 113 | else 114 | Serial.println("RELPOS request failed"); 115 | 116 | Serial.println(""); 117 | } 118 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example12_setStaticPosition/Example12_setStaticPosition.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Set the static position of the receiver. 3 | By: SparkFun Electronics / Nathan Seidle 4 | Date: September 26th, 2020 5 | License: MIT. See license file for more information but you can 6 | basically do whatever you want with this code. 7 | 8 | This example shows how to set the static position of a receiver 9 | using an Earth-Centered, Earth-Fixed (ECEF) location. This is the 10 | output from a long (24 hour+) survey-in. Setting the static position 11 | immediately causes the receiver to begin outputting RTCM data (if 12 | enabled), perfect for setting up your own RTCM NTRIP caster or CORS. 13 | 14 | Feel like supporting open source hardware? 15 | Buy a board from SparkFun! 16 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 17 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 18 | 19 | Hardware Connections: 20 | Plug a Qwiic cable into the GNSS and a BlackBoard 21 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 22 | Open the serial monitor at 115200 baud to see the output 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); // You may need to increase this for high navigation rates! 33 | while (!Serial) 34 | ; //Wait for user to open terminal 35 | Serial.println(F("SparkFun u-blox Example")); 36 | 37 | Wire.begin(); 38 | 39 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages 40 | 41 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 42 | { 43 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 44 | while (1) 45 | ; 46 | } 47 | 48 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 49 | 50 | bool success = true; 51 | 52 | //-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so... 53 | 54 | //Units are cm so 1234 = 12.34m 55 | //success &= myGNSS.setStaticPosition(-128020831, -471680385, 408666581); 56 | 57 | //Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78) 58 | success &= myGNSS.setStaticPosition(-128020830, -80, -471680384, -70, 408666581, 10); //With high precision 0.1mm parts 59 | 60 | //We can also set via lat/long 61 | //40.09029751,-105.18507900,1560.238 62 | //success &= myGNSS.setStaticPosition(400902975, -1051850790, 156024, true); //True at end enables lat/long input 63 | //success &= myGNSS.setStaticPosition(400902975, 10, -1051850790, 0, 156023, 80, true); 64 | 65 | if (!success) Serial.println(F("At least one call to setStaticPosition failed!")); 66 | 67 | //Now let's use getVals to read back the data 68 | //long ecefX = myGNSS.getVal32(0x40030003); 69 | //Serial.print("ecefX: "); 70 | //Serial.println(ecefX); 71 | 72 | Serial.println(F("Done!")); 73 | } 74 | 75 | void loop() 76 | { 77 | } 78 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example13_autoHPPOSLLH/Example13_autoHPPOSLLH.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring the GNSS to automatically send HPPOSLLH position reports over I2C 3 | By: Paul Clark 4 | Date: October 27th 2020 5 | 6 | Based on an earlier example: 7 | By: Nathan Seidle and Thorsten von Eicken 8 | SparkFun Electronics 9 | Date: January 3rd, 2019 10 | License: MIT. See license file for more information but you can 11 | basically do whatever you want with this code. 12 | 13 | This example shows how to configure the U-Blox GNSS the send navigation reports automatically 14 | and retrieving the latest one via getHPPOSLLH. This eliminates the blocking in getHPPOSLLH while the GNSS 15 | produces a fresh navigation solution at the expense of returning a slighly old solution. 16 | 17 | This can be used over serial or over I2C, this example shows the I2C use. With serial the GNSS 18 | simply outputs the UBX_NAV_HPPOSLLH packet. With I2C it queues it into its internal I2C buffer (4KB in 19 | size?) where it can be retrieved in the next I2C poll. 20 | 21 | Feel like supporting open source hardware? 22 | Buy a board from SparkFun! 23 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 24 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 25 | 26 | Hardware Connections: 27 | Plug a Qwiic cable into the GNSS and a BlackBoard 28 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 29 | Open the serial monitor at 115200 baud to see the output 30 | */ 31 | 32 | #include //Needed for I2C to GNSS 33 | 34 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 35 | SFE_UBLOX_GNSS myGNSS; 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | while (!Serial); //Wait for user to open terminal 41 | Serial.println("SparkFun u-blox Example"); 42 | 43 | Wire.begin(); 44 | 45 | //myGNSS.enableDebugging(); // Uncomment this line to enable lots of helpful debug messages 46 | //myGNSS.enableDebugging(Serial, true); // Uncomment this line to enable the minimum of helpful debug messages 47 | 48 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 49 | { 50 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 51 | while (1); 52 | } 53 | 54 | // Uncomment the next line if you want to reset your module back to the default settings with 1Hz navigation rate 55 | //myGNSS.factoryDefault(); delay(5000); 56 | 57 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 58 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save the communications port settings to flash and BBR 59 | 60 | myGNSS.setNavigationFrequency(1); //Produce one solution per second 61 | 62 | 63 | // The acid test: all four of these combinations should work seamlessly :-) 64 | 65 | //myGNSS.setAutoPVT(false); // Library will poll each reading 66 | //myGNSS.setAutoHPPOSLLH(false); // Library will poll each reading 67 | 68 | //myGNSS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically 69 | //myGNSS.setAutoHPPOSLLH(false); // Library will poll each reading 70 | 71 | //myGNSS.setAutoPVT(false); // Library will poll each reading 72 | //myGNSS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically 73 | 74 | myGNSS.setAutoPVT(true); // Tell the GPS to "send" each solution automatically 75 | myGNSS.setAutoHPPOSLLH(true); // Tell the GPS to "send" each hi res solution automatically 76 | } 77 | 78 | void loop() 79 | { 80 | // Calling getHPPOSLLH returns true if there actually is a fresh navigation solution available. 81 | // Calling getPVT returns true if there actually is a fresh navigation solution available. 82 | if ((myGNSS.getHPPOSLLH()) || (myGNSS.getPVT())) 83 | { 84 | Serial.println(); 85 | 86 | long highResLatitude = myGNSS.getHighResLatitude(); 87 | Serial.print(F("Hi Res Lat: ")); 88 | Serial.print(highResLatitude); 89 | 90 | int highResLatitudeHp = myGNSS.getHighResLatitudeHp(); 91 | Serial.print(F(" ")); 92 | Serial.print(highResLatitudeHp); 93 | 94 | long highResLongitude = myGNSS.getHighResLongitude(); 95 | Serial.print(F(" Hi Res Long: ")); 96 | Serial.print(highResLongitude); 97 | 98 | int highResLongitudeHp = myGNSS.getHighResLongitudeHp(); 99 | Serial.print(F(" ")); 100 | Serial.print(highResLongitudeHp); 101 | 102 | unsigned long horizAccuracy = myGNSS.getHorizontalAccuracy(); 103 | Serial.print(F(" Horiz accuracy: ")); 104 | Serial.print(horizAccuracy); 105 | 106 | long latitude = myGNSS.getLatitude(); 107 | Serial.print(F(" Lat: ")); 108 | Serial.print(latitude); 109 | 110 | long longitude = myGNSS.getLongitude(); 111 | Serial.print(F(" Long: ")); 112 | Serial.println(longitude); 113 | } 114 | else 115 | { 116 | Serial.print("."); 117 | delay(50); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example14_NTRIPServer/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char *ssid = "TRex"; 3 | const char *password = "hasBigTeeth"; 4 | 5 | //RTK2Go works well and is free 6 | const char casterHost[] = "rtk2go.com"; 7 | const uint16_t casterPort = 2101; 8 | const char mountPoint[] = "bldr_dwntwn2"; //The mount point you want to push data to 9 | const char mountPointPW[] = "WR5wRo4H"; 10 | 11 | //Emlid Caster also works well and is free 12 | //const char casterHost[] = "caster.emlid.com"; 13 | //const uint16_t casterPort = 2101; 14 | //const char mountPoint[] = "MP1979d"; //The mount point you want to push data to 15 | //const char mountPointPW[] = "296ynq"; 16 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example15_NTRIPClient/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "hasBigTeeth"; 4 | 5 | //RTK2Go works well and is free 6 | const char casterHost[] = "rtk2go.com"; 7 | const uint16_t casterPort = 2101; 8 | const char casterUser[] = "myEmail@test.com"; //User must provide their own email address to use RTK2Go 9 | const char casterUserPW[] = ""; 10 | const char mountPoint[] = "bldr_SparkFun1"; //The mount point you want to get data from 11 | 12 | //Emlid Caster also works well and is free 13 | //const char casterHost[] = "caster.emlid.com"; 14 | //const uint16_t casterPort = 2101; 15 | //const char casterUser[] = "u99696"; //User name and pw must be obtained through their web portal 16 | //const char casterUserPW[] = "466zez"; 17 | //const char mountPoint[] = "MP1979"; //The mount point you want to get data from 18 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example16_NTRIPClient_WithGGA/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "TRex"; 3 | const char password[] = "parachutes"; 4 | 5 | //RTK2Go works well and is free 6 | const char casterHost[] = "rtk2go.com"; 7 | const uint16_t casterPort = 2101; 8 | const char casterUser[] = "myEmail@test.com"; //User must provide their own email address to use RTK2Go 9 | const char casterUserPW[] = ""; 10 | const char mountPoint[] = "bldr_SparkFun1"; //The mount point you want to get data from 11 | 12 | //Emlid Caster also works well and is free 13 | //const char casterHost[] = "caster.emlid.com"; 14 | //const uint16_t casterPort = 2101; 15 | //const char casterUser[] = "u99696"; //User name and pw must be obtained through their web portal 16 | //const char casterUserPW[] = "466zez"; 17 | //const char mountPoint[] = "MP1979"; //The mount point you want to get data from 18 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = "yourSSID"; 3 | const char password[] = "yourPassword"; 4 | 5 | //RTK2Go works well and is free 6 | //const char casterHost[] = "rtk2go.com"; 7 | //const uint16_t casterPort = 2101; 8 | //const char casterUser[] = "myEmail@test.com"; //User must provide their own email address to use RTK2Go 9 | //const char casterUserPW[] = ""; 10 | //const char mountPoint[] = "bldr_SparkFun1"; //The mount point you want to get data from 11 | 12 | //Emlid Caster also works well and is free 13 | //const char casterHost[] = "caster.emlid.com"; 14 | //const uint16_t casterPort = 2101; 15 | //const char casterUser[] = "u99696"; //User name and pw must be obtained through their web portal 16 | //const char casterUserPW[] = "466zez"; 17 | //const char mountPoint[] = "MP1979"; //The mount point you want to get data from 18 | 19 | // Skylark (Swift Navigation) is awesome - but requires a subscription: 20 | // https://www.swiftnav.com/skylark 21 | // https://account.swiftnav.com/sign-up 22 | // Use the promo-code ONEMONTHFREE for a free one month access to Skylark on one device 23 | const char casterHost[] = "na.skylark.swiftnav.com"; // na = North Americs L1+L2; eu = Europe L1+L2 24 | const uint16_t casterPort = 2101; 25 | const char casterUser[] = "NTRIPusername+accountSubdomain"; // This is generated when you add a device to your Skylark account 26 | const char casterUserPW[] = "devicePassword"; 27 | const char mountPoint[] = "CRS"; // The mount point you want to get data from. Select CRS (Cloud Reference Station) for the ZED-F9x 28 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example18_PointPerfectClient/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = ""; 3 | const char password[] = ""; 4 | 5 | // Below infomation you can set after signing up with u-blox Thingstream portal 6 | // and after add a new New PointPerfect Thing 7 | // https://portal.thingstream.io/app/location-services/things 8 | // in the new PointPerfect Thing you go to the credentials page and copy paste the values and certificate into this. 9 | 10 | // -> Credentials -> Hostname 11 | const char AWS_IOT_ENDPOINT[] = "pp.services.u-blox.com"; 12 | const unsigned short AWS_IOT_PORT = 8883; 13 | // -> Credentials -> IP key distribution topic 14 | const char MQTT_TOPIC_KEY[] = "/pp/ubx/0236/ip"; // This topic provides the IP only dynamic keys in UBX format 15 | //const char MQTT_TOPIC_KEY[] = "/pp/ubx/0236/Lb"; // This topic provides the L-Band + IP dynamic keys in UBX format 16 | // -> Credentials -> IP correction topic for EU/US region 17 | const char MQTT_TOPIC_SPARTN[] = "/pp/ip/us"; // This topic provides the SPARTN corrections for IP only: choice of {eu, us} 18 | //const char MQTT_TOPIC_SPARTN[] = "/pp/Lb/us"; // This topic provides the SPARTN corrections for L-Band and L-Band + IP: choice of {eu, us} 19 | // -> Credentials -> AssistNow (MGA) topic 20 | const char MQTT_TOPIC_ASSISTNOW[] = "/pp/ubx/mga"; 21 | 22 | // -> Credentials -> Client Id 23 | static const char MQTT_CLIENT_ID[] = ""; 24 | 25 | // -> Credentials -> Amazon Root Certificate 26 | static const char AWS_CERT_CA[] PROGMEM = R"EOF( 27 | -----BEGIN CERTIFICATE----- 28 | 29 | -----END CERTIFICATE----- 30 | )EOF"; 31 | 32 | // -> Credentials -> Client Certificate 33 | static const char AWS_CERT_CRT[] PROGMEM = R"KEY( 34 | -----BEGIN CERTIFICATE----- 35 | 36 | -----END CERTIFICATE----- 37 | )KEY"; 38 | 39 | // Get this from Thingstream Portal 40 | // -> Credentials -> Client Key 41 | static const char AWS_CERT_PRIVATE[] PROGMEM = R"KEY( 42 | -----BEGIN RSA PRIVATE KEY----- 43 | 44 | -----END RSA PRIVATE KEY----- 45 | )KEY"; 46 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example19_LBand_Corrections_with_NEO-D9S/secrets.h: -------------------------------------------------------------------------------- 1 | // You can set the information below after signing up with the u-blox Thingstream portal 2 | // and adding a new New PointPerfect Thing (L-Band or L-Band + IP) 3 | // https://portal.thingstream.io/app/location-services/things 4 | // In the new PointPerfect Thing, you go to the credentials tab and copy and paste the IP Dynamic Keys here. 5 | // 6 | // The keys are valid from a particular GPS Week Number and Time of Week. 7 | // Looking at the credentials tab, the current key expires 23:59 Feb 11th 2022. 8 | // This means the next key is valid _from_ Midnight Feb 12th 2022. 9 | // That is GPS Week 2196. The GPS Time of Week in seconds is 518400. 10 | // Working backwards, the current key became valid exactly 4 weeks earlier (Midnight Jan 15th 2022). 11 | // 12 | // See: https://www.labsat.co.uk/index.php/en/gps-time-calculator 13 | // 14 | // The keys are given as: 32 hexadecimal digits = 128 bits = 16 Bytes 15 | // 16 | // The next example shows how to retrieve the keys using ESP32 WiFi and MQTT. 17 | // You can cut and paste the keys and GPS week/time-of-week from that example into here. 18 | 19 | const uint8_t currentKeyLengthBytes = 16; 20 | const char currentDynamicKey[] = ""; 21 | const uint16_t currentKeyGPSWeek = 2254; // Update this when you add new keys 22 | const uint32_t currentKeyGPSToW = 0; 23 | 24 | const uint8_t nextKeyLengthBytes = 16; 25 | const char nextDynamicKey[] = ""; 26 | const uint16_t nextKeyGPSWeek = 2258; // Update this when you add new keys 27 | const uint32_t nextKeyGPSToW = 0; 28 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example1_GetPositionAccuracy/Example1_GetPositionAccuracy.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Get the high position accuracy of the RTK enhanced position from HPPOSECEF 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 3rd, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to inspect the accuracy of the high-precision 10 | positional solution. 11 | 12 | Feel like supporting open source hardware? 13 | Buy a board from SparkFun! 14 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 15 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 16 | SAM-M8Q: https://www.sparkfun.com/products/15106 17 | 18 | Hardware Connections: 19 | Plug a Qwiic cable into the GNSS and a BlackBoard 20 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GNSS 25 | 26 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 30 | 31 | void setup() 32 | { 33 | Serial.begin(115200); 34 | while (!Serial); //Wait for user to open terminal 35 | Serial.println("SparkFun u-blox Example"); 36 | 37 | Wire.begin(); 38 | 39 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 40 | { 41 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 42 | while (1); 43 | } 44 | 45 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 46 | //myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR 47 | } 48 | 49 | void loop() 50 | { 51 | //Query module only every second. Doing it more often will just cause I2C traffic. 52 | //The module only responds when a new position is available 53 | if (millis() - lastTime > 1000) 54 | { 55 | lastTime = millis(); //Update the timer 56 | 57 | long latitude = myGNSS.getLatitude(); 58 | Serial.print(F("Lat: ")); 59 | Serial.print(latitude); 60 | 61 | long longitude = myGNSS.getLongitude(); 62 | Serial.print(F(" Long: ")); 63 | Serial.print(longitude); 64 | Serial.print(F(" (degrees * 10^-7)")); 65 | 66 | long altitude = myGNSS.getAltitude(); 67 | Serial.print(F(" Alt: ")); 68 | Serial.print(altitude); 69 | Serial.print(F(" (mm)")); 70 | 71 | long accuracy = myGNSS.getPositionAccuracy(); 72 | Serial.print(F(" 3D Positional Accuracy: ")); 73 | Serial.print(accuracy); 74 | Serial.println(F(" (mm)")); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example20_PMP_with_L-Band_Keys_via_MQTT/secrets.h: -------------------------------------------------------------------------------- 1 | //Your WiFi credentials 2 | const char ssid[] = ""; 3 | const char password[] = ""; 4 | 5 | // Below infomation you can set after signing up with u-blox Thingstream portal 6 | // and after add a new New PointPerfect Thing (L-Band or L-Band + IP) 7 | // https://portal.thingstream.io/app/location-services/things 8 | // in the new PointPerfect Thing you go to the credentials page and copy paste the values and certificate into this. 9 | 10 | // -> Credentials -> Hostname 11 | const char AWS_IOT_ENDPOINT[] = "pp.services.u-blox.com"; 12 | const unsigned short AWS_IOT_PORT = 8883; 13 | // -> Credentials -> IP key distribution topic 14 | //const char MQTT_TOPIC_KEY[] = "/pp/ubx/0236/ip"; // This topic provides the IP only dynamic keys in UBX format 15 | const char MQTT_TOPIC_KEY[] = "/pp/ubx/0236/Lb"; // This topic provides the L-Band + IP dynamic keys in UBX format 16 | 17 | // -> Credentials -> Client Id 18 | static const char MQTT_CLIENT_ID[] = ""; 19 | 20 | // -> Credentials -> Amazon Root Certificate 21 | static const char AWS_CERT_CA[] PROGMEM = R"EOF( 22 | -----BEGIN CERTIFICATE----- 23 | 24 | -----END CERTIFICATE----- 25 | )EOF"; 26 | 27 | // -> Credentials -> Client Certificate 28 | static const char AWS_CERT_CRT[] PROGMEM = R"KEY( 29 | -----BEGIN CERTIFICATE----- 30 | 31 | -----END CERTIFICATE----- 32 | )KEY"; 33 | 34 | // Get this from Thingstream Portal 35 | // -> Credentials -> Client Key 36 | static const char AWS_CERT_PRIVATE[] PROGMEM = R"KEY( 37 | -----BEGIN RSA PRIVATE KEY----- 38 | 39 | -----END RSA PRIVATE KEY----- 40 | )KEY"; 41 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example23_getRXMRAWX/Example23_getRXMRAWX.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Polling RXM RAWX reports over I2C 3 | By: Paul Clark 4 | SparkFun Electronics 5 | Date: November 25th, 2022 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to poll RXM RAWX reports from the u-blox module. 10 | 11 | Feel like supporting open source hardware? 12 | Buy a board from SparkFun! 13 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 14 | 15 | Hardware Connections: 16 | Plug a Qwiic cable into the GPS and a BlackBoard 17 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 18 | Open the serial monitor at 115200 baud to see the output 19 | */ 20 | 21 | #include //Needed for I2C to GPS 22 | 23 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 24 | SFE_UBLOX_GNSS myGNSS; 25 | 26 | void setup() 27 | { 28 | Serial.begin(115200); 29 | while (!Serial); //Wait for user to open terminal 30 | Serial.println("SparkFun u-blox Example"); 31 | 32 | Wire.begin(); 33 | 34 | //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial 35 | 36 | // Because we are polling RAWX, we need to increase the size of packetCfg.payload 37 | // RAWX packets can be over 2K bytes so let's allocate 3K bytes 38 | if (!myGNSS.setPacketCfgPayloadSize(3000)) 39 | { 40 | Serial.println(F("setPacketCfgPayloadSize failed. You will not be able to poll RAWX data. Freezing.")); 41 | while (1); // Do nothing more 42 | } 43 | 44 | while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 45 | { 46 | Serial.println(F("u-blox GNSS not detected at default I2C address. Retrying...")); 47 | delay(1000); 48 | } 49 | 50 | Serial.println(F("u-blox GNSS detected.")); 51 | 52 | myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) 53 | myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR 54 | 55 | myGNSS.setNavigationFrequency(1); //Produce one solution per second (RAWX produces a _lot_ of data!) 56 | } 57 | 58 | void loop() 59 | { 60 | if (myGNSS.getRXMRAWX()) // Poll RAWX data 61 | { 62 | // Print the RAWX data, using a pointer to the RXM RAWX data stored in packetUBXRXMRAWX 63 | printRAWX(&myGNSS.packetUBXRXMRAWX->data); 64 | } 65 | } 66 | 67 | void printRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct) 68 | { 69 | Serial.println(); 70 | 71 | Serial.print(F("New RAWX data received. It contains ")); 72 | Serial.print(ubxDataStruct->header.numMeas); // Print numMeas (Number of measurements / blocks) 73 | Serial.println(F(" data blocks:")); 74 | 75 | for (uint8_t block = 0; block < ubxDataStruct->header.numMeas; block++) // For each block 76 | { 77 | Serial.print(F("GNSS ID: ")); 78 | if (ubxDataStruct->blocks[block].gnssId < 100) Serial.print(F(" ")); // Align the gnssId 79 | if (ubxDataStruct->blocks[block].gnssId < 10) Serial.print(F(" ")); // Align the gnssId 80 | Serial.print(ubxDataStruct->blocks[block].gnssId); 81 | Serial.print(F(" SV ID: ")); 82 | if (ubxDataStruct->blocks[block].svId < 100) Serial.print(F(" ")); // Align the svId 83 | if (ubxDataStruct->blocks[block].svId < 10) Serial.print(F(" ")); // Align the svId 84 | Serial.print(ubxDataStruct->blocks[block].svId); 85 | 86 | if (sizeof(double) == 8) // Check if our processor supports 64-bit double 87 | { 88 | // Convert prMes from uint8_t[8] to 64-bit double 89 | // prMes is little-endian 90 | double pseudorange; 91 | memcpy(&pseudorange, &ubxDataStruct->blocks[block].prMes, 8); 92 | Serial.print(F(" PR: ")); 93 | Serial.print(pseudorange, 3); 94 | 95 | // Convert cpMes from uint8_t[8] to 64-bit double 96 | // cpMes is little-endian 97 | double carrierPhase; 98 | memcpy(&carrierPhase, &ubxDataStruct->blocks[block].cpMes, 8); 99 | Serial.print(F(" m CP: ")); 100 | Serial.print(carrierPhase, 3); 101 | Serial.print(F(" cycles")); 102 | } 103 | Serial.println(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example2_ValConfigurationMethod/Example2_ValConfigurationMethod.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring u-blox Module using new VALGET / VALSET / VALDEL methods 3 | 4 | Please see u-blox_config_keys.h for the definitions of _all_ of the configuration keys 5 | 6 | By: Nathan Seidle 7 | SparkFun Electronics 8 | Date: January 3rd, 2019 9 | License: MIT. See license file for more information but you can 10 | basically do whatever you want with this code. 11 | 12 | u-blox deprecated many -CFG messages and replaced them with new 13 | VALGET, VALSET, VALDEL methods. This shows the basics of how to use 14 | these methods. 15 | 16 | Leave NMEA parsing behind. Now you can simply ask the module for the datums you want! 17 | 18 | Feel like supporting open source hardware? 19 | Buy a board from SparkFun! 20 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 21 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 22 | SAM-M8Q: https://www.sparkfun.com/products/15106 23 | 24 | Hardware Connections: 25 | Plug a Qwiic cable into the GNSS and a BlackBoard 26 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 27 | Open the serial monitor at 115200 baud to see the output 28 | */ 29 | 30 | #include //Needed for I2C to GNSS 31 | 32 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 33 | SFE_UBLOX_GNSS myGNSS; 34 | 35 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | while (!Serial); //Wait for user to open terminal 41 | Serial.println("SparkFun u-blox Example"); 42 | 43 | Wire.begin(); 44 | 45 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 46 | { 47 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 48 | while (1); 49 | } 50 | 51 | byte response; 52 | response = myGNSS.getVal8(UBLOX_CFG_I2C_ADDRESS, VAL_LAYER_RAM); // Get the I2C address (see u-blox_config_keys.h for details) 53 | Serial.print(F("I2C Address: 0x")); 54 | Serial.println(response >> 1, HEX); //We have to shift by 1 to get the common '7-bit' I2C address format 55 | 56 | response = myGNSS.getVal8(UBLOX_CFG_I2COUTPROT_NMEA, VAL_LAYER_RAM); // Get the flag indicating is NMEA should be output on I2C 57 | Serial.print(F("Output NMEA over I2C port: 0x")); 58 | Serial.print(response, HEX); 59 | } 60 | 61 | void loop() 62 | { 63 | } 64 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example6_GetVal/Example6_GetVal.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Get a device's I2C address using advanced getVal method 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 9th, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the 10 | UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL 11 | commands instead. This example shows how to use this new command structure. 12 | 13 | Feel like supporting open source hardware? 14 | Buy a board from SparkFun! 15 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 16 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 17 | SAM-M8Q: https://www.sparkfun.com/products/15106 18 | 19 | Hardware Connections: 20 | Plug a Qwiic cable into the GNSS and a RedBoard Qwiic or BlackBoard 21 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 22 | Open the serial monitor at 115200 baud to see the output 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 31 | 32 | void setup() 33 | { 34 | Serial.begin(115200); 35 | while (!Serial) 36 | ; //Wait for user to open terminal 37 | Serial.println("u-blox getVal example"); 38 | 39 | Wire.begin(); 40 | Wire.setClock(400000); //Increase I2C clock speed to 400kHz 41 | 42 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 43 | { 44 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 45 | while (1) 46 | ; 47 | } 48 | 49 | //myGNSS.enableDebugging(); //Enable debug messages over Serial (default) 50 | //myGNSS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB 51 | 52 | uint8_t currentI2Caddress = myGNSS.getVal8(UBLOX_CFG_I2C_ADDRESS); 53 | Serial.print("Current I2C address (should be 0x42): 0x"); 54 | Serial.println(currentI2Caddress >> 1, HEX); //u-blox module returns a shifted 8-bit address. Make it 7-bit unshifted. 55 | } 56 | 57 | void loop() 58 | { 59 | // Nothing to do here 60 | } 61 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example7_SetVal/Example7_SetVal.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Send UBX binary commands to enable RTCM sentences on u-blox ZED-F9P module 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: January 9th, 2019 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | u-blox changed how to configure their modules in 2019. As of version 23 of the UBX protocol the 10 | UBX-CFG commands are deprecated; they still work, they just recommend using VALSET, VALGET, and VALDEL 11 | commands instead. This example shows how to use this new command structure. 12 | 13 | Feel like supporting open source hardware? 14 | Buy a board from SparkFun! 15 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 16 | NEO-M8P RTK: https://www.sparkfun.com/products/15005 17 | SAM-M8Q: https://www.sparkfun.com/products/15106 18 | 19 | Hardware Connections: 20 | Plug a Qwiic cable into the GNSS and a RedBoard Qwiic or BlackBoard 21 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 22 | Open the serial monitor at 115200 baud to see the output 23 | */ 24 | 25 | #include //Needed for I2C to GNSS 26 | 27 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 28 | SFE_UBLOX_GNSS myGNSS; 29 | 30 | long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module. 31 | 32 | void setup() 33 | { 34 | Serial.begin(115200); 35 | while (!Serial) 36 | ; //Wait for user to open terminal 37 | Serial.println("u-blox getVal example"); 38 | 39 | Wire.begin(); 40 | Wire.setClock(400000); //Increase I2C clock speed to 400kHz 41 | 42 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 43 | { 44 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 45 | while (1) 46 | ; 47 | } 48 | 49 | //myGNSS.enableDebugging(); //Enable debug messages over Serial (default) 50 | //myGNSS.enableDebugging(SerialUSB); //Enable debug messages over Serial USB 51 | 52 | bool setValueSuccess; 53 | 54 | //These key values are hard coded and defined in u-blox_config_keys.h. 55 | //You can obtain them from the ZED-F9P interface description doc 56 | //or from u-center's Messages->CFG->VALSET window. Keys must be 32-bit. 57 | //setValueSuccess = myGNSS.setVal(UBLOX_CFG_NMEA_HIGHPREC, 0); //Enable high precision NMEA 58 | //setValueSuccess = myGNSS.setVal(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 100ms (10Hz update rate) 59 | setValueSuccess = myGNSS.setVal(UBLOX_CFG_RATE_MEAS, 1000); //Set measurement rate to 1000ms (1Hz update rate) 60 | 61 | //Below is the original way we enabled the RTCM message on the I2C port. After that, we show how to do the same 62 | //but with setVal(). 63 | //Original: myGNSS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second 64 | //setValueSuccess = myGNSS.setVal(UBLOX_CFG_MSGOUT_RTCM_3X_TYPE1005_I2C, 1); //Set output rate of msg 1005 over the I2C port to once per second 65 | 66 | if (setValueSuccess == true) 67 | { 68 | Serial.println("Value was successfully set"); 69 | } 70 | else 71 | Serial.println("Value set failed"); 72 | } 73 | 74 | void loop() 75 | { 76 | } 77 | -------------------------------------------------------------------------------- /examples/ZED-F9P/Example8_GetSetPortSettings/Example8_GetSetPortSettings.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Configuring port settings using the newer getVal/setVal methods 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: October 23rd, 2020 6 | License: MIT. See license file for more information but you can 7 | basically do whatever you want with this code. 8 | 9 | This example shows how to query a u-blox module for its UART1 settings and 10 | then change them if the settings aren't what we want. 11 | 12 | Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher. 13 | 14 | Feel like supporting open source hardware? 15 | Buy a board from SparkFun! 16 | ZED-F9P RTK2: https://www.sparkfun.com/products/15136 17 | 18 | Hardware Connections: 19 | Plug a Qwiic cable into the GNSS and a RedBoard 20 | If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) 21 | Open the serial monitor at 115200 baud to see the output 22 | */ 23 | 24 | #include //Needed for I2C to GNSS 25 | 26 | #include //http://librarymanager/All#SparkFun_u-blox_GNSS 27 | SFE_UBLOX_GNSS myGNSS; 28 | 29 | void setup() 30 | { 31 | Serial.begin(115200); 32 | while (!Serial) 33 | ; //Wait for user to open terminal 34 | Serial.println("SparkFun u-blox Example"); 35 | 36 | Wire.begin(); 37 | 38 | if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port 39 | { 40 | Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); 41 | while (1) 42 | ; 43 | } 44 | 45 | bool response = true; 46 | 47 | //Read the settings from RAM (what the module is running right now, not BBR, Flash, or default) 48 | uint8_t currentUART1Setting_ubx = myGNSS.getVal8(UBLOX_CFG_UART1INPROT_UBX); 49 | uint8_t currentUART1Setting_nmea = myGNSS.getVal8(UBLOX_CFG_UART1INPROT_NMEA); 50 | uint8_t currentUART1Setting_rtcm3 = myGNSS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X); 51 | 52 | Serial.print("currentUART1Setting_ubx: "); 53 | Serial.println(currentUART1Setting_ubx); 54 | Serial.print("currentUART1Setting_nmea: "); 55 | Serial.println(currentUART1Setting_nmea); 56 | Serial.print("currentUART1Setting_rtcm3: "); 57 | Serial.println(currentUART1Setting_rtcm3); 58 | 59 | //Check if NMEA and RTCM are enabled for UART1 60 | if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0) 61 | { 62 | Serial.println("Updating UART1 configuration"); 63 | 64 | //setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed 65 | response &= myGNSS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input 66 | response &= myGNSS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input 67 | response &= myGNSS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input 68 | 69 | if (response == false) 70 | Serial.println("SetVal failed"); 71 | else 72 | Serial.println("SetVal succeeded"); 73 | } 74 | else 75 | Serial.println("No port change needed"); 76 | 77 | //Change speed of UART2 78 | uint32_t currentUART2Baud = myGNSS.getVal32(UBLOX_CFG_UART2_BAUDRATE); 79 | Serial.print("currentUART2Baud: "); 80 | Serial.println(currentUART2Baud); 81 | 82 | if (currentUART2Baud != 57600) 83 | { 84 | response &= myGNSS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 57600); 85 | if (response == false) 86 | Serial.println("SetVal failed"); 87 | else 88 | Serial.println("SetVal succeeded"); 89 | } 90 | else 91 | Serial.println("No baud change needed"); 92 | 93 | Serial.println("Done"); 94 | } 95 | 96 | void loop() 97 | { 98 | } 99 | -------------------------------------------------------------------------------- /img/Contributing.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/4e542ba29be98088e5a1c4ee9ccafdd07901cb86/img/Contributing.JPG -------------------------------------------------------------------------------- /keys/NEO-D9S_InterfaceDescription_UBX-19048765_keys_sorted.txt: -------------------------------------------------------------------------------- 1 | 0x1041000d 2 | 0x10410013 3 | 0x10510002 4 | 0x10510003 5 | 0x10520005 6 | 0x10530005 7 | 0x10530006 8 | 0x10640002 9 | 0x10640003 10 | 0x10640005 11 | 0x10640006 12 | 0x10650001 13 | 0x10650002 14 | 0x10710001 15 | 0x10720001 16 | 0x10730001 17 | 0x10740001 18 | 0x10750001 19 | 0x10760001 20 | 0x10770001 21 | 0x10780001 22 | 0x10790001 23 | 0x107a0001 24 | 0x10a20001 25 | 0x10a20002 26 | 0x10a3002e 27 | 0x10a3002f 28 | 0x10a30030 29 | 0x10a30031 30 | 0x10a30032 31 | 0x10a30033 32 | 0x10a30034 33 | 0x10a30035 34 | 0x10b10014 35 | 0x10b10016 36 | 0x10b10019 37 | 0x10c70001 38 | 0x10c70002 39 | 0x10d0000c 40 | 0x10d0000d 41 | 0x10d0000e 42 | 0x20210003 43 | 0x20410001 44 | 0x20410002 45 | 0x20410010 46 | 0x20510001 47 | 0x20520002 48 | 0x20520003 49 | 0x20520004 50 | 0x20530002 51 | 0x20530003 52 | 0x20530004 53 | 0x20640001 54 | 0x20910187 55 | 0x20910188 56 | 0x20910189 57 | 0x2091018a 58 | 0x2091018b 59 | 0x20910196 60 | 0x20910197 61 | 0x20910198 62 | 0x20910199 63 | 0x2091019a 64 | 0x2091019b 65 | 0x2091019c 66 | 0x2091019d 67 | 0x2091019e 68 | 0x2091019f 69 | 0x209101a0 70 | 0x209101a1 71 | 0x209101a2 72 | 0x209101a3 73 | 0x209101a4 74 | 0x209101a5 75 | 0x209101a6 76 | 0x209101a7 77 | 0x209101a8 78 | 0x209101a9 79 | 0x209101b4 80 | 0x209101b5 81 | 0x209101b6 82 | 0x209101b7 83 | 0x209101b8 84 | 0x209101b9 85 | 0x209101ba 86 | 0x209101bb 87 | 0x209101bc 88 | 0x209101bd 89 | 0x20910231 90 | 0x20910232 91 | 0x20910233 92 | 0x20910234 93 | 0x20910235 94 | 0x20910259 95 | 0x2091025a 96 | 0x2091025b 97 | 0x2091025c 98 | 0x2091025d 99 | 0x2091031d 100 | 0x2091031e 101 | 0x2091031f 102 | 0x20910320 103 | 0x20910321 104 | 0x20920001 105 | 0x20920002 106 | 0x20920003 107 | 0x20920004 108 | 0x20920005 109 | 0x20920006 110 | 0x20920007 111 | 0x20920008 112 | 0x20920009 113 | 0x2092000a 114 | 0x20a20003 115 | 0x20a20005 116 | 0x20a30036 117 | 0x20a30037 118 | 0x20a30038 119 | 0x20c70003 120 | 0x20d0000b 121 | 0x30210001 122 | 0x30210002 123 | 0x3065000a 124 | 0x3065000b 125 | 0x3065000c 126 | 0x30a20004 127 | 0x30b10012 128 | 0x30b10013 129 | 0x30b10015 130 | 0x30b10017 131 | 0x40520001 132 | 0x40530001 133 | 0x40b10011 134 | 0x40d0000f 135 | 0x5065000d 136 | 0x5065000e 137 | 0x5065000f 138 | 0x50650010 139 | 0x50650011 140 | 0x50650012 141 | 0x50650013 142 | 0x50650014 143 | 0x50650015 144 | 0x50650016 145 | 0x50650017 146 | 0x50650018 147 | 0x50b1001a 148 | 0x50c70004 149 | 0x50c70005 150 | 0x50c70006 151 | 0x50c70007 152 | -------------------------------------------------------------------------------- /keys/u-blox-D9-QZS-1.01_InterfaceDescription_UBX-21031777_keys_sorted.txt: -------------------------------------------------------------------------------- 1 | 0x10520005 2 | 0x10650001 3 | 0x10650002 4 | 0x10730001 5 | 0x10730003 6 | 0x10740001 7 | 0x10770001 8 | 0x10770003 9 | 0x10780001 10 | 0x20370020 11 | 0x20370030 12 | 0x20370050 13 | 0x20370060 14 | 0x20370080 15 | 0x20520002 16 | 0x20520003 17 | 0x20520004 18 | 0x2091033b 19 | 0x2091033d 20 | 0x20920002 21 | 0x20920004 22 | 0x3065000a 23 | 0x3065000b 24 | 0x3065000c 25 | 0x40520001 26 | 0x5065000d 27 | 0x5065000e 28 | 0x5065000f 29 | 0x50650010 30 | 0x50650011 31 | 0x50650012 32 | 0x50650013 33 | 0x50650014 34 | 0x50650015 35 | 0x50650016 36 | 0x50650017 37 | 0x50650018 38 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=SparkFun u-blox GNSS Arduino Library 2 | version=2.2.27 3 | author=SparkFun Electronics 4 | maintainer=SparkFun Electronics 5 | sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules

6 | paragraph=An Arduino Library to support the full range of u-blox GNSS modules, using both NMEA and UBX protocols over I2C, Serial and SPI. Useful for interfacing to the SparkFun GPS-RTK2 ZED-F9P, SparkFun GPS-RTK NEO-M8P-2, SparkFun SAM-M8Q, SparkFun ZOE-M8Q and all the other SparkFun u-blox GNSS Breakouts.

The ZED-F9P and NEO-M8P-2 modules are top-of-the-line modules for high accuracy GNSS and GPS location solutions including RTK. The ZED-F9P is unique in that it is capable of both rover and base station operations allowing the module to become a base station and produce RTCM 3.x correction data.

Need support for RTK NTRIP Caster services like RTK2go, Emlid Caster and Skylark? This library has functions, callbacks and tried-and-tested examples to let you push RTCM correction data to your module seamlessly!
7 | category=Sensors 8 | url=https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library 9 | architectures=* 10 | --------------------------------------------------------------------------------