|
1 | 1 | # Simple GPS datalogging demonstration.
|
2 | 2 | # This example uses the GPS library and to read raw NMEA sentences
|
3 | 3 | # over I2C or UART from the GPS unit and dumps them to a file on an SD card
|
4 |
| -# (recommended) or internal storage (be careful as only a few kilobytes to |
5 |
| -# megabytes are available). Before writing to internal storage you MUST |
6 |
| -# carefully follow the steps in this guide to enable writes to the internal |
7 |
| -# filesystem: |
| 4 | +# (recommended), microcontroller internal storage (be careful as only a few |
| 5 | +# kilobytes are available), or to a filesystem. |
| 6 | +# If you are using a microcontroller, before writing to internal storage you |
| 7 | +# MUST carefully follow the steps in this guide to enable writes to the |
| 8 | +# internal filesystem: |
8 | 9 | # https://learn.adafruit.com/adafruit-ultimate-gps-featherwing/circuitpython-library
|
9 | 10 | import board
|
10 | 11 | import busio
|
|
14 | 15 | # which means new lines are added at the end and all old data is kept.
|
15 | 16 | # Change this path to point at internal storage (like '/gps.txt') or SD
|
16 | 17 | # card mounted storage ('/sd/gps.txt') as desired.
|
17 |
| -LOG_FILE = '/gps.txt' # Example for writing to internal path /gps.txt |
| 18 | +LOG_FILE = 'gps.txt' # Example for writing to internal path gps.txt |
18 | 19 |
|
19 | 20 | # File more for opening the log file. Mode 'ab' means append or add new lines
|
20 | 21 | # to the end of the file rather than erasing it and starting over. If you'd
|
21 | 22 | # like to erase the file and start clean each time use the value 'wb' instead.
|
22 | 23 | LOG_MODE = 'ab'
|
23 | 24 |
|
24 |
| -# If writing to SD card customize and uncomment these lines to import the |
25 |
| -# necessary library and initialize the SD card: |
| 25 | +# If writing to SD card on a microcontroller customize and uncomment these |
| 26 | +# lines to import the necessary library and initialize the SD card: |
| 27 | +# NOT for use with a single board computer like Raspberry Pi! |
26 | 28 | """
|
27 | 29 | import adafruit_sdcard
|
28 | 30 | import digitalio
|
|
42 | 44 | # These are the defaults you should use for the GPS FeatherWing.
|
43 | 45 | # For other boards set RX = GPS module TX, and TX = GPS module RX pins.
|
44 | 46 | uart = busio.UART(board.TX, board.RX, baudrate=9600, timeout=10)
|
| 47 | + |
| 48 | +# If using a USB/Serial converter, use pyserial and update the serial |
| 49 | +# port name to match the serial connection for the GPS! |
| 50 | +#import serial |
| 51 | +#uart = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=10) |
| 52 | + |
45 | 53 | # If using I2C, we'll create an I2C interface to talk to using default pins
|
46 | 54 | #i2c = busio.I2C(board.SCL, board.SDA)
|
47 | 55 |
|
|
0 commit comments