Parsing GPS NMEA Data Format and Introduction to GPS/BeiDou Dual-Mode Module TD3020C
- 22 May, 2020
NMEA Data Format
NMEA-0183 is a standard protocol that GPS receivers should comply with and is currently the most widely used protocol for GPS receivers worldwide. Most GPS receivers, including BeiDou modules, adhere to or at least are compatible with this protocol.
The standard format definition for NMEA sentences is as follows:
- $
,,,…,* [CR][LF] - The sentence type identifier consists of two parts: sentence identifier + sentence format specifier;
- BeiDou and GPS use different sentence identifiers. BeiDou’s identifier is
BD, while GPS’s isGP; - The subsequent sentence format specifiers are common. For example, both use
GGAfor position information andVTGfor ground speed information.
- BeiDou and GPS use different sentence identifiers. BeiDou’s identifier is
- Each different NMEA sentence contains multiple independently defined data fields, separated by commas;
- The
is calculated from all characters between $and*; CRandLFare standard carriage return and line feed characters.
In applications, whether using standard GPS modules or domestic BeiDou modules, the format and protocol of positioning information output by the module itself essentially comply with the NMEA-0183 standard (with only slight differences in sentence identifiers):

On the hardware side, most GPS, BeiDou, and dual-mode modules output these NMEA sentences via standard serial ports, making them easily compatible and replaceable at both hardware and software levels.
Common NMEA-0183 Sentences
The NMEA-0183 protocol defines many sentences, but the most commonly used and widely compatible ones include:
$GPGGA: Position information$GPGSA: Current satellite information$GPGSV: Visible satellite information$GPRMC: Recommended minimum specific GPS/Transit data$GPVTG: Ground speed information$GPGLL: Geographic position, latitude/longitude
For our applications using GPS or BeiDou modules, the primary functions we utilize are:
- Latitude and longitude for positioning;
- Speed and direction of motion information;
- Altitude;
- Time synchronization;
Therefore, for our applications, we only need to focus on and parse the following sentences output by the positioning module:
GGA: Latitude/longitude, GPS status, number of available satellites, altitude;RMC: Latitude/longitude, UTC time (accurate to milliseconds), magnetic variation;VTG: Speed and its direction;
The following link provides an NMEA data parsing library. You can try to use this library directly in your application to parse the required information, avoiding reinventing the wheel:
GPRMC/BDRMC
The structure of the RMC data frame and the definition of its fields are as follows:
- *$GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>hh[CR][LF]
<1>UTC Time,hhmmss(hours, minutes, seconds) format<2>Positioning status,A= Valid position,V= Invalid position<3>Latitudeddmm.mmmm(degrees, minutes) format (leading zeros are also transmitted)<4>Latitude hemisphere,N(Northern Hemisphere) orS(Southern Hemisphere)<5>Longitudedddmm.mmmm(degrees, minutes) format (leading zeros are also transmitted)<6>Longitude hemisphere,E(East longitude) orW(West longitude)<7>Ground speed (000.0~999.9knots, leading zeros are also transmitted)<8>Ground track (000.0~359.9degrees, referenced to true North, leading zeros are also transmitted)<9>UTC Date,ddmmyy(day, month, year) format<10>Magnetic variation (000.0~180.0degrees, leading zeros are also transmitted)<11>Magnetic variation direction,E(East) orW(West)<12>Mode indicator (output only by NMEA0183 version 3.00,A= Autonomous,D= Differential,E= Estimated,N= Data not valid)*: Sentence terminatorhh: XOR checksum of all ASCII characters between$and*[CR]: Carriage Return, end marker[LF]: Line Feed, end marker
Important information contained in RMC sentences includes: UTC time, latitude/longitude, positioning status, speed (in knots, requiring conversion to km/h) and its direction, magnetic variation, etc.;
- As can be seen, the RMC sentence generally contains most of the common information we are interested in;
- If speed information in km/h is required, the
GPVTGsentence can be parsed. This sentence contains speed information in both knots and km/h.
GPGGA/BDGGA
The structure of the GGA data frame and the definition of its fields are as follows:
- *$GPGGA,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,M,<10>,M,<11>,<12>xx
$GPGGA: Start prefix and sentence format description. For a BeiDou module, it would beBDGGA;<1>UTC Time, formathhmmss.sss;<2>Latitude, formatddmm.mmmm(leading zero will also be transmitted);<3>Latitude hemisphere,NorS(North or South latitude)<4>Longitude, formatdddmm.mmmm(leading zero will also be transmitted);<5>Longitude hemisphere,EorW(East or West longitude)<6>GPS Status:0= Fix not available or invalid,1= GPS SPS Mode, Fix Valid,2= Differential GPS, SPS Mode, Fix Valid,3= PPS Fix (not supported),4= Real Time Kinematic,5= Float RTK,6= Estimated (DR) mode,7= Manual input mode,8= Simulation mode,9= WAAS differential<7>Number of satellites in use,00to12(leading zero will also be transmitted)<8>HDOP (Horizontal Dilution of Precision),0.5to99.9. Generally, a smaller HDOP indicates better quality.<9>Altitude,-9999.9to9999.9metersMindicates altitude unit is meters<10>Geoid separation,-9999.9to9999.9meters (difference between WGS-84 earth ellipsoid and mean sea level)Mindicates unit is meters<11>Age of differential GPS data (RTCM SC-104), time in seconds since last SC-104 Type 1 or 9 update, empty if not differential positioning<12>Differential reference station ID,0000to1023(leading zero will also be transmitted).*: Sentence terminatorxx: XOR checksum of all ASCII characters between$and*[CR]: Carriage Return, end marker[LF]: Line Feed, end marker
Important information in GGA sentences includes: latitude/longitude, GPS status, number of satellites currently in use, and altitude;
Summary of NMEA Data Parsing for Positioning Modules
- From the data organized above, it can be seen that both
GPGGAandGPRMCcontain positioning information such as latitude and longitude. So, which one should we use in our applications? In fact,GPGGAprovides GPS positioning information, whileGPRMCprovides recommended minimum specific GPS/Transit data, which is generally more accurate. - Considering the types of information generally required from a positioning module in common applications, most of the information we need is already contained within the
GPRMCsentence, so parsing only theGPRMCsentence should suffice.
Introduction to Using the GPS/BeiDou Dual-Mode Module TD3020C
The TD3020C is a GPS and BeiDou-2 dual-mode navigation and positioning module launched by Dongguan NavSpark Microelectronics. With dimensions of 22.4mm x 17mm x 2.0mm, it adopts a 28-pin stamp hole package, achieving pin-to-pin hardware compatibility with mainstream GPS modules (such as u-blox’s LEA-5/6 series).

A typical application wiring diagram is shown below:

The main interfaces included are as follows:
- Power interface;
- Antenna interface: GPS and BeiDou share a single external active antenna interface;
- Sleep mode control interface
- The module enters sleep mode controlled by an external sleep mode pin, reducing power consumption to below 5mA;
- Two sets of UART interfaces
- UART1 (
TXD1/RXD1), outputs NMEA data at UTC second boundaries, and can also be used to control the module’s operating mode, output baud rate, etc.; the default baud rate for this UART is 9600; - UART2 (
TXD2/RXD2), a spare UART, used for outputting custom-formatted data and can also be used for software upgrades of the module.
- UART1 (
- GPIO interface
- Includes 3 GPIO interfaces, whose functions can be defined according to user requirements.
In normal operation, in addition to outputting latitude, longitude, and other information according to the NMEA standard, the TD3020C can also control the module’s positioning mode, baud rate, and other operating parameters via UART1.
- Positioning mode switching commands: Supports independent operating modes for GPS and BeiDou, as well as mixed operating modes;

- Baud rate setting commands: Sets the baud rate for serial port output;

- GPS/BeiDou module NMEA information output update rate setting commands:
