|
| 1 | +/* |
| 2 | + Configuring the GPS to automatically send position reports over I2C at high frequency |
| 3 | + The ZED-F9K can handle rates up to 30Hz |
| 4 | + By: Paul Clark (PaulZC) |
| 5 | + Date: May 11th, 2020 |
| 6 | +
|
| 7 | + Based on an earlier example: |
| 8 | + By: Nathan Seidle and Thorsten von Eicken |
| 9 | + SparkFun Electronics |
| 10 | + Date: January 3rd, 2019 |
| 11 | + License: MIT. See license file for more information but you can |
| 12 | + basically do whatever you want with this code. |
| 13 | +
|
| 14 | + This example shows how to configure the U-Blox GPS the send navigation reports automatically |
| 15 | + and retrieving the latest one via getPVT. This eliminates the blocking in getPVT while the GPS |
| 16 | + produces a fresh navigation solution at the expense of returning a slighly old solution. |
| 17 | +
|
| 18 | + This can be used over serial or over I2C, this example shows the I2C use. With serial the GPS |
| 19 | + simply outputs the UBX_NAV_PVT packet. With I2C it queues it into its internal I2C buffer (4KB in |
| 20 | + size?) where it can be retrieved in the next I2C poll. |
| 21 | +
|
| 22 | + Feel like supporting open source hardware? |
| 23 | + Buy a board from SparkFun! |
| 24 | + ZED-F9P RTK2: https://www.sparkfun.com/products/15136 |
| 25 | + NEO-M8P RTK: https://www.sparkfun.com/products/15005 |
| 26 | + SAM-M8Q: https://www.sparkfun.com/products/15106 |
| 27 | +
|
| 28 | + Hardware Connections: |
| 29 | + Plug a Qwiic cable into the GPS and a BlackBoard |
| 30 | + If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425) |
| 31 | + Open the serial monitor at 115200 baud to see the output |
| 32 | +*/ |
| 33 | + |
| 34 | +#include <Wire.h> //Needed for I2C to GPS |
| 35 | + |
| 36 | +#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS |
| 37 | +SFE_UBLOX_GPS myGPS; |
| 38 | + |
| 39 | +uint16_t old_millis = 0; // Store the last millis reading |
| 40 | +uint16_t new_millis = 0; // Store the new millis reading |
| 41 | + |
| 42 | +void setup() |
| 43 | +{ |
| 44 | + Serial.begin(115200); // You may need to increase this for very high rates |
| 45 | + while (!Serial); //Wait for user to open terminal |
| 46 | + Serial.println(F("SparkFun Ublox Example")); |
| 47 | + |
| 48 | + Wire.begin(); |
| 49 | + |
| 50 | +#if defined(ARDUINO_ARCH_APOLLO3) |
| 51 | + // For the Artemis, we need to disable the internal I2C pull-ups |
| 52 | + // otherwise we see many additional I2C bus gremlins. |
| 53 | + // If you have disabled the pull-up resistors on your GNSS board, |
| 54 | + // you _may_ need to comment the next line: |
| 55 | + Wire.setPullups(0); // Disable Artemis I2C pull-ups |
| 56 | + |
| 57 | + // Alternatives values are: |
| 58 | + //Wire.setPullups(1); // Set Artemis I2C pull-ups to 1.5K (default) |
| 59 | + //Wire.setPullups(6); // Set Artemis I2C pull-ups to 6K |
| 60 | + //Wire.setPullups(12); // Set Artemis I2C pull-ups to 12K |
| 61 | + //Wire.setPullups(24); // Set Artemis I2C pull-ups to 24K |
| 62 | +#endif |
| 63 | + |
| 64 | + myGPS.enableDebugging(Serial, true); // Print limited debug messages only |
| 65 | + |
| 66 | + if (myGPS.begin() == false) //Connect to the Ublox module using Wire port |
| 67 | + { |
| 68 | + Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
| 69 | + while (1); |
| 70 | + } |
| 71 | + |
| 72 | + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) |
| 73 | + |
| 74 | + // For the ZED family, we can limit the GNSS Satellite Systems used to GPS only to |
| 75 | + // allow faster navigation rates |
| 76 | + myGPS.newCfgValset8(0x10310021, 0, VAL_LAYER_RAM); // Disable GAL in RAM |
| 77 | + myGPS.addCfgValset8(0x10310022, 0); // Disable BDS (in RAM) |
| 78 | + myGPS.addCfgValset8(0x10310024, 0); // Disable QZSS (in RAM) |
| 79 | + myGPS.sendCfgValset8(0x10310025, 0); // Disable GLO (in RAM) |
| 80 | + |
| 81 | + delay(3100); // Wait for the GNSS to reconfigure |
| 82 | + |
| 83 | + myGPS.setNavigationFrequency(30); //Produce 30 (!) solutions per second (only valid on devices like the ZED-F9K) |
| 84 | + myGPS.setAutoPVT(true); //Tell the GPS to "send" each solution |
| 85 | + //myGPS.saveConfiguration(); //Save the current settings to flash and BBR |
| 86 | +} |
| 87 | + |
| 88 | +void loop() |
| 89 | +{ |
| 90 | + // Only print GNSS millis otherwise we will probably overrun the Serial buffer |
| 91 | + new_millis = myGPS.getMillisecond(); // Get the latest millis (using AutoPVT) |
| 92 | + if (new_millis != old_millis) // Only print millis when it changes |
| 93 | + { |
| 94 | + if (new_millis < 10) Serial.print(F("0")); // Pad zeros |
| 95 | + if (new_millis < 100) Serial.print(F("0")); // Pad zeros |
| 96 | + Serial.println(new_millis); |
| 97 | + old_millis = new_millis; // Update old_millis |
| 98 | + } |
| 99 | + delay(5); // Let's limit how often we call checkUbloxInternal via getPVT |
| 100 | +} |
0 commit comments