Created
November 22, 2016 14:36
-
-
Save mikerr/6d6a53b291f22291e474a13962e83683 to your computer and use it in GitHub Desktop.
Stream GPS to initalstate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import pynmea2 | |
import time | |
from ISStreamer.Streamer import Streamer | |
serialStream = serial.Serial("/dev/ttyS0", 9600, timeout=0.5) | |
# construct a streamer instance with information to append to or create | |
# a bucket and an ini file location that contains the Initial State | |
# Account Access Key. | |
streamer = Streamer(bucket_name="GPS Tracker", bucket_key="V4QHQ4747LFE", ini_file_location="./isstreamer.ini") | |
#streamer.log("Location", "{lat},{lon}".format(lat=53.429,lon=-2.756772)) | |
try: | |
while True: | |
sentence = serialStream.readline() | |
if sentence.find('GGA') > 0: | |
data = pynmea2.parse(sentence) | |
lat = data.latitude | |
if (lat != 0): | |
print lat | |
streamer.log("Location", "{lat},{lon}".format(lat=data.latitude,lon=data.longitude)) | |
streamer.log("Altitude ({unit})".format(unit=data.altitude_units), data.altitude) | |
except KeyboardInterrupt: | |
streamer.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment