Skip to content

Commit 6f5f8c8

Browse files
committed
Add NEO-M8P moving base examples - resolves #184
1 parent 2e24bf4 commit 6f5f8c8

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 <Wire.h> //Needed for I2C to GNSS
25+
26+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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 <Wire.h> //Needed for I2C to GNSS
24+
25+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //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+
}

0 commit comments

Comments
 (0)