This python script will show each character received, simply to prove that the GPS device is outputting data:
Code: Select all
#!/usr/bin/env python
import sys
import serial
def init():
ser = serial.Serial()
ser.baudrate = 4800
ser.port = '/dev/ttyUSB0'
ser.open()
if not ser.isOpen():
print("Unable to open serial port!")
raise SystemExit
while True:
gps = ser.read(1)
print gps
try:
init()
except KeyboardInterrupt:
print "Done."
If you see random characters such as below then your baud rate is probably wrong.$
G
P
G
G
A
,
1
9
1
I believe these are the only prerequisites other than Python 2.x:à
†
f
x
ø
x
†
python-serial, python-flask, python-requests, pyRestDb, pyNmea-RaspberryPi
Code: Select all
sudo apt-get install python-serial
sudo apt-get install python-flask
sudo apt-get install python-requests
sudo mkdir pyrestdb
cd pyrestdb
sudo wget https://github.com/rmamba/pyRestDb/archive/master.zip
sudo unzip master.zip
cd ..
sudo mkdir pynmea
cd pynmea
sudo wget https://github.com/rmamba/pyNmea-RaspberryPi/archive/master.zip
sudo unzip master.zip
I used 2 terminal windows for the next part.
Run the pyrestdb module in 1st terminal:
Code: Select all
sudo python /path-to-pyrestdb/pyRestDb.py
Run the pynmea gpsd module in 2nd terminal:* Running on http://0.0.0.0:666/
Code: Select all
sudo python /path-to-pynmea/gpsd.py start
This means that the data is being sent and the summary is served up at http://raspberry-Pi-IP-Add:666* Running on http://0.0.0.0:666/
127.0.0.1 - - [19/Nov/2014 15:00:32] "POST /post/GPS HTTP/1.1" 200 -
127.0.0.1 - - [19/Nov/2014 15:00:32] "POST /post/GPS HTTP/1.1" 200 -
127.0.0.1 - - [19/Nov/2014 15:00:34] "POST /post/GPS HTTP/1.1" 200 -
127.0.0.1 - - [19/Nov/2014 15:00:35] "POST /post/GPS HTTP/1.1" 200 -
If you visit http://raspberry-Pi-IP-Add:666 you will see a summary page of the GPS output,with all kinds of info including a Google maps link to your current location, satellites tracked, lat, long, speed, etc.
To be able to query specific info, you can use this schema:
Which will output a page to your browser that only contains the # of satellites tracked.
To check other info, just use the output page or documentation to figure out what it's called. Here's a short list of examples:
I don't have a project to apply this to right now, but as you can see the data is right there ready to be queried at the specific links.
This python solution uses about 13% CPU on my stock B+ Pi.