4G GNSS-RTK High Precision Positioning Kit

1. Introduction

This is an RTK high-precision positioning kit that supports multiple satellite systems and uses a 4G module to connect to the internet for obtaining positioning correction data. The GNSS module simultaneously supports receiving signals from GNSS, GPS, GLONASS, Galileo, BDS, and QZSS satellites, and can track GPS L1 C/A, GLONASS L1, Galileo E1, BDS B11, QZSS L1 C/A, GPS L5, Galileo E5a, BDS B2a, and QZSS L5 frequency bands. Compared to traditional RTK positioning kits, it offers more flexible usage and achieves a wider RTK positioning range, typically covering 15~20km.

The kit uses the Ntrip protocol to obtain RTCM correction data. Before use, you need to prepare a CORS account and a 4G SIM card. Please check the coverage of local CORS services in advance. Currently, domestic CORS services basically cover most urban areas in China.

The kit outputs data information through a Gravity interface, which can be switched between I2C and UART modes, making it compatible with main controllers like Arduino, ESP32, and Raspberry Pi. As an entry-level high-precision positioning kit, it does not involve complex data linking processes, making it very suitable for applications such as high-precision positioning for remote-controlled cars, item tracking, and trajectory acquisition.

Note: Due to weak satellite signals indoors and severe obstruction affecting the antenna's satellite acquisition quality, it can only be used in relatively open outdoor areas. During the first power-on, since the 4G module initialization and GNSS antenna satellite acquisition require a process, it is necessary to wait a few minutes after powering on to obtain RTK positioning information.

2. Appearance and Interfaces

Front Interface
Front Interface

Name Description
UART⇄I2C UART/I2C Output Mode Switch
PWR IN 5~12V External Power Supply Terminal(DC 5~12V)
RTK RTK Status Indicator Light, blinks once per second for positioning status value 5; steady on for status value 4; off for other statuses.
PWR Power Indicator Light - when powered via Type-C or PWR IN
Type-C Type-C Power Supply Interface

Nano SIM
Nano SIM

Name Description
Nano SIM Nano SIM Card Slot

During installation, align the SIM card with its metal chip face down towards the slot. Use the included screwdriver to gently press down until you hear a clear "click" sound, indicating successful locking.
For removal, also use the included screwdriver to gently press down. Once it pops up, use the side of the screwdriver to pry it out (repeated removal is not recommended unless necessary).

This side faces down during installation

Gravity Interface
Gravity Interface

Name Description
Gravity I2C&UART Data Output Gravity Interface

Antenna Interfaces
Antenna Interfaces

Name Description
4G 4G Antenna SMA Interface
GNSS GNSS Antenna SMA Interface

3. Positioning Principle

3.1 RTK Positioning Principle

3.1.1 Ntrip Protocol

Definition
NTRIP (Networked Transport of RTCM via Internet Protocol) is an internet-based protocol specifically designed for the real-time transmission of differential GNSS (Global Navigation Satellite System) data. It is primarily used to transmit RTCM (Radio Technical Commission for Maritime Services) format differential correction data (e.g., for GPS, GLONASS, etc.) from a reference station to a rover (such as surveying equipment, drones, autonomous driving systems, etc.) to improve positioning accuracy (from meter-level to centimeter-level).

Components

  • NTRIP Client: The terminal device (e.g., GNSS receiver) that receives the differential data.
  • NTRIP Server: Stores and distributes differential data from reference stations.
  • NTRIP Caster: The core intermediary server responsible for coordinating the connection between clients and servers, acting like a "router".
  • Mount Point: A unique identifier for a data stream; clients subscribe to specific data sources (e.g., data from a particular reference station) through it.

Working Principle

  • Based on the HTTP/HTTPS protocol, using long connections (Keep-Alive) to achieve real-time data transmission.
  • The client sends an HTTP request to the Caster, specifying the target Mount Point. The Caster then continuously pushes the corresponding RTCM data stream to the client.
  • Supports authentication (e.g., username/password) to ensure secure data access.

Characteristics

  • Low Latency: Suitable for scenarios requiring high real-time performance (e.g., autonomous driving).
  • Cross-Network Compatibility: Utilizes the HTTP protocol to penetrate firewalls, adapting to complex network environments.
  • Flexibility: Supports unicast (point-to-point) and multicast (one-to-many) transmission modes.
  • Standardized Data Format: Uses the RTCM SC-104 standard (commonly version RTCM 3.x), ensuring device compatibility.

3.1.2 Common CORS Service Providers and Positioning Accuracy

Please understand the coverage of the CORS service before purchasing the equipment, and make sure you can obtain a CORS account service; otherwise, you will not be able to get RTK positioning data after receiving the equipment.

3.2 Positioning Principle Overview and Flowchart

In a large area, multiple base stations (three or more) are evenly distributed to form a reference station network. They send data to a central server. The central server simulates a "virtual reference station" based on this data. The user, using a fixed CORS account, employs the 4G network and Ntrip protocol to broadcast the data from this "virtual reference station" in real-time to the rover. The rover performs real-time differential calculations to eliminate common errors, thereby achieving centimeter-level accuracy RTK positioning.

3.3 Advantages and Disadvantages of Network RTK

Network RTK has significant advantages, mainly reflected in utilizing widely distributed mobile communication base stations as reference stations, achieving seamless coverage, and using the built-in 4G module for efficient communication between the rover and the central server. Users do not need to build their own reference stations, reducing costs, and only need to pay communication fees. Meanwhile, due to the large number of reference stations, even if some are damaged, it does not affect the overall accuracy and reliability.

However, in the Network RTK model, network stability greatly impacts positioning accuracy. Stable network communication must be ensured to guarantee stable delivery of differential data, enabling ultra-high positioning accuracy.

3.4 Common Application Scenarios

  • Surveying and Geographic Information Collection: Improving the accuracy of field measurements.
  • Precision Agriculture: Autonomous driving of agricultural machinery and variable rate fertilization.
  • UAV Navigation: Achieving centimeter-level positioning for aerial photography or inspection.
  • Intelligent Transportation Systems: High-precision vehicle positioning and lane-level navigation.

3.5 NMEA Data Parsing

Modules output NMEA 0183 messages (e.g., RMC, GGA). Example GGA data:
$GNGGA,063924.000,3037.643956,N,10348.010829,E,5,34,0.46,507.909,M,-32.181,M,1.0,3335*76

Field Name Description Example
0 Identifier Start character ($) $
1 System $GP (GPS), $GL (GLONASS), $GN (GNSS) $GNGGA
2 Sentence ID GGA (Global Positioning System Fix Data) GGA
3 UTC Time hhmmss.sss 063924.000
4 Latitude ddmm.mmmmmm 3037.643956
5 N/S Indicator N (North), S (South) N
6 Longitude dddmm.mmmmmm 10348.010829
7 E/W Indicator E (East), W (West) E
8 Position Fix 0=Invalid, 1=GPS, 2=DGPS, 4=RTK Fixed, 5=RTK Float 5
9 Satellites Used Number of satellites 34
10 HDOP Horizontal Dilution of Precision (lower = better) 0.46
11 MSL Altitude Meters above Mean Sea Level 507.909
12 Units M (meters) M
13 Geoid Separation Geoid height above/below WGS84 ellipsoid (m) -32.181
14 Separation Units M (meters) M
15 Differential Age Age of RTK corrections (valid for RTK only) 1.0
16 Base Station ID Reference station ID 3335
17 Checksum * + hex value *76

Full NMEA 0183 Reference

3.5 Common Coordinate System Comparison

Coordinate System CGCS2000 Coordinate System WGS84 Coordinate System ITRF2008 Coordinate System
Regionality China Global Global
Accuracy High (within China region) Medium Highest
Reference Frame Based on ITRF, optimized for China region Based on ITRF, continuously updated Based on global space geodetic techniques
Application Within China, GIS, navigation, etc GPS, global navigation, map services, etc cientific research, high-precision positioning, coordinate system reference
Maintaining Body National Administration of Surveying, Mapping and Geoinformation (now Ministry of Natural Resources), China National Geospatial-Intelligence Agency (NGA), USA International Earth Rotation and Reference Systems Service (IERS)
Relationship with ITRF Closely related to ITRF, but with regional adjustments Closely related to ITRF, continuously updated to maintain consistency Itself is a realization of ITRF, serves as the reference frame

4. Product Features

  • 4G Communication, Ntrip protocol for data transmission
  • Wide coverage (typically 15~20km, depends on different CORS service providers' coverage)
  • Uniform and reliable accuracy
  • Centimeter-level positioning accuracy (slight variations among different manufacturers)

5. Product Performance Parameters

  • Power Supply Interface: Gravity interface, 3.3~5V
  • Type-C: Power supply for 4G module (requires separate power supply)
  • Output Signal: I2C/UART
  • Antenna Interface: SMA
  • Reception Bands:
  • GPS/QZSS: L1 C/A, L5
  • GLONASS: L1
  • Galileo: E1, E5a
  • BDS: B11, B2a
  • Default Constellations: GPS+GLONASS+Galileo+BDS+QZSS
  • Concurrent Reception Constellations: 4+QGNSS
  • SBAS: WAAS, EGNOS, MSAS, GAGAN
  • Function: RTK
  • Horizontal Positioning Accuracy:
  • Autonomous: 1m
  • RTK: 5cm+1ppm
  • Velocity Accuracy: 0.03m/s
  • 1PPS Accuracy: 20ns
  • RTK Convergence Time: RTK < 10s
  • Sensitivity:
  • Acquisition: -145dBm
  • Tracking: -165dBm
  • Reacquisition: -157dBm
  • Dynamic Performance:
  • Maximum Altitude: 10000m
  • Maximum Velocity: 500m/s
  • Maximum Acceleration: 4g
  • Navigation Update Rate: RTK: 1Hz
  • Raw Data Update Rate: GNSS: 1Hz
  • Protocols: NMEA 0183 / RTCM 3.x
  • Weight: Aboutt 380g
  • Supported Countries/Regions: EMEA & Thailand

# 6. User Guide

6.1 Arduino IDE User Guide

6.1.1 Hardware preparation

6.1.2 Software preparation

6.1.3 API

/**
 * @fn getUTC
 * @brief Get UTC, standard time 
 * @return sTim_t type, represents the returned hour, minute and second 
 * @retval sTim_t.hour hour 
 * @retval sTim_t.minute minute 
 * @retval sTim_t.second second 
 */
  sTim_t getUTC(void);

/**
 * @fn getDate
 * @brief Get date information, year, month, day 
 * @return sTim_t type, represents the returned year, month, day 
 * @retval sTim_t.year year
 * @retval sTim_t.month month 
 * @retval sTim_t.day day 
 */
  sTim_t getDate(void);

/**
 * @fn getLat
 * @brief Get latitude 
 * @return sLonLat_t type, represents the returned latitude  
 * @retval sLonLat_t.latDD   Latitude degree(0-90)
 * @retval sLonLat_t.latMM   The first and second digits behind the decimal point 
 * @retval sLonLat_t.latMMMMM Latitude  The third and seventh digits behind the decimal point 
 * @retval sLonLat_t.latitude Latitude value with 7 decimal digits
 * @retval sLonLat_t.latDirection Direction of latitude
 */
  sLonLat_t getLat(void);

/**
 * @fn getLon
 * @brief Get longitude 
 * @return sLonLat_t Type, represents the returned longitude
 * @retval sLonLat_t.lonDDD  Longitude degree(0-90)
 * @retval sLonLat_t.lonMM   Longitude  The first and second digits behind the decimal point
 * @retval sLonLat_t.lonMMMMM Longitude The third and seventh digits behind the decimal point
 * @retval sLonLat_t.lonitude Longitude value with 7 decimal digits
 * @retval sLonLat_t.lonDirection Direction of longitude 
 */
  sLonLat_t getLon(void);

/**
 * @fn getNumSatUsed
 * @brief Get the number of the used satellite used
 * @return uint8_t type, represents the number of the used satellite
 */
  uint8_t getNumSatUsed(void);

/**
 * @fn getAlt
 * @brief Altitude information
 * @return double type, represents altitude 
 */
  double getAlt(void);

/**
 * @fn getSep
 * @brief At the height of geoid
 * @return double 
 */
  double getSep(void);

/**
 * @fn getHdop
 * @brief Indicates the horizontal accuracy of positioning
 * @return double
 */
  double getHdop(void);

/**
 * @fn getQuality
 * @brief message Quality
 * @return uint8_t 
 */
  uint8_t getQuality(void);

/**
 * @fn getSiteID
 * @brief The site id of differential gps data, commonly used for differential gps positioning
 * @return uint16_t
 */
  uint16_t getSiteID(void);

/**
 * @fn getDifTime
 * @brief The number of seconds in which a differential signal was last received
 * @return double 
 */
  double getDifTime(void);

/**
 * @fn getDataFlush
 * @brief Gets whether data is refreshed
 * @return bool
 * @retval True if data is refreshed
 * @retval false if data is not refreshed
 */
  bool getDataFlush(void);

/**
 * @fn setModule
 * @brief Set the Module
 * @param mode 4G or lora
 */
  void setModule(eModuleMode_t mode);

/**
 * @fn getModule
 * @brief Get the Module run mode
 * @return eModuleMode_t 
 */
  eModuleMode_t getModule(void);

  /**
   * @fn transmitAT
   * @brief Interface for transparent transmission of gnss commands
   * @return char * return commands
   */
  char * transmitAT(const char* cmd);

/**
 * @fn getGnssMessage
 * @brief Get different types of gps data
 * @param mode eGnssData_t type
 * @return char* 
 */
  char * getGnssMessage(eGnssData_t mode);

/**
 * @fn getAllGnss
 * @brief Get GNSS data, call back and receive
 * @return null
 */
  void getAllGnss(void);

/**
 * @fn setModuleBaud
 * @brief Set the Module Baud rate
 * @param baud eModuleBaud_t
 */
  void setModuleBaud(eModuleBaud_t baud);

/**
 * @fn set4gBaud
 * @brief Set the receive 4g Baud rate
 * @param baud eModuleBaud_t
 */
  void set4gBaud(eModuleBaud_t baud);

/**
 * @fn setLoraBaud
 * @brief Set the recevie Lora Baud rate
 * @param baud eModuleBaud_t
 */
  void setLoraBaud(eModuleBaud_t baud);

/**
 * @fn getModuleBaud
 * @brief Get the Module Baud rate
 * @return uint32_t Baud rate of serial communication
 */
  uint32_t getModuleBaud(void);

/**
 * @fn getLoraBaud
 * @brief Get the Lora Baud rate
 * @return uint32_t Baud rate of serial communication
 */
  uint32_t getLoraBaud(void);

/**
 * @fn get4gBaud
 * @brief Get the 4G Baud rate
 * @return uint32_t Baud rate of serial communication
 */
  uint32_t get4gBaud(void);

/**
 * @fn setUserName
 * @brief Set the 4G User Name
 * @param name user name eg:"chw123456789"
 * @param len name length
 */
  void setUserName(const char *name, uint8_t len);

/**
 * @fn setUserPassword
 * @brief Set the 4G User Password
 * @param password eg:"12345678"
 * @param len password length
 */
  void setUserPassword(const char *password, uint8_t len);

/** 
 * @fn setServerAddr
 * @brief Set the Server Addr
 * @param addr ip address eg: "192.168.1.1"
 * @param len addr length
 */
  void setServerAddr(const char *addr, uint8_t len);

/**
 * @fn setServerAddr
 * @brief set Mount Point
 * @param point eg:"RTCM33"
 * @param len point length
 */
  void setMountPoint(const char *point, uint8_t len);

/**
 * @fn setPort
 * @brief Set the Port
 * @param port eg: 8002
 */
  void setPort(uint16_t port);

/**
 * @fn connect
 * @brief connect 
 * @return String connect state
 */
  String connect(void);

/**
 * @fn getConnectState
 * @brief get connect state
 * @return true or false
 */
  bool getConnectState(void);

/**
 * @fn reConnect
 * @brief re connect
 */
  void reConnect(void);

/**
 * @fn setCallback
 * @brief Set callback function type
 * @param  call function name 
 * @return null
 */
  void setCallback(void (*call)(char *, uint8_t));

6.1.4 Reading NMEA Data via I2C Protocol

Wiring Diagram
I2C-R3

  • Take out the product and connect the rover to the Arduino according to the wiring diagram above.
  • Move the selection switch on the rover to the I2C side.
  • Download and install the RTK library.
  • Purchase a CORS account and modify the CORS account, password, server address, mount point, and port number. You need to modify these yourself.
#define  USER_NAME      "xxx"
#define  USER_PASSWORD  "xxxx"
#define  SERVER_ADDR    "xxx.x.xxx.xxx"
#define  MOUNT_POINT    "RTCMxx"
uint16_t port = 8002;
  • Upload Code
    Place the device in an open outdoor area. Open the Arduino IDE Serial Monitor, set the baud rate to 115200, and observe the serial print results.
 /*!
  * @file  getAllGnss4G.ino
  * @brief read all rtk data at 4G mode
  * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  * @license The MIT License (MIT)
  * @author ZhixinLiu([email protected])
  * @version V0.5.0
  * @date 2024-10-28
  * @url https://github.com/DFRobot/DFRobot_RTK_4G
  */

#include "DFRobot_RTK_4G.h"

void callback(char *data, uint8_t len)
{
  for(uint8_t i = 0; i < len; i++){
    Serial.print((char)data[i]);
  }
}

#define I2C_COMMUNICATION  //use I2C for communication, but use the serial port for communication if the line of codes were masked

#ifdef  I2C_COMMUNICATION
  DFRobot_RTK_4G_I2C rtk(&Wire ,DEVICE_ADDR);
#else
/* -----------------------------------------------------------------------------------------------------
 * |  Sensor  | Connect line | Leonardo/Mega2560/M0 |    UNO    | ESP8266 | ESP32 |  microbit  |   m0  |
 * |   VCC    |=============>|        VCC           |    VCC    |   VCC   |  VCC  |     X      |  vcc  |
 * |   GND    |=============>|        GND           |    GND    |   GND   |  GND  |     X      |  gnd  |
 * |   RX     |=============>|     Serial1 TX1      |     5     |   5/D6  |  D2   |     X      |  tx1  |
 * |   TX     |=============>|     Serial1 RX1      |     4     |   4/D7  |  D3   |     X      |  rx1  |
 * ----------------------------------------------------------------------------------------------------*/
/* Baud rate cannot be changed  */
  #if defined(ARDUINO_AVR_UNO) || defined(ESP8266)
    SoftwareSerial mySerial(4, 5);
    DFRobot_RTK_4G_UART rtk(&mySerial, 57600);
  #elif defined(ESP32)
    DFRobot_RTK_4G_UART rtk(&Serial1, 115200 ,/*rx*/D2 ,/*tx*/D3);
  #else
    DFRobot_RTK_4G_UART rtk(&Serial1, 115200);
  #endif
#endif


#define  USER_NAME      "maplays7874"
#define  USER_PASSWORD  "79546"
#define  SERVER_ADDR    "103.45.160.41"
#define  MOUNT_POINT    "RTCM33GRCEJpro"
uint16_t port = 8002;
String   result = "";

void setup()
{
  Serial.begin(115200);
  while(!rtk.begin()){
    Serial.println("NO Deivces !");
    delay(1000);
  }
  Serial.println("Device connected !");

  rtk.setModule(eMoudle4g);
  while(rtk.getModule() != eMoudle4g){
    Serial.println("Module type is not 4G!  please wait!");
    delay(1000);
  }
  rtk.setUserName(USER_NAME, strlen(USER_NAME));
  rtk.setUserPassword(USER_PASSWORD, strlen(USER_PASSWORD));
  rtk.setServerAddr(SERVER_ADDR, strlen(SERVER_ADDR));
  rtk.setMountPoint(MOUNT_POINT, strlen(MOUNT_POINT));
  rtk.setPort(port);
  Serial.println("please wait 4g module init!");
  Serial.println("connecting network please wait !");
  result = rtk.connect();
  if((String)"CONNECT SUCCESSFUL" == result){
    Serial.println("connect success");
  }else{
    Serial.println(result);
  }

  rtk.setCallback(callback);
}

void loop()
{
  // Please note that there is no judgment of timeout reconnection for the 4G module here
  rtk.getAllGnss();
  if(!rtk.getConnectState()){
    Serial.println("restart connect .....");
    rtk.reConnect();
  }
}

For more advanced data analysis, please refer to the Standard Messages section (2.2) of the NMEA 0183 Protocol Standard.

6.1.5 Reading Data via UART

6.1.5.1 Modifying the Baud Rate

Note: If using an Arduino UNO, it is necessary to employ the configparam example routine within the library file. First, switch the module to I2C mode to configure the rover module's baud rate and modify it to 57600. Using boards with multiple hardware UART interfaces like the MEGA2560 or ESP32 does not require this baud rate modification step.

Wiring Diagram

I2C-R3
  • Connect the module to the Arduino according to the wiring diagram above.
  • Move the selection switch on the sensor to the I2C side. (Note: Text says I2C, but wiring and context suggest UART preparation. Possibly means use I2C first for configuration).
  • Open Arduino IDE, upload the code below to Arduino UNO.
  • Open the Arduino IDE Serial Monitor, set the baud rate to 57600, and observe the serial print results.
  • Note: Configuration mode only supports I2C mode. Running this example requires switching to I2C.
    Parameter Configuration Example Code
  /*!
  * @file  configParam.ino
  * @brief config moudle param
  * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  * @license The MIT License (MIT)
  * @author ZhixinLiu([email protected])
  * @version V0.5.0
  * @date 2024-04-24
  * @url https://github.com/DFRobot/DFRobot_RTK_LoRa
  */

#include "DFRobot_RTK_LoRa.h"

// must use iic config parameter
DFRobot_RTK_LoRa_I2C rtk(&Wire ,DEVICE_ADDR);
void setup()
{
  Serial.begin(115200);
  while(!rtk.begin()){
    Serial.println("NO Deivces !");
    delay(1000);
  }
  Serial.println("Device connected !");

  /**
   * | Support Baud | UNO/ESP8266 | Leonardo/Mega2560 | ESP32 |  M0 |
   * | eBaud9600    |      √      |         √         |   √   |  √  |
   * | eBaud14400   |      √      |         √         |   √   |  √  |
   * | eBaud19200   |      √      |         √         |   √   |  √  |
   * | eBaud38400   |      √      |         √         |   √   |  √  |
   * | eBaud56000   |      √      |         √         |   √   |  √  |
   * | eBaud57600   |      √      |         √         |   √   |  √  |
   * | eBaud115200  |             |         √         |   √   |  √  |
   * | eBaud256000  |             |                   |   √   |  √  |
   * | eBaud512000  |             |                   |   √   |  √  |
   * | eBaud921600  |             |                   |   √   |  √  |
   */
  rtk.setModuleBaud(eBaud115200);

  Serial.print("module mode = ");
  Serial.println(rtk.getModule());

  Serial.print("moudle buad = ");
  Serial.println(rtk.getModuleBaud());
}

void loop()
{
  // Reserved interface, direct communication with gnss firmware, use with the original factory data manual
  Serial.println(rtk.transmitAT("$PQTMVERNO*58\r\n"));
  delay(2000);
}

6.1.5.2 Obtaining Latitude, Longitude, and Positioning Status via UART Mode

Connection Diagram

UART-R3
  • Take out the product and connect the rover to the Arduino according to the wiring diagram above.
  • Move the selection switch on the rover to the UART side.
  • Download and install the RTK_4G library
#define  USER_NAME      "xxx"
#define  USER_PASSWORD  "xxxx"
#define  SERVER_ADDR    "xxx.x.xxx.xxx"
#define  MOUNT_POINT    "RTCMxx"
uint16_t port = 8002;

  • Purchase a CORS account and modify the CORS account, password, server address, mount point, and port number. You need to modify these yourself.

UART Example Code

 /*!
  * @file  getGnss4G.ino
  * @brief Get gnss simple data at 4G mode
  * @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  * @license The MIT License (MIT)
  * @author ZhixinLiu([email protected])
  * @version V0.5.0
  * @date 2024-10-28
  * @url https://github.com/DFRobot/DFRobot_RTK_4G
  */

#include "DFRobot_RTK_4G.h"

#define I2C_COMMUNICATION  //use I2C for communication, but use the serial port for communication if the line of codes were masked

#ifdef  I2C_COMMUNICATION
  DFRobot_RTK_4G_I2C rtk(&Wire ,DEVICE_ADDR);
#else
/* -----------------------------------------------------------------------------------------------------
 * |  Sensor  | Connect line | Leonardo/Mega2560/M0 |    UNO    | ESP8266 | ESP32 |  microbit  |   m0  |
 * |   VCC    |=============>|        VCC           |    VCC    |   VCC   |  VCC  |     X      |  vcc  |
 * |   GND    |=============>|        GND           |    GND    |   GND   |  GND  |     X      |  gnd  |
 * |   RX     |=============>|     Serial1 TX1      |     5     |   5/D6  |  D2   |     X      |  tx1  |
 * |   TX     |=============>|     Serial1 RX1      |     4     |   4/D7  |  D3   |     X      |  rx1  |
 * ----------------------------------------------------------------------------------------------------*/
/* Baud rate cannot be changed */
  #if defined(ARDUINO_AVR_UNO) || defined(ESP8266)
    SoftwareSerial mySerial(4, 5);
    DFRobot_RTK_4G_UART rtk(&mySerial, 57600);
  #elif defined(ESP32)
    DFRobot_RTK_4G_UART rtk(&Serial1, 115200 ,/*rx*/D2 ,/*tx*/D3);
  #else
    DFRobot_RTK_4G_UART rtk(&Serial1, 115200);
  #endif
#endif

#define  USER_NAME      "chwj068746"
#define  USER_PASSWORD  "16409678"
#define  SERVER_ADDR    "119.3.136.126"
#define  MOUNT_POINT    "RTCM33"
uint16_t port = 8002;
String   result = "";
void setup()
{
  Serial.begin(115200);
  while(!rtk.begin()){
    Serial.println("NO Deivces !");
    delay(1000);
  }
  Serial.println("Device connected !");
  rtk.setModule(eMoudle4g);
  while(rtk.getModule() != eMoudle4g){
    Serial.println("Module type is not 4G!  please wait!");
    delay(1000);
  }

  rtk.setUserName(USER_NAME, strlen(USER_NAME));
  rtk.setUserPassword(USER_PASSWORD, strlen(USER_PASSWORD));
  rtk.setServerAddr(SERVER_ADDR, strlen(SERVER_ADDR));
  rtk.setMountPoint(MOUNT_POINT, strlen(MOUNT_POINT));
  rtk.setPort(port);
  Serial.println("please wait 4g module init!");
  Serial.println("connecting network please wait !");
  result = rtk.connect();
  if((String)CONNECT_SUCCESS == result){
    Serial.println("connect success");
  }else{
    Serial.println(result);
  }
  
}

void loop()
{
  bool state = rtk.getDataFlush();
  if(state == true){
    sTim_t utc = rtk.getUTC();
    sTim_t date = rtk.getDate();
    sLonLat_t lat = rtk.getLat();
    sLonLat_t lon = rtk.getLon();
    double high = rtk.getAlt();
    uint8_t starUserd = rtk.getNumSatUsed();
    double hdop = rtk.getHdop();
    double sep = rtk.getSep();
    uint8_t mode = rtk.getQuality();
    uint16_t siteID = rtk.getSiteID();
    double diftime = rtk.getDifTime();

    Serial.println("");
    Serial.print(date.year);
    Serial.print("/");
    Serial.print(date.month);
    Serial.print("/");
    Serial.print(date.date);
    Serial.print("/");
    Serial.print(utc.hour);
    Serial.print(":");
    Serial.print(utc.minute);
    Serial.print(":");
    Serial.print(utc.second);
    Serial.println();
    Serial.println((char)lat.latDirection);
    Serial.println((char)lon.lonDirection);
    
    // Serial.print("lat DDMM.MMMMM = ");
    // Serial.println(lat.latitude, 5);
    // Serial.print(" lon DDDMM.MMMMM = ");
    // Serial.println(lon.lonitude, 5);
    Serial.print("lat degree = ");
    Serial.println(lat.latitudeDegree,6);
    Serial.print("lon degree = ");
    Serial.println(lon.lonitudeDegree,6);

    Serial.print("star userd = ");
    Serial.println(starUserd);
    Serial.print("alt high = ");
    Serial.println(high);
    Serial.print("sep  = ");
    Serial.println(sep);

    Serial.print("hdop = ");
    Serial.println(hdop);
    Serial.print("message mode  = ");
    Serial.println(mode);
    Serial.print("siteID = ");
    Serial.println(siteID);
    Serial.print("diftime = ");
    Serial.println(diftime);
    Serial.println(rtk.getGnssMessage(eGGA));
    Serial.println(rtk.getGnssMessage(eRMC));
    Serial.println(rtk.getGnssMessage(eGLL));
    Serial.println(rtk.getGnssMessage(eVTG));
  }
  if(!rtk.getConnectState()){
    Serial.println("restart connect .....");
    rtk.reConnect();
  }
  delay(800);
}

Results and Parsing

Name meaning remark
N North Latitude Hemisphere
E East Longitude Hemisphere
lat degree Latitude
lon degree Longitude
star Number of satellites Include GNSS,GPS,GLONASS,Galileo,BDS
alt high Meters above Mean Sea Level
sep Geoid height above/below WGS84 ellipsoid (m) Positive: the geoid is higher than the ellipsoid; Negative: The geoid is below the ellipsoid
hdop Horizontal Dilution of Precision (lower = better)
message mode Positioning status 0=Invalid, 1=GPS, 2=DGPS, 4=RTK Fixed, 5=RTK Float
siteID Reference station ID Only RTK fixed interpretations or floating-point solutions are valid
diftime Age of RTK corrections (valid for RTK only) Only RTK fixed interpretations or floating-point solutions are valid
$GNGGA NMEA Message Please refer to the NMEA Data Resolution section
$GNRMC NMEA Message Please refer to the NMEA Data Resolution section
$GNGLL NMEA Message Please refer to the NMEA Data Resolution section
$GNVTG NMEA Message Please refer to the NMEA Data Resolution section
$GNGGA NMEA Message Please refer to the NMEA Data Resolution section

6.2 Raspberry Pi User Guide

6.2.1 Hardware preparation

6.2.2 Software Preparation

6.2.3 I2C Usage Tutorial

Wiring Diagram
I2C-Raspberry Pi

Before use, confirm the I2C rate is 400k. Configure as follows:

sudo vi /boot/firmware/config.txt    # Modify configuration file
sudo reboot    # Reboot Raspberry Pi after saving changes to take effect

If dtparam=i2c_arm=on already exists, just add ,i2c_arm_baudrate=400000 to the same line.

Download the library file and run it. The default is I2C mode

Move the hardware mode switch to the I2C mode. Note: When toggling the DIP switch, the device is powered on. Please power cycle the device after switching for the change to take effect.

# Create directory and get library file
cd ~
cd Desktop
mkdir df

# Create folder
cd df

# Switch to folder
git clone https://github.com/DFRobot/DFRobot_RTK_4G.git # Note: Corrected URL cdja/DFROb0t to DFRobot

# Get library file
cd DFRobot_RTK_4G/python/raspberrypi/examples # Note: Corrected DFROb0t to DFRobot

# Switch to example file
sudo python3 get_gnss_4g.py # Note: Assuming filename is get_gnss_4g.py

6.2.4 UART Tutorial

Wiring Diagram

I2C-UART

Change to UART Mode

# Create directory and get library file
cd ~
cd Desktop
mkdir df

# Create folder
cd df

# Switch to folder
git clone https://github.com/DFRobot/DFRobot_RTK_4G.git # Note: Corrected URL cdjq/DFRobot to DFRobot

# Get library file
cd DFRobot_RTK_4G/python/raspberrypi/examples

# Switch to example file
sudo vi get_gnss_4g.py # Edit the file to change mode

Move the hardware DIP switch to the UART mode. Note: When toggling the DIP switch, the device is powered on. Please power cycle the device after switching for the change to take effect.

sudo python3 get_gnss_4g.py

7. Usage Notes

  1. When using, powering solely through the Gravity interface may lead to insufficient power for the 4G module, causing communication failures. It is recommended to use the Type-C interface or the terminal block for additional power supply.

  2. Due to weak satellite signals indoors and severe obstruction affecting the antenna's satellite acquisition quality, it can only be used in relatively open outdoor areas.

  3. During the first power-on, since the 4G module initialization and GNSS antenna satellite acquisition require a process, it is necessary to wait a few minutes after powering on to obtain RTK positioning information.

  4. When switching the I2C/UART output mode, power off and then on again for the change to take effect.

  5. (Note: Item 5 is empty in the original)

8. Related Materials

schematic.zip
Full NMEA 0183 Reference