Accessing R+ NMEA Data From Python

Hi community!

I spend some time accessing NMEA from my R+ with Python.
As I couldn’t find any related post, I thought I’d share my experience.

  1. Hardware Setup
    R+ with stable satellite connection and WiFi access to the same network as the PC.

  2. Software Setup
    Python with pynmeagps module: pynmeagps · PyPI
    (complete code attached below)

  3. Output
    <NMEA(GNGGA, time=16:08:27, lat=50.xxxxxxxx, NS=N, lon=6.xxxxxxxxx, EW=E, quality=5, numSV=14, HDOP=1.3, alt=91.441, altUnit=M, sep=46.329, sepUnit=M, diffAge=1.0, diffStation=2975)>

  4. Code

import datetime
import socket
from pynmeagps import NMEAReader

if __name__ == '__main__':

    host_ip = 'xxx.xxx.xxx.xx'  # Reach IP
    port = 9001                 # Reach TCP Port

    try:
        stream = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        print ("Socket successfully created")
    except socket.error as err:
        print ("socket creation failed with error %s" %(err))

    print('Connecting: ' + str(host_ip) + ' : ' + str(port))
    stream.connect((host_ip, port))
    nmr = NMEAReader(stream)

    print('Listening...')
    for (raw_data, parsed_data) in nmr.iterate(): 
        if parsed_data:

            t = '' # to be filled with time data
            try:
                t = parsed_data.time.strftime('%H:%M:%S,%f')
                # print(parsed_data.time)
            except:
                pass

            print(parsed_data)
            print('System \t\t\t\t GPS' )
            print(str(datetime.datetime.now()) + ' \t ' + str(t) + '\n')
        else:
            pass
3 Likes

Thanks for sharing that. Although I’m clueless about what is a R+ . What is it ?

Sorry, it appears I missed an S there. I meant a Reach RS+.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.