{"id":288,"date":"2019-11-23T23:06:51","date_gmt":"2019-11-23T20:06:51","guid":{"rendered":"http:\/\/192.168.100.172\/?p=288"},"modified":"2020-04-28T11:18:11","modified_gmt":"2020-04-28T08:18:11","slug":"python-gps-nmea-sentence-parser","status":"publish","type":"post","link":"https:\/\/egemeric.gen.tr\/old\/index.php\/2019\/11\/23\/python-gps-nmea-sentence-parser\/","title":{"rendered":"python GPS &#8211; NMEA sentence Parser"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>from datetime import datetime\nimport sqlite3\nimport time\nimport requests\n\nclass db_create():\n    def __init__(self,lon,lat,speed):\n        self.lon=lon\n        self.lat=lat\n        self.speed=speed\n        self.time=time.time()\n    def __str__(self):\n        return(\" Lon={}\\n Lat={}\\n Speed={}\".format(self.lon,self.lat,self.speed))\nclass decode():\n    def __init__(self,serial_data):\n        self.raw_lat=serial_data&#91;3]\n        self.raw_lon=serial_data&#91;5]\n        self.speed_knot=serial_data&#91;7]\n\n        self.to_decaminal()\n\n    def to_decaminal(self):\n        self.lat=float(self.raw_lat&#91;0:2])+(float(self.raw_lat&#91;2:4])\/60)+(float(self.raw_lat&#91;5:7])\/3600)\n        self.lon=float(self.raw_lon&#91;0:3])+(float(self.raw_lon&#91;3:5])\/60)+(float(self.raw_lon&#91;6:8])\/3600)\n        self.speed=float(self.speed_knot)*1.85200 #knots to kmh\n        \ngprmc=\"$GNRMC,091805.00,A,3953.300557,N,03252.202539,E,0.102,,200619,,,A*6\"#exapmle data string of telnet\n\nif (gprmc&#91;0:6] == \"$GNRMC\"):\n    parsed_data=gprmc.split(\",\")\n    if (parsed_data&#91;2]==\"A\"):\n        decoded_data=decode(parsed_data)\n        print(db_create(decoded_data.lon,decoded_data.lat,decoded_data.speed))\n    else:\n        print(\"gps error\")\n<\/code><\/pre>\n\n\n\n<p>It is an example for parsing nmea sentes with python and it creates the db , you need to create serial connection to use with gps receiver.<\/p>\n\n\n\n<p>#gprmc string is example of serial data stream you need to create serial connection to use <\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"https:\/\/192.168.100.172\/wp-content\/uploads\/2019\/11\/gps-parser.zip\">gps-parser<\/a><a href=\"https:\/\/192.168.100.172\/wp-content\/uploads\/2019\/11\/gps-parser.zip\" class=\"wp-block-file__button\" download>\u0130ndir<\/a><\/div>\n\n\n\n<p><a href=\"http:\/\/aprs.gids.nl\/nmea\/\">http:\/\/aprs.gids.nl\/nmea\/<\/a> # here, you can find more information about gps nema sentences<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is an example for parsing nmea sentes with python and it creates the db , you need to create serial connection to use with gps receiver. #gprmc string is example of serial data stream you need to create serial connection to use http:\/\/aprs.gids.nl\/nmea\/ # here, you can find more information about gps nema sentences<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":4,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":301,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/posts\/288\/revisions\/301"}],"wp:attachment":[{"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egemeric.gen.tr\/old\/index.php\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}