GPS-RTK Hookup Guide
Setting Up A Base Station
If you’re located further than 20km from a correction station you can create your own station using the NEO-M8P-2. u-blox provides a great setup guide showing the various settings needed via u-center. We’ll be covering how to setup the GPS-RTK using I2C commands only. This will enable a headless (computerless) configuration of a base station that outputs RTCM correction data. You can watch a brief demo of this in the product video:
Before getting started we recommend you configure the module using u-center. Checkout our tutorial on using U-Center then read the u-blox datasheet on getting the NEO-M8P configured for RTK using U-Center. Once you’ve been successful controlling the module in the comfort of your lab, then consider heading outdoors.
For this exercise we’ll be using the following parts:
- SparkFun GPS-RTK Board
- SparkFun BlackBoard makes I2C easy
- microB Cable if you need one
- Antenna L1/L2 GNSS 3-5V Magnetic Mount
- GPS Antenna Ground Plate
- U.FL to SMA Cable
- Two Qwiic Cables
- 20x4 SerLCD with Qwiic Adapter soldered on
- 1x 20+ft SMA extension can be handy when first experimenting with base stations so you can sit indoors with a laptop and analyze the output of the GPS-RTK
- A standard camera tripod
The NEO-M8P-2 can be configured using Serial, SPI, or I2C. We’re fans of the daisychain-ability of I2C so we’ll be focusing on the Qwiic system. For this exercise we’ll be connecting the an LCD and GPS-RTK to a BlackBoard using two Qwiic cables.
For the antenna, you’ll need a clear view of the sky. The better your antenna position the better your accuracy and performance of the system. We designed the GPS Antenna Ground Plate to make this setup easy. The plate has a ¼” threaded hole that threads directly onto a camera tripod. The plate thickness was chosen to be thick enough so that the threaded screw is flush with the plate so it won’t interfere with the antenna. Not sure why we’re using a ground plate? Read the u-blox white paper on using low-cost GNSS antennas with RTK. Mount your magnetic mount antenna and run the SMA cable to the U.FL to SMA cable to the GPS-RTK board.
There are only three steps to initiating a base station:
- Enable Survey-In mode for 5 minutes (300 seconds)
- Enable RTCM output messages
- Begin transmitting the RTCM packets over the backhaul of choice
Be sure to grab the SparkFun u-blox GNSS Arduino Library. You can easily install this via the library manager by searching ‘SparkFun u-blox GNSS’. Once installed click on File->Examples->SparkFun_u-blox_GNSS_Arduino_Library
.
The NEO-M8P subfolder houses a handful of sketches specific to its setup. Example3 demonstrates how to send the various commands to the GPS-RTK to enable Survey-In mode. Let’s discuss the important bits of code.
language:c
response = myGNSS.enableSurveyMode(300, 2.000); //Enable Survey in, 300 seconds, 2.0m
The library is capable of sending UBX binary commands with all necessary headers, packet length, and CRC bytes over I2C. The enableSurveyMode(minimumTime, minimumRadius)
command does all the hard work to tell the module to go into survey mode. The module will begin to record lock data and calculate a 3D standard deviation. The survey-in process ends when both the minimum time and minimum radius are achieved. u-blox recommends 300 seconds (5 minutes) and a radius of 2m. With a clear view of the sky, with a low cost GNSS antenna mounted to a ground plate we’ve seen the survey complete at 301 seconds with a radius of around 1.5m.
language:c
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1005, UBX_RTCM_I2C_PORT, 1); //Enable message 1005 to output through I2C port, message every second
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1077, UBX_RTCM_I2C_PORT, 1);
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1087, UBX_RTCM_I2C_PORT, 1);
response &= myGNSS.enableRTCMmessage(UBX_RTCM_1230, UBX_RTCM_I2C_PORT, 10); //Enable message every 10 seconds
These four lines enable the four RTCM output messages needed for a second GPS-RTK to receive correction data. Once these sentences have been enabled (and assuming a survey process is complete) the GPS-RTK base module will begin outputting RTCM data every second after the NMEA sentences (the RTCM_1230 sentence will be output once every 10 seconds). You can view an example of what this output looks like here.
The size of the RTCM correction data varies but in general it is approximately 350 bytes every second (~500 bytes every 10th second when 1230 is transmitted).
language:c
//This function gets called from the SparkFun u-blox GNSS Arduino Library.
//As each RTCM byte comes in you can specify what to do with it
//Useful for passing the RTCM correction data to a radio, Ntrip broadcaster, etc.
void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
{
//Let's just pretty-print the HEX values for now
if (myGNSS.rtcmFrameCounter % 16 == 0) Serial.println();
Serial.print(" ");
if (incoming < 0x10) Serial.print("0");
Serial.print(incoming, HEX);
}
If you have a ‘rover’ in the field in need of correction data you’ll need to get the RTCM bytes to the rover. The SparkFun u-blox library automatically detects the difference between NMEA sentences and RTCM data. The processRTCM()
function allows you to ‘pipe’ just the RTCM correction data to the channel of your choice. Once the base station has completed the survey and has the RTCM messages enabled, your custom processRTCM()
function can pass each byte to any number of channels:
- A wireless system such as LoRa or Cellular
- Posting the bytes over the internet using WiFi or wired ethernet over an Ntrip caster
- Over a wired solution such as RS485
The power of the processRTCM()
function is that it doesn’t care; it presents the user with the incoming byte and is agnostic about the back channel.
What about configuring the rover? u-blox designed the NEO-M8P to automatically go into RTK mode once RTCM data is detected on any of the ports. Simply push the RTCM bytes from your back channel into one of the ports (UART, SPI, I2C) on the rover's GPS-RTK and the location accuracy will go from meters to centimeters. The rover's NMEA messages will contain the improved Lat/Long data and you'll know where you are with mind-bending accuracy. It’s a lot of fun to watch!