5.1. NMEA Protocol (RS-232)#
NMEA protocol is based on the standard protocol family widely used by the navigation equipment. NMEA protocol is sentence oriented, and is capable of sending multiple sentences with different information. The sentence content is designated by the starting keyword which is different for each sentence type. NMEA sentences are terminated with the checksum which makes this protocol extremely reliable. NMEA protocol is single-direction protocol: data is only transmitted from the surface velocity radar. At RS-232 interface the device periodically outputs following data sentences:
Surface velocity measurement report#
$VEL,<direction>,<velocity>,<snr>,<status>*<checksum><CR><LF>
$VEL: The keyword sent on the beginning of each report. This sentence contains information about the measured flow.
<direction>: The direction of the flow, as detected by the instrument (1 incoming, -1 outgoing, 0 no flow).<velocity>: The absolute value of the surface flow velocity, in selected measurement units, as decimal number. If no flow is detected, the output will be zero.<snr>: The signal-to-noise ratio of the returned radar signal, in dB.<status>: The status indicator. If the device operates without any errors, the output will be zero. If non-zero, it is interpreted as error bitmask: Bit 0: forward tilt angle error (tilt angle outside of expected range), Bit 1: side tilt angle error (tilt is too big), Bit 2: radar co-processor update failed, Bit 3: radar co-processor not responding, Bit 4: radar co-processor needs to be updated, Bit 5: tilt sensor is not working, Bit 6: radar self-calibration failed, Bit 7: DFP data corrupt, needs reset, Bit 8: power save mode is active, Bit 9: radar is initializing.<checksum>: Two uppercase hexadecimal digits containing the checksum value of the NMEA sentence.
Device status report#
$STAT,<angle_elevation>,<angle_sideways>,<temperature>,<humidity>*<checksum><CR><LF>
$STAT: The keyword sent to denote the device status report sentence.
<angle_elevation>: The elevation angle, expressed in degrees, describes the tilt of the radar relative to the water surface. An elevation angle of 0° means the radar is oriented parallel to the water surface; an elevation angle of 90° means the radar is oriented perpendicular to the water surface.<angle_sideways>: The sideways tilt angle of the instrument. Negative values are tilted to the left, and positive to the right. The radar should be positioned so that this angle is close to zero.<temperature>: The temperature inside the instrument enclosure, in degrees Celsius.<humidity>: The relative humidity inside the instrument enclosure, in %.
NMEA Checksum Calculation#
Each NMEA sentence ends with a checksum to ensure data integrity. The checksum (CSUM) is calculated as follows:
Start with a checksum value of 0.
Perform a bitwise XOR operation on all characters in the sentence between the $ and * symbols.
Do not include the $, *, the two checksum hex digits, or trailing CR/LF
characters in the calculation.
If the input has no *, compute XOR over all characters after $.
The resulting checksum value is converted to two hexadecimal characters (0–9, A–F) and appended after the * symbol.
The following Python function shows how to calcualate the checksum:
def nmea_checksum(nmea_sentence: str) -> str:
s = nmea_sentence.rstrip("\\r\\n")
# Remove leading '$' or '!' if present.
if s and s[0] in "$!":
s = s[1:]
# Keep only payload part before checksum delimiter.
s = s.split("*", 1)[0]
checksum = 0
for char in s.encode("ascii"):
checksum ^= char
return f"{checksum:02X}"