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.
.-------------. | | |.-----------.| || OLED || || 128 x 64 || |.___________.| | | |[O] [O]| |EN Boot| | | Vcc -o .---------. o-- GND o | | o o | ESP32 | o o | | o o | | o .---------------. o | | o GND --o GND | o ._________| o Vcc --o Vcc | o o | GPS | o o | GN-801 | o o | | o RX1 o-- 17 ---------o TX | o TX1 o-- 16 ---------o RX | o o ._______________. o o o o o o o o o o o o o o | | ]ยจ|USB on][ ]_| ][o | off][ ._____________.
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.
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:
$GNGGA,084353.00,4728.65955,N,00818.96752,E,2,12,0.71,391.8,M,47.3,M,,0000*43The other sentences received are:
$GNRMC,091509.00,A,4728.66095,N,00818.97058,E,0.080,,100420,,,A*62 $GNVTG,,T,,M,0.080,N,0.147,K,A*37 $GNGGA,091509.00,4728.66095,N,00818.97058,E,1,12,0.74,381.3,M,47.3,M,,*48 $GNGSA,A,3,24,15,19,12,13,10,28,20,25,,,,1.32,0.74,1.09*12 $GNGSA,A,3,73,71,8$GNRMC,091519.00,A,4728.66031,N,00818.97018,E,0.140,,100420,,,A*64 $GNVTG,,T,,M,0.140,N,0.259,K,A*36 $GNGGA,091519.00,4728.66031,N,00818.97018,E,1,12,0.74,380.1,M,47.3,M,,*40 $GNGSA,A,3,24,15,19,12,13,10,28,20,25,,,,1.32,0.74,1.09*12 $GNGSA,A,3,73,71,82,81,,,,,,,,,1.32,0.74,1.09*16 $GPGSV,4,1,14,01,02,015,,10,20,297,11,12,42,230,34,13,25,152,17*77 $GPGSV,4,2,14,15,45,183,33,17,37,063,08,19,43,095,26,20,14,264,11*7A $GPGSV,4,3,14,24,72,304,15,25,10,235,25,28,14,053,24,32,03,321,*73 $GPGSV,4,4,14,36,31,150,,49,35,185,*78 $GLGSV,3,1,10,65,04,343,,70,16,193,,71,49,242,28,72,36,315,*6C $GLGSV,3,2,10,73,63,305,22,74,27,272,17,80,37,060,,81,12,017,26*67 $GLGSV,3,3,10,82,30,066,27,83,19,118,*63 $GNGLL,4728.66031,N,00818.97018,E,091519.00,A,A*7FThe 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.
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.