Skip to content

Instantly share code, notes, and snippets.

@davidsulpy
Last active November 18, 2015 00:08
Show Gist options
  • Save davidsulpy/16b306218b4bd9e7cb7d to your computer and use it in GitHub Desktop.
Save davidsulpy/16b306218b4bd9e7cb7d to your computer and use it in GitHub Desktop.
isstreamer.ini
  1. Start with fresh Jessie install on a Raspberry Pi 2

  2. Install some libraries

    $ sudo apt-get install python-pip

    $ sudo pip install pynmea2

  3. Change console tty to free up HW UART

    $ sudo nano /boot/cmdline.txt

    Change contents from:

    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 roo tfstype=ext4 elevator=deadline fsck.repair=yes rootwait

    To:

    dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

    Note: we're removing console=ttyAMA0,115200 from the file.

    You can also achieve this by doing sudo raspi-config, selecting option 8, going to 'Serial' and turning .

  4. disable getty on serial

    $ sudo systemctl disable [email protected]

  5. reboot the Pi

    $ sudo reboot now

import serial
import pynmea2
from ISStreamer.Streamer import Streamer
streamer = Streamer(bucket_name="GPS", ini_file_location="./isstreamer.ini")
serialPort = serial.Serial("/dev/ttyAMA0", 9600, timeout=0.5)
def parseGPS(str):
if str.find('GGA') > 0:
msg = pynmea2.parse(str)
streamer.log("Location", "{lat},{lon}".format(lat=msg.latitude,lon=msg.longitude))
print "Timestamp: %s -- Lat: %s %s -- Lon: %s %s -- Altitude: %s %s" % (msg.timestamp,msg.lat,msg.lat_dir,msg.lon,msg.lon_dir,msg.altitude,msg.altitude_units)
while True:
str = serialPort.readline()
parseGPS(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment