Jan 21, 2015

NMEA CRC checksum calculator and arduino function

Elimelec Lopez offers this clear solution and computes the correct code
Link to a NMEA calculator on web: http://www.hhhh.org/wiml/proj/nmeaxor.html
   ex: $GPGGA,045104.000,3014.1985,N,09749.2873,W,1,09,1.2,211.6,M,-22.5,M,,0000*62"
Elimeléc's Arduino Projects: NMEA checksum calculator

excerpt: Generates a two nybble hex value for an ASCII string surrounded by $ and *

 
  if (data_end == true){
    for (byte x = start_with+1; x<end_with; x++){ // XOR every character in between '$' and '*'
      CRC = CRC ^ buffer[x] ;
    }
  }

  if(CRC > 0){
    Serial.println(CRC,HEX); // print calculated CS in HEX format.
    CRC = 0; // reset CRC variable
    data_end = false; // Reset EOF so we can process more incoming data.
  }

A complete example and explanation is in a later post above.