Skip to content

Modified README to help people use floats. Also changed uart timeout on example files. #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down Expand Up @@ -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.
locally verify it will pass.
2 changes: 1 addition & 1 deletion examples/gps_computer_datalogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/gps_datalogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/gps_echotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/gps_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/gps_time_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down