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

Commit 71ee3a9

Browse files
committed
Adding Base with LCD example
1 parent e946628 commit 71ee3a9

File tree

2 files changed

+193
-1
lines changed

2 files changed

+193
-1
lines changed

examples/ZED-F9P/Example3_StartRTCMBase/Example3_StartRTCMBase.ino

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void setup()
3333
{
3434
Serial.begin(115200);
3535
while (!Serial); //Wait for user to open terminal
36-
Serial.println("Ublox NEO-M8P-2 base station example");
36+
Serial.println("Ublox Base station example");
3737

3838
Wire.begin();
3939
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
@@ -59,6 +59,10 @@ void setup()
5959
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_I2C, 1);
6060
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
6161

62+
//Use COM_PORT_UART1 for the above six messages to direct RTCM messages out UART1
63+
//COM_PORT_UART2, COM_PORT_USB, COM_PORT_SPI are also available
64+
//For example: response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_UART1, 10);
65+
6266
if (response == true)
6367
{
6468
Serial.println("RTCM messages enabled");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
Send UBX binary commands to enable RTCM sentences on Ublox 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+
This example does all steps to configure and enable a ZED-F9P as a base station:
10+
Begin Survey-In
11+
Once we've achieved 2m accuracy and 300s have passed, survey is complete
12+
Enable six RTCM messages
13+
Begin outputting RTCM bytes
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 GPS and a BlackBoard
23+
Plug a SerLCD onto the Qwiic bus
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+
Watch the output on the LCD or open the serial monitor at 115200 baud to see the output
26+
*/
27+
28+
#define STAT_LED 13
29+
30+
#include <Wire.h> //Needed for I2C to GPS
31+
32+
#include "SparkFun_Ublox_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_Ublox_GPS
33+
SFE_UBLOX_GPS myGPS;
34+
35+
#include <SerLCD.h> //Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
36+
SerLCD lcd; // Initialize the library with default I2C address 0x72
37+
38+
void setup()
39+
{
40+
Serial.begin(115200);
41+
while (!Serial); //Wait for user to open terminal
42+
Serial.println("Ublox GPS I2C Test");
43+
44+
Wire.begin();
45+
46+
pinMode(STAT_LED, OUTPUT);
47+
digitalWrite(STAT_LED, LOW);
48+
49+
lcd.begin(Wire); //Set up the LCD for Serial communication at 9600bps
50+
lcd.setBacklight(0x4B0082); //indigo, a kind of dark purplish blue
51+
lcd.clear();
52+
lcd.print(F("LCD Ready"));
53+
54+
myGPS.begin(Wire);
55+
if (myGPS.isConnected() == false)
56+
{
57+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
58+
lcd.setCursor(0, 1);
59+
lcd.print(F("No GPS detected"));
60+
while (1);
61+
}
62+
63+
Wire.setClock(400000); //Increase I2C clock speed to 400kHz
64+
65+
lcd.setCursor(0, 1);
66+
lcd.print("GPS Detected");
67+
68+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
69+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
70+
71+
boolean response = true;
72+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
73+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1074, COM_PORT_I2C, 1);
74+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1084, COM_PORT_I2C, 1);
75+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1094, COM_PORT_I2C, 1);
76+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1124, COM_PORT_I2C, 1);
77+
response &= myGPS.enableRTCMmessage(UBX_RTCM_1230, COM_PORT_I2C, 10); //Enable message every 10 seconds
78+
if (response == true)
79+
{
80+
Serial.println(F("RTCM messages enabled"));
81+
}
82+
else
83+
{
84+
Serial.println(F("RTCM failed to enable. Are you sure you have an NEO-M8P?"));
85+
while (1); //Freeze
86+
}
87+
88+
//Check if Survey is in Progress before initiating one
89+
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (request can take a long time)
90+
if (response == false)
91+
{
92+
Serial.println(F("Failed to get Survey In status"));
93+
while (1); //Freeze
94+
}
95+
96+
if (myGPS.svin.active == true)
97+
{
98+
Serial.print(F("Survey already in progress."));
99+
lcd.setCursor(0, 2);
100+
lcd.print(F("Survey already going"));
101+
}
102+
else
103+
{
104+
//Start survey
105+
response = myGPS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
106+
if (response == false)
107+
{
108+
Serial.println(F("Survey start failed"));
109+
lcd.setCursor(0, 3);
110+
lcd.print(F("Survey start failed"));
111+
while (1);
112+
}
113+
Serial.println(F("Survey started. This will run until 300s has passed and less than 2m accuracy is achieved."));
114+
}
115+
116+
while (Serial.available()) Serial.read(); //Clear buffer
117+
118+
lcd.clear();
119+
lcd.print(F("Survey in progress"));
120+
121+
//Begin waiting for survey to complete
122+
while (myGPS.svin.valid == false)
123+
{
124+
if (Serial.available())
125+
{
126+
byte incoming = Serial.read();
127+
if (incoming == 'x')
128+
{
129+
//Stop survey mode
130+
response = myGPS.disableSurveyMode(); //Disable survey
131+
Serial.println(F("Survey stopped"));
132+
break;
133+
}
134+
}
135+
136+
response = myGPS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)
137+
if (response == true)
138+
{
139+
Serial.print(F("Press x to end survey - "));
140+
Serial.print(F("Time elapsed: "));
141+
Serial.print((String)myGPS.svin.observationTime);
142+
143+
lcd.setCursor(0, 1);
144+
lcd.print(F("Elapsed: "));
145+
lcd.print((String)myGPS.svin.observationTime);
146+
147+
Serial.print(F(" Accuracy: "));
148+
Serial.print((String)myGPS.svin.meanAccuracy);
149+
Serial.println();
150+
151+
lcd.setCursor(0, 2);
152+
lcd.print(F("Accuracy: "));
153+
lcd.print((String)myGPS.svin.meanAccuracy);
154+
}
155+
else
156+
{
157+
Serial.println(F("SVIN request failed"));
158+
}
159+
160+
delay(1000);
161+
}
162+
Serial.println(F("Survey valid!"));
163+
164+
Serial.println(F("Base survey complete! RTCM now broadcasting."));
165+
lcd.clear();
166+
lcd.print(F("Transmitting RTCM"));
167+
}
168+
169+
void loop()
170+
{
171+
myGPS.checkUblox(); //See if new data is available. Process bytes as they come in.
172+
173+
//Do anything you want. Call checkUblox() every second. NEO-M8P-2 has TX buffer of 4k bytes.
174+
175+
delay(250); //Don't pound too hard on the I2C bus
176+
}
177+
178+
//This function gets called from the SparkFun Ublox Arduino Library.
179+
//As each RTCM byte comes in you can specify what to do with it
180+
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
181+
void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
182+
{
183+
//Let's just pretty-print the HEX values for now
184+
if (myGPS.rtcmFrameCounter % 16 == 0) Serial.println();
185+
Serial.print(" ");
186+
if (incoming < 0x10) Serial.print("0");
187+
Serial.print(incoming, HEX);
188+
}

0 commit comments

Comments
 (0)