All Projects → Knio → Pynmea2

Knio / Pynmea2

Licence: mit
Python library for parsing the NMEA 0183 protocol (GPS)

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Pynmea2

ios logger
Application for camera and sensor data logging (iOS)
Stars: ✭ 60 (-84.17%)
Mutual labels:  gps
Navego
NaveGo: an open-source MATLAB/GNU Octave toolbox for processing integrated navigation systems and performing inertial sensors analysis.
Stars: ✭ 294 (-22.43%)
Mutual labels:  gps
Sim7000 Lte Shield
LTE CAT-M/NB-IoT Arduino-compatible shield with GNSS and temperature sensor. Library supports SIMCom 2G/3G/4G LTE/CAT-M/NB-IoT
Stars: ✭ 340 (-10.29%)
Mutual labels:  gps
GPXParser.js
GPX file parser javascript library
Stars: ✭ 58 (-84.7%)
Mutual labels:  gps
Disco4g
4G/LTE softmod for the Parrot Disco
Stars: ✭ 273 (-27.97%)
Mutual labels:  gps
Rxgps
Finding current location cannot be easier on Android !
Stars: ✭ 307 (-19%)
Mutual labels:  gps
AndrOBD-Plugin
AndrOBD plugin development project
Stars: ✭ 38 (-89.97%)
Mutual labels:  gps
Fmm
Fast map matching, an open source framework in C++
Stars: ✭ 359 (-5.28%)
Mutual labels:  gps
Gpmf Parser
Parser for GPMF™ formatted telemetry data used within GoPro® cameras.
Stars: ✭ 282 (-25.59%)
Mutual labels:  gps
Open Location Code
Open Location Code is a library to generate short codes, called "plus codes", that can be used as digital addresses where street addresses don't exist.
Stars: ✭ 3,567 (+841.16%)
Mutual labels:  gps
ninja-scan-light
Ultra-small motion logger using Silicon Laboratories USB C8051 MCU
Stars: ✭ 28 (-92.61%)
Mutual labels:  gps
Traccar
Traccar GPS Tracking System
Stars: ✭ 3,353 (+784.7%)
Mutual labels:  gps
Overland Ios
📌 GPS logger for iOS devices
Stars: ✭ 310 (-18.21%)
Mutual labels:  gps
nmea
NMEA 0183 parser
Stars: ✭ 13 (-96.57%)
Mutual labels:  gps
Gprs c sdk
Ai-Thinker A9/A9G GPRS (with GPS(A9G)) module C development SDK
Stars: ✭ 356 (-6.07%)
Mutual labels:  gps
EasyWayLocation
This library contain all utils related to google location. like, getting lat or long, Address and Location Setting dialog, many more...
Stars: ✭ 142 (-62.53%)
Mutual labels:  gps
Beagle sdr gps
KiwiSDR: BeagleBone web-accessible shortwave receiver and software-defined GPS
Stars: ✭ 300 (-20.84%)
Mutual labels:  gps
Navit
The open source (GPL v2) turn-by-turn navigation software for many OS
Stars: ✭ 368 (-2.9%)
Mutual labels:  gps
Multi sensor fusion
Multi-Sensor Fusion (GNSS, IMU, Camera) 多源多传感器融合定位 GPS/INS组合导航 PPP/INS紧组合
Stars: ✭ 357 (-5.8%)
Mutual labels:  gps
Ulogger Server
μlogger • web viewer for tracks uploaded with μlogger mobile client
Stars: ✭ 315 (-16.89%)
Mutual labels:  gps

pynmea2

pynmea2 is a python library for the NMEA 0183 protocol

pynmea2 is based on pynmea by Becky Lewis

The pynmea2 homepage is located at http://github.com/Knio/pynmea2

Compatibility

pynmea2 is compatable with Python 2.7 and Python 3.4+

Python version Build status Coverage status

Installation

The recommended way to install pynmea2 is with pip:

pip install pynmea2

PyPI version PyPI downloads

Parsing

You can parse individual NMEA sentences using the parse(data, check=False) function, which takes a string containing a NMEA 0183 sentence and returns a NMEASentence object. Note that the leading '$' is optional and trailing whitespace is ignored when parsing a sentence.

With 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.

Example:

>>> import pynmea2
>>> msg = pynmea2.parse("$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D")
>>> msg
<GGA(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')>

The NMEASentence object has different properties, depending on its sentence type. The GGA message has the following properties:

>>> msg.timestamp
datetime.time(18, 43, 53)
>>> msg.lat
'1929.045'
>>> msg.lat_dir
'S'
>>> msg.lon
'02410.506'
>>> msg.lon_dir
'E'
>>> msg.gps_qual
'1'
>>> msg.num_sats
'04'
>>> msg.horizontal_dil
'2.6'
>>> msg.altitude
100.0
>>> msg.altitude_units
'M'
>>> msg.geo_sep
'-33.9'
>>> msg.geo_sep_units
'M'
>>> msg.age_gps_data
''
>>> msg.ref_station_id
'0000'

Additional properties besides the ones explicitly in the message data may also exist.

For example, latitude and longitude properties exist as helpers to access the geographic coordinates as python floats (DD, "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.

>>> msg.latitude
-19.4840833333
>>> msg.longitude
24.1751
>>> '%02%07.4f′' % (msg.latitude, msg.latitude_minutes)
'-19°29.0450′'
>>> '%02%02d′%07.4f″' % (msg.latitude, msg.latitude_minutes, msg.latitude_seconds)
"-19°29′02.7000″"

Generating

You can create a NMEASentence object by calling the constructor with talker, message type, and data fields:

>>> import pynmea2
>>> msg = pynmea2.GGA('GP', 'GGA', ('184353.07', '1929.045', 'S', '02410.506', 'E', '1', '04', '2.6', '100.00', 'M', '-33.9', 'M', '', '0000'))

and generate a NMEA string from a NMEASentence object:

>>> str(msg)
'$GPGGA,184353.07,1929.045,S,02410.506,E,1,04,2.6,100.00,M,-33.9,M,,0000*6D'

File reading example

See examples/read_file.py

import pynmea2

file = open('examples/data.log', encoding='utf-8')

for line in file.readlines():
    try:
        msg = pynmea2.parse(line)
        print(repr(msg))
    except pynmea2.ParseError as e:
        print('Parse error: {}'.format(e))
        continue

pySerial device example

See examples/read_serial.py

import io

import pynmea2
import serial


ser = serial.Serial('/dev/ttyS1', 9600, timeout=5.0)
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))

while 1:
    try:
        line = sio.readline()
        msg = pynmea2.parse(line)
        print(repr(msg))
    except serial.SerialException as e:
        print('Device error: {}'.format(e))
        break
    except pynmea2.ParseError as e:
        print('Parse error: {}'.format(e))
        continue
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].