I am trying to use quectel L80 GPS receiver for my project. I am trying to configure the L80 using the PMTK strings. But the problem is the string should also contain a hexadecimal check sum.

eg. $PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29

This is the example string given in the "protocol specification" document. In this string '29' is the check sum. My question is how do I generate the checksum? I know that for NMEA strings, the check sum is generated by 'XOR' operation of consecutive characters between '$' and '*' . while calculating the check sum do I also need to include 'comma'?


  • \$\begingroup\$ Oh thanks, its help full. :) The protocol specification does not include the information on how to generate the checksum. \$\endgroup\$
    – R. Hirur
    Commented Jan 30, 2016 at 6:57
  • 1
    \$\begingroup\$ @Roger I think on that page they're talking about the $ and * delimiters, the commas are included in NMEA checksums and you can see on that page if you include commas it changes the value. \$\endgroup\$
    – PeterJ
    Commented Jan 30, 2016 at 11:52
  • \$\begingroup\$ Check out the Wikipedia page for NEMA Standard \$\endgroup\$
    – MaNyYaCk
    Commented Jun 22, 2018 at 9:36

1 Answer 1


You just exclusive-or all the characters between the '$' and the '*' (including commas) and use the two-character hex representation of that byte (leading 0 if required to pad to two characters). Here's an example code fragment in Python:

st = "PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
i = 0
checksum = 0
while i < len(st):
   checksum ^= ord(st[i])
   i+= 1
print "%02X"%checksum

Result is 29

For "GPGSA,A,3,10,07,05,02,29,04,08,13,,,,,1.72,1.03,1.38", the result is 0A

  • \$\begingroup\$ This. Double-check it for known cases. As the specification and sample agree when you include the commas you have your answer. \$\endgroup\$
    – user16324
    Commented Jan 30, 2016 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.