{"id":13937387,"url":"https://github.com/Knio/pynmea2","last_synced_at":"2025-07-19T23:31:51.260Z","repository":{"id":9323182,"uuid":"11167307","full_name":"Knio/pynmea2","owner":"Knio","description":"Python library for parsing the NMEA 0183 protocol (GPS)","archived":false,"fork":false,"pushed_at":"2024-11-22T06:01:09.000Z","size":286,"stargazers_count":652,"open_issues_count":34,"forks_count":228,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-06-08T15:50:23.232Z","etag":null,"topics":["gps","gps-data","nmea-parser","nmea-protocol","nmea-sentences","nmea0183","pynmea2","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Knio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-07-04T04:49:36.000Z","updated_at":"2025-04-23T16:05:10.000Z","dependencies_parsed_at":"2023-02-11T21:16:26.570Z","dependency_job_id":"86ab501d-3d14-4f1a-84c3-85e0696e606c","html_url":"https://github.com/Knio/pynmea2","commit_stats":{"total_commits":182,"total_committers":40,"mean_commits":4.55,"dds":0.478021978021978,"last_synced_commit":"d9eb144892bad2fe01b76708750a93ed151fc9bb"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Knio/pynmea2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Knio%2Fpynmea2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Knio%2Fpynmea2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Knio%2Fpynmea2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Knio%2Fpynmea2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Knio","download_url":"https://codeload.github.com/Knio/pynmea2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Knio%2Fpynmea2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266041697,"owners_count":23867944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gps","gps-data","nmea-parser","nmea-protocol","nmea-sentences","nmea0183","pynmea2","python"],"created_at":"2024-08-07T23:03:33.771Z","updated_at":"2025-07-19T23:31:51.242Z","avatar_url":"https://github.com/Knio.png","language":"Python","readme":"# pynmea2\n\n`pynmea2` is a python library for the [NMEA 0183](http://en.wikipedia.org/wiki/NMEA_0183) protocol\n\n`pynmea2` is based on [`pynmea`](https://code.google.com/p/pynmea/) by Becky Lewis\n\nThe `pynmea2` homepage is located at \u003chttp://github.com/Knio/pynmea2\u003e\n\n## Compatibility\n\n`pynmea2` is compatable with Python 2.7 and Python 3.4+\n\n![Python version](https://img.shields.io/pypi/pyversions/pynmea2.svg?style=flat)\n[![Build status](https://github.com/Knio/pynmea2/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Knio/pynmea2/actions/workflows/ci.yml?query=branch%3Amaster+)\n[![Coverage status](https://img.shields.io/coveralls/github/Knio/pynmea2/master.svg?style=flat)](https://coveralls.io/r/Knio/pynmea2?branch=master)\n\n## Installation\n\nThe recommended way to install `pynmea2` is with\n[pip](http://pypi.python.org/pypi/pip/):\n\n```bash\npip install pynmea2\n```\n\n[![PyPI version](https://img.shields.io/pypi/v/pynmea2.svg?style=flat)](https://pypi.org/project/pynmea2/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/pynmea2.svg?style=flat)](https://pypi.org/project/pynmea2/)\n\n## Parsing\n\nYou can parse individual NMEA sentences using the `parse(data, check=False)` function, which takes a string containing a\nNMEA 0183 sentence and returns a `NMEASentence` object. Note that the leading '$' is optional and trailing whitespace is ignored when parsing a sentence.\n\nWith `check=False`, `parse` will accept NMEA messages that do not have checksums, however it will still raise `pynmea2.ChecksumError` if they are present. `check=True` will also raise `ChecksumError` if the checksum is missing.\n\nExample:\n\n```python\n\u003e\u003e\u003e import pynmea2\n\u003e\u003e\u003e msg = pynmea2.parse(\"$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D\")\n\u003e\u003e\u003e msg\n\u003cGGA(timestamp=datetime.time(18, 43, 53), lat='1929.045', lat_dir='S', lon='02410.506', lon_dir='E', gps_qual='1', num_sats='04', horizontal_dil='2.6', altitude=100.0, altitude_units='M', geo_sep='-33.9', geo_sep_units='M', age_gps_data='', ref_station_id='0000')\u003e\n```\n\nThe `NMEASentence` object has different properties, depending on its sentence type.\nThe `GGA` message has the following properties:\n\n```python\n\u003e\u003e\u003e msg.timestamp\ndatetime.time(18, 43, 53)\n\u003e\u003e\u003e msg.lat\n'1929.045'\n\u003e\u003e\u003e msg.lat_dir\n'S'\n\u003e\u003e\u003e msg.lon\n'02410.506'\n\u003e\u003e\u003e msg.lon_dir\n'E'\n\u003e\u003e\u003e msg.gps_qual\n'1'\n\u003e\u003e\u003e msg.num_sats\n'04'\n\u003e\u003e\u003e msg.horizontal_dil\n'2.6'\n\u003e\u003e\u003e msg.altitude\n100.0\n\u003e\u003e\u003e msg.altitude_units\n'M'\n\u003e\u003e\u003e msg.geo_sep\n'-33.9'\n\u003e\u003e\u003e msg.geo_sep_units\n'M'\n\u003e\u003e\u003e msg.age_gps_data\n''\n\u003e\u003e\u003e msg.ref_station_id\n'0000'\n```\n\nAdditional properties besides the ones explicitly in the message data may also exist.\n\nFor example, `latitude` and `longitude` properties exist as helpers to access the geographic coordinates as python floats ([DD](http://en.wikipedia.org/wiki/Decimal_degrees), \"decimal degrees\") instead of the DDDMM.MMMM (\"Degrees, minutes, seconds\") format used in the NMEA protocol. `latitude_minutes`, `latitude_seconds`, `longitude_minutes`, and `longitude_seconds` are also supported and allow easy creation of differently formatted location strings.\n\n```python\n\u003e\u003e\u003e msg.latitude\n-19.4840833333\n\u003e\u003e\u003e msg.longitude\n24.1751\n\u003e\u003e\u003e '%02d°%07.4f′' % (msg.latitude, msg.latitude_minutes)\n'-19°29.0450′'\n\u003e\u003e\u003e '%02d°%02d′%07.4f″' % (msg.latitude, msg.latitude_minutes, msg.latitude_seconds)\n\"-19°29′02.7000″\"\n```\n\n## Generating\n\nYou can create a `NMEASentence` object by calling the constructor with talker, message type, and data fields:\n\n```python\n\u003e\u003e\u003e import pynmea2\n\u003e\u003e\u003e msg = pynmea2.GGA('GP', 'GGA', ('184353.07', '1929.045', 'S', '02410.506', 'E', '1', '04', '2.6', '100.00', 'M', '-33.9', 'M', '', '0000'))\n```\n\nand generate a NMEA string from a `NMEASentence` object:\n\n```python\n\u003e\u003e\u003e str(msg)\n'$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D'\n```\n\n## File reading example\n\nSee [examples/read_file.py](/examples/read_file.py)\n\n```python\nimport pynmea2\n\nfile = open('examples/data.log', encoding='utf-8')\n\nfor line in file.readlines():\n    try:\n        msg = pynmea2.parse(line)\n        print(repr(msg))\n    except pynmea2.ParseError as e:\n        print('Parse error: {}'.format(e))\n        continue\n```\n\n## `pySerial` device example\n\nSee [examples/read_serial.py](/examples/read_serial.py)\n\n```python\nimport io\n\nimport pynmea2\nimport serial\n\n\nser = serial.Serial('/dev/ttyS1', 9600, timeout=5.0)\nsio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))\n\nwhile 1:\n    try:\n        line = sio.readline()\n        msg = pynmea2.parse(line)\n        print(repr(msg))\n    except serial.SerialException as e:\n        print('Device error: {}'.format(e))\n        break\n    except pynmea2.ParseError as e:\n        print('Parse error: {}'.format(e))\n        continue\n```\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnio%2Fpynmea2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKnio%2Fpynmea2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKnio%2Fpynmea2/lists"}