Decoding GPS NMEA Sentences

1. Features

This procect shows how the NMEA sentences received from a GPS module can be decoded and displayed. Of the numerous sentences only the $GNGGA is decoded.

2. Parts

Parts needed for the GPS Project

3. Wiring

ESP32 Module
ESP32 Module
ESP32 Module
ESP32 Module

4. User Interface


The screen shows the decoded GGA Data.The time information is UTC. For your local time add the corrections for your timezone and daylight saving time. The number 12 after UTC stands for the number of satellites used for determining the position and the 0.81 is a measure for the horizontal deviation. The next two lines are self-explanatory namely latitude, longitude and altitude.

GGA-Data fetched from GPS
Line 1: Custom header
Line 2: UTC time, Nbr of satellites for fix, horizontal dillution of precision
Line 3: Latitude and longitude
Line 4: Altitude

5. Program Code

My programming environment is not the native Arduino™ IDE but PlatformIO™ on top of Microsoft's Visual Studio Code™. This combination offers many advantages and allows a much better structuring of the code into several modules especially when we adopt The Object Oriented way.

In the main loop of the program we read continuously the strings fetched on serial port 1. If the string contains the token GGA we parse the string into a data structure and then display the different values on the OLED. The string is also output on the serial monitor for control purposes. It looks like this:

The other sentences received are:


The decoding of the other NMEA sentences is prepared but not worked out in detail. That is left as and exercise to the ambitious programmer.

Interested? Please download the entire program code. The zip-file contains the complete PlatformIO project.