|
| 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 <Wire.h> //Needed for I2C to GPS |
| 30 | + |
| 31 | +#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS |
| 32 | +SFE_UBLOX_GPS myGPS; |
| 33 | + |
| 34 | +boolean usingAutoHNRAtt = false; |
| 35 | +boolean usingAutoHNRDyn = false; |
| 36 | +boolean 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 | + //myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial |
| 47 | + |
| 48 | + if (myGPS.begin() == false) //Connect to the Ublox 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 | + myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise) |
| 55 | + myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR |
| 56 | + |
| 57 | + if (myGPS.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 = myGPS.setAutoHNRAtt(true); //Attempt to enable auto HNR attitude messages |
| 63 | + usingAutoHNRDyn = myGPS.setAutoHNRDyn(true); //Attempt to enable auto HNR vehicle dynamics messages |
| 64 | + usingAutoHNRPVT = myGPS.setAutoHNRPVT(true); //Attempt to enable auto HNR PVT messages |
| 65 | +} |
| 66 | + |
| 67 | +void loop() |
| 68 | +{ |
| 69 | + if (usingAutoHNRAtt && (myGPS.getHNRAtt() == true)) // If setAutoHNRAtt was successful and new data is available |
| 70 | + { |
| 71 | + Serial.print(F("Roll: ")); // Print selected data |
| 72 | + Serial.print(myGPS.hnrAtt.roll); |
| 73 | + Serial.print(F(" Pitch: ")); |
| 74 | + Serial.print(myGPS.hnrAtt.pitch); |
| 75 | + Serial.print(F(" Heading: ")); |
| 76 | + Serial.println(myGPS.hnrAtt.heading); |
| 77 | + } |
| 78 | + if (usingAutoHNRDyn && (myGPS.getHNRDyn() == true)) // If setAutoHNRDyn was successful and new data is available |
| 79 | + { |
| 80 | + Serial.print(F("xAccel: ")); // Print selected data |
| 81 | + Serial.print(myGPS.hnrVehDyn.xAccel); |
| 82 | + Serial.print(F(" yAccel: ")); |
| 83 | + Serial.print(myGPS.hnrVehDyn.yAccel); |
| 84 | + Serial.print(F(" zAccel: ")); |
| 85 | + Serial.println(myGPS.hnrVehDyn.zAccel); |
| 86 | + } |
| 87 | + if (usingAutoHNRPVT && (myGPS.getHNRPVT() == true)) // If setAutoHNRPVT was successful and new data is available |
| 88 | + { |
| 89 | + Serial.print(F("ns: ")); // Print selected data |
| 90 | + Serial.print(myGPS.hnrPVT.nano); |
| 91 | + Serial.print(F(" Lat: ")); |
| 92 | + Serial.print(myGPS.hnrPVT.lat); |
| 93 | + Serial.print(F(" Lon: ")); |
| 94 | + Serial.println(myGPS.hnrPVT.lon); |
| 95 | + } |
| 96 | +} |
0 commit comments