{"library":"pynmea2","title":"pynmea2 NMEA 0183 Protocol Parser","description":"pynmea2 is a Python library for parsing and creating NMEA 0183 sentences, commonly used in GPS and other GNSS receivers. It provides a flexible API for working with various NMEA sentence types, handling checksums, and accessing data fields. The current version is 1.19.0, with a release cadence of several updates per year, primarily for bug fixes and new sentence type support.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pynmea2"],"cli":null},"imports":["import pynmea2\nmsg = pynmea2.parse('$GPGGA,...')","from pynmea2 import GGA\nmsg = GGA('GP', 'GGA', (...))","from pynmea2 import ChecksumError","from pynmea2 import ParseError"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pynmea2\nimport datetime\n\n# Example 1: Parsing an NMEA sentence\nraw_gga = '$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D'\ntry:\n    msg = pynmea2.parse(raw_gga)\n    print(f\"Parsed sentence type: {msg.sentence_type}\")\n    print(f\"Timestamp: {msg.timestamp}\")\n    print(f\"Latitude: {msg.latitude}, Longitude: {msg.longitude}\")\nexcept pynmea2.ChecksumError as e:\n    print(f\"Checksum error: {e}\")\nexcept pynmea2.ParseError as e:\n    print(f\"Parse error: {e}\")\n\n# Example 2: Creating an NMEA sentence\n# GGA fields: (timestamp, lat, lat_dir, lon, lon_dir, fix_quality, num_sats, hdop, alt, alt_units, geoid_sep, geoid_units, age_of_diff, diff_ref_id)\n# Note: lat/lon can be floats, others mostly strings/ints\ntimestamp_val = datetime.time(12, 0, 0)\nlat_val = '3404.70417'\nlat_dir_val = 'N'\nlon_val = '11808.66539'\nlon_dir_val = 'W'\n\ntry:\n    new_gga = pynmea2.GGA('GP', 'GGA', (\n        timestamp_val, lat_val, lat_dir_val, lon_val, lon_dir_val,\n        1, 8, 0.9, 500.0, 'M', 25.0, 'M', '', ''\n    ))\n    print(f\"\\nCreated NMEA sentence: {str(new_gga)}\")\nexcept ValueError as e:\n    print(f\"Error creating GGA sentence: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to parse an existing NMEA 0183 GGA sentence and how to construct a new GGA sentence from scratch. It includes basic error handling for common parsing issues.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}