diff --git a/README.rst b/README.rst index a437320..09cacf7 100644 --- a/README.rst +++ b/README.rst @@ -31,7 +31,64 @@ This is easily achieved by downloading Usage Example ============= -See examples/simple.py for a demonstration of parsing and printing GPS location. +See examples/gps_simpletest.py for a demonstration of parsing and printing GPS location. + +Important: +Feather boards and many other circuitpython boards will round to two decimal places like this: + +.. code-block:: python + + >>> float('1234.5678') + 1234.57 + +This isn't ideal for gps data as this lowers the accuracty from 0.1m to 11m. + +This can be fixed by using string formatting when the gps data is outputted. + +An implementation of this can be found in examples/gps_simpletest.py + +.. code-block:: python + + import time + import board + import busio + + import adafruit_gps + + RX = board.RX + TX = board.TX + + uart = busio.UART(TX, RX, baudrate=9600, timeout=30) + + gps = adafruit_gps.GPS(uart, debug=False) + + gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') + + gps.send_command(b'PMTK220,1000') + + last_print = time.monotonic() + while True: + + gps.update() + + current = time.monotonic() + if current - last_print >= 1.0: + last_print = current + if not gps.has_fix: + print('Waiting for fix...') + continue + print('=' * 40) # Print a separator line. + print('Latitude: {0:.6f} degrees'.format(gps.latitude)) + print('Longitude: {0:.6f} degrees'.format(gps.longitude)) + + +These two lines are the lines that actually solve the issue: + +.. code-block:: python + + print('Latitude: {0:.6f} degrees'.format(gps.latitude)) + print('Longitude: {0:.6f} degrees'.format(gps.longitude)) + Contributing ============ @@ -85,4 +142,4 @@ Now, once you have the virtual environment activated: This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to -locally verify it will pass. \ No newline at end of file +locally verify it will pass. diff --git a/examples/gps_computer_datalogging.py b/examples/gps_computer_datalogging.py index 0e32132..a3fd8c9 100644 --- a/examples/gps_computer_datalogging.py +++ b/examples/gps_computer_datalogging.py @@ -17,7 +17,7 @@ # Create a serial connection for the GPS connection using default speed and # a slightly higher timeout (GPS modules typically update once a second). # Update the serial port name to match the serial connection for the GPS! -uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3000) +uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=30) # Main loop just reads data from the GPS module and writes it back out to # the output file while also printing to serial output. diff --git a/examples/gps_datalogging.py b/examples/gps_datalogging.py index 324b4c3..7ffb8be 100644 --- a/examples/gps_datalogging.py +++ b/examples/gps_datalogging.py @@ -40,7 +40,7 @@ # Create a serial connection for the GPS connection using default speed and # a slightly higher timeout (GPS modules typically update once a second). -uart = busio.UART(TX, RX, baudrate=9600, timeout=3000) +uart = busio.UART(TX, RX, baudrate=9600, timeout=30) # Main loop just reads data from the GPS module and writes it back out to # the output file while also printing to serial output. diff --git a/examples/gps_echotest.py b/examples/gps_echotest.py index 450e6e7..e97a42e 100644 --- a/examples/gps_echotest.py +++ b/examples/gps_echotest.py @@ -16,7 +16,7 @@ # Create a serial connection for the GPS connection using default speed and # a slightly higher timeout (GPS modules typically update once a second). -uart = busio.UART(TX, RX, baudrate=9600, timeout=3000) +uart = busio.UART(TX, RX, baudrate=9600, timeout=30) # for a computer, use the pyserial library for uart access #import serial diff --git a/examples/gps_simpletest.py b/examples/gps_simpletest.py index a475acf..c5d33cf 100644 --- a/examples/gps_simpletest.py +++ b/examples/gps_simpletest.py @@ -16,7 +16,7 @@ # Create a serial connection for the GPS connection using default speed and # a slightly higher timeout (GPS modules typically update once a second). -uart = busio.UART(TX, RX, baudrate=9600, timeout=3000) +uart = busio.UART(TX, RX, baudrate=9600, timeout=30) # for a computer, use the pyserial library for uart access #import serial diff --git a/examples/gps_time_source.py b/examples/gps_time_source.py index f23aa37..9dd3bc1 100644 --- a/examples/gps_time_source.py +++ b/examples/gps_time_source.py @@ -8,7 +8,7 @@ import rtc import adafruit_gps -uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=3000) +uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=30) gps = adafruit_gps.GPS(uart, debug=False) gps.send_command(b'PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0')