Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 619ff88

Browse files
committed
Adding support for HNR messages on the NEO-M8U (with "auto")
1 parent 9397889 commit 619ff88

File tree

5 files changed

+800
-27
lines changed

5 files changed

+800
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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 <Wire.h> //Needed for I2C to GPS
31+
32+
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_Ublox_GPS
33+
SFE_UBLOX_GPS myGPS;
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+
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
44+
45+
if (myGPS.begin() == false) //Connect to the Ublox 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+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
52+
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
53+
54+
if (myGPS.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+
60+
void loop()
61+
{
62+
// Poll and print selected HNR data
63+
if (myGPS.getHNRAtt(125) == true) // Request HNR Att data using a 125ms timeout
64+
{
65+
Serial.print(F("Roll: "));
66+
Serial.print(myGPS.hnrAtt.roll);
67+
Serial.print(F(" Pitch: "));
68+
Serial.print(myGPS.hnrAtt.pitch);
69+
Serial.print(F(" Heading: "));
70+
Serial.println(myGPS.hnrAtt.heading);
71+
}
72+
if (myGPS.getHNRDyn(125) == true) // Request HNR Dyn data using a 125ms timeout
73+
{
74+
Serial.print(F("xAccel: "));
75+
Serial.print(myGPS.hnrVehDyn.xAccel);
76+
Serial.print(F(" yAccel: "));
77+
Serial.print(myGPS.hnrVehDyn.yAccel);
78+
Serial.print(F(" zAccel: "));
79+
Serial.println(myGPS.hnrVehDyn.zAccel);
80+
}
81+
if (myGPS.getHNRPVT(125) == true) // Request HNR PVT data using a 125ms timeout
82+
{
83+
Serial.print(F("ns: "));
84+
Serial.print(myGPS.hnrPVT.nano);
85+
Serial.print(F(" Lat: "));
86+
Serial.print(myGPS.hnrPVT.lat);
87+
Serial.print(F(" Lon: "));
88+
Serial.println(myGPS.hnrPVT.lon);
89+
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
}

Diff for: keywords.txt

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ setStaticPosition KEYWORD2
175175

176176
pushRawData KEYWORD2
177177

178+
setHNRNavigationRate KEYWORD2
179+
getHNRNavigationRate KEYWORD2
180+
assumeAutoHNRAtt KEYWORD2
181+
setAutoHNRAtt KEYWORD2
182+
getHNRAtt KEYWORD2
183+
assumeAutoHNRDyn KEYWORD2
184+
setAutoHNRDyn KEYWORD2
185+
getHNRDyn KEYWORD2
186+
assumeAutoHNRPVT KEYWORD2
187+
setAutoHNRPVT KEYWORD2
188+
getHNRPVT KEYWORD2
189+
178190
#######################################
179191
# Constants (LITERAL1)
180192
#######################################

0 commit comments

Comments
 (0)