Working on a data acquisition project where I am trying to send GPS data to cloud.
Board: Customised board based on the schematics of Raspberry Pi Compute Module 3 Lite and I/O baord. Have added GSM and GPS modules to it for my requirements.
OS : Raspbian Stretch Lite (June 2018 release, latest one)
GPS Module used: Ublox EVAM8M
My code:
from systemd import journal
import gps
import time
import threading
import datetime
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
while True:
try:
report = session.next()
# Wait for a 'TPV' report and display the current time
# To see all report data, uncomment the line below
# print report
if report['class'] == 'TPV':
if hasattr(report, 'time'):
timestamp = report.time
print timestamp
journal.send(
channel='gps',
priority=journal.Priority.INFO,
timestamp="%f" % (time.time()*1000),
)
if report['class'] == 'TPV':
if hasattr(report, 'lat'):
lat = report.lat
print lat
journal.send(
channel='gps',
priority=journal.Priority.INFO,
lat='lat',
)
if report['class'] == 'TPV':
if hasattr(report, 'lon'):
long = report.lon
print long
journal.send(
channel='gps',
priority=journal.Priority.INFO,
long='long',
)
if report['class'] == 'TPV':
if hasattr(report, 'alt'):
altitude = report.alt
print altitude
journal.send(
channel='gps',
priority=journal.Priority.INFO,
altitude='altitude',
)
except KeyError:
pass
except KeyboardInterrupt:
quit()
except StopIteration:
session = None
print "GPSD has terminated"
I got this code from an Adafruit tutorial: https://learn.adafruit.com/adafruit-ult ... i?view=all and I installed systemd from pypi: https://pypi.org/project/systemd/ . While I am able to perfectly display timestamp, lat, lon and alt on the terminal, I am not able to send this data to the cloud. I know this because I receive the timestamp alone on the journal but not the other values. I also have another python code which does the exact same thing, and I am able to see all the data on the website. I am using python3 and not python to run that code. But the problem with that code is that, it causes the CPU to get really hot (that's another story altogether) hence I cannot use that code.
Coming back to the code here, what am I missing? I am not getting any error. Just that, I see nothing on the website.