-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Newbie to all things Pi and coding. Any and all help massively appreciated!
I get the error above when the code gets to
if sentence.find('GGA') > 0:
Raspberry Pi Zero W fully up to date.
Ultimate GPS wired per the rpi-gps instructions.
Fails whether running at command line or GUI IDLE3.
Packages installed for both Python 2 and Python 3.
For a previous project I had the GPS pointed at ttyS0 rather than ttyAMA0 so I have been substituting ttyAMA0 with ttyS0 throughout this project.
cat ttyS0 correctly shows nmea sentences as expected so I'm definately getting data from the GPS breakout.
My code deviates very slightly from the initialstate code:
#!/usr/bin/env python3
import serial
import pynmea2
from ISStreamer.Streamer import StreamerserialStream = serial.Serial("/dev/ttyS0", 9600, timeout=0.5)
streamer = Streamer(bucket_name="GPS Tracker", ini_file_location="./isstreamer.ini")
try:
while True: sentence = serialStream.readline() print (sentence) if sentence.find('GGA') > 0: print('Found a GGA') data = pynmea2.parse(sentence) streamer.log("Satellite Count", data.num_stats) if (data.num_stats >= 3): streamer.log("Location", "{lat},{lon}".format(lat=data.latitude, lon=data.longitude)) if (data.num_stats > 4): streamer.log("Altitude ({unit})".format(unit=data.altitude_units), data.altitude)except KeyboardInterrupt:
streamer.close()