B4J Question NMEA-Sentences to GPS-Location


Licensed User

I am currently dealing with NMEA data.
But do not know whether all data(sentences) should be used to get a comparable GPS data set.
I would like to fill out a location class from the received NMEA data so that a certain compatibility between NMEA and GPS is established.
Can someone guide me in the right direction?

19 Interpreted sentences
$GPBOD - Bearing, origin to destination
$GPBWC - Bearing and distance to waypoint, great circle
$GPGGA - Global Positioning System Fix Data
$GPGLL - Geographic position, latitude / longitude
$GPGSA - GPS DOP and active satellites
$GPGSV - GPS Satellites in view
$GPHDT - Heading, True
$GPR00 - List of waypoints in currently active route
$GPRMA - Recommended minimum specific Loran-C data
$GPRMB - Recommended minimum navigation info
$GPRMC - Recommended minimum specific GPS/Transit data
$GPRTE - Routes
$GPTRF - Transit Fix Data
$GPSTN - Multiple Data ID
$GPVBW - Dual Ground / Water Speed
$GPVTG - Track made good and ground speed
$GPWPL - Waypoint location
$GPXTE - Cross-track error, Measured
$GPZDA - Date & Time
These 2 classes should be filled in:
Class GPSSatellite:
  Azimuth As Float [read only]
  Elevation As Float [read only]
  IsInitialized As Boolean
  Prn As Int [read only]
  Snr As Float [read only]
  UsedInFix As Boolean [read only]

Class Location:
  Accuracy As Float
  AccuracyValid As Boolean [read only]
  Altitude As Double
  AltitudeValid As Boolean [read only]
  Bearing As Float
  BearingTo (TargetLocation As android.location.Location) As Float
  BearingValid As Boolean [read only]
  ConvertToMinutes (Coordinate As Double) As String
  ConvertToSeconds (Coordinate As Double) As String
  DistanceTo (TargetLocation As android.location.Location) As Float
  IsInitialized As Boolean
  Latitude As Double
  Longitude As Double
  Speed As Float
  SpeedValid As Boolean [read only]
  Time As Long


Well-Known Member
Licensed User

Look at his attachment.
You must know where (how) to get the data you need from each type of sentence.
One used to be able to register for only certain sentence types - to reduce the noise - don't know if possible now.


Licensed User
You don't have to use all the sentences that you get, just those that you need for the data. The sentences do not come with the same frequency so choose those that come frequently.
I wrote in the past for a Pi connected to usb GPS, as an example:
If msg.StartsWith("$GPVTG") Then
'    Log(msg)
    str = Regex.Split(",",msg)
        Dim az As Int = NumberFormat(str(1),1,0)
        Dim speed As Int = NumberFormat(str(7),1,0)
    End Try
End If
If msg.StartsWith("$GPGGA") Then
    str = Regex.Split(",",msg)
        'Dim t As String = str(1)
        ttr = Regex.Split("\.",str(1))
        Dim H As String = DateTime.GetHour(DateTime.Now + 2* DateTime.TicksPerHour)
        Dim M As String = ttr(0).SubString2(2,4)
        Dim S As String = ttr(0).SubString2(4,6)
        st = H&":"&M&":"&s
        Dim lat() As String
        lat = Regex.Split("\.",str(2))
        Dim Deg As String = lat(0).SubString2(0,2)
        Dim Mi As String = lat(0).SubString(2)
        Dim dlat As String = NumberFormat((Deg + Mi/60),1,5)

        Dim lon() As String
        lon = Regex.Split("\.",str(4))
        Deg = lon(0).SubString2(0,3)
        Mi  = lon(0).SubString(3)
        Dim dlon As String = NumberFormat((Deg + Mi/60),1,5)
    End Try
    Log("Time:  " & st &"    Az: " & az & "   Speed:  " & speed & " Lat: " & dlat & " Long: " & dlon)
For the satellites you'll need :
$GPGSA - GPS DOP and active satellites
$GPGSV - GPS Satellites in view
Last edited: