GPS on Orange Pi 2G IOT

Recently I got myself a GPS module to play with such as this. Not that I knew much about but felt like something nice to play with. First thing first is connecting the GPS module to the GPIO in Orange Pi 2G. In my case I decided to connect the GPS to ttyS2, asides from VCC (2.8V) and GND. This correspond to pins 1, 6, 8 and 10.
Vcc -> pin 1
GND -> pin 6
TxD -> pin 8
RxD -> pin 10

Pin 1 would be the one just below a small white arrow to the left of the SD card. Below two pictures of GPS connected to Orange Pi GPIO pins.

Another important thing is to cross TxD and RxD cables, that means connecting GPS TxD to Orange Pi RxD and GPS RxD to Orange Pi TxD.
Now that the GPS module is connected to the Orange Pi power it up and log into it. We will now check if the GPS mocule is working, in order to do this we will connect via minicom.

user@computer:$ minicom -D /dev/ttyS2 -b 9600
Welcome to minicom 2.7

Compiled on Apr 26 2017, 00:45:18.
Port /dev/ttyS2, 19:10:00

Press CTRL-A Z for help on special keys


Output is pretty ugly as can be seen but you can see the coordinates in GPGLL entry. In order to have something more readable we install below packages.

user@computer:$ sudo dpkg -l | grep -i gps
ii gpsd 3.11-3 armhf Global Positioning System - daemon
ii gpsd-clients 3.11-3 armhf Global Positioning System - clients
ii libgps21:armhf 3.11-3 armhf Global Positioning System - library
ii python-gps 3.11-3 armhf Global Positioning System - Python libraries

Now copy below script and execute in order to start gpsd and listen on ttyS2.


sudo gpsd /dev/ttyS2 -F /var/run/gpsd.sock

Now I created below python script which prints creates Google Maps URL based on GPS coordinates.

import gps

# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947") | gps.WATCH_NEWSTYLE)

while True:
        report =
        # Wait for a 'TPV' report and display current time
        if report['class'] == 'TPV':
            if hasattr(report, 'time') and hasattr(report, 'lat') and hasattr(report, 'lon'):
                print report.time
                print "Latitude: "+str(", Longitude: "+str(report.lon)
                print "Google Maps URL:"+str(","+str(report.lon)+"\n"
    except KeyError:
    except KeyboardInterrupt:
    except StopIteration:
        session = None
        print "GPSD has terminated"

And we proceed executing.

user@computer:$ python
Latitude: 42.872081491, Longitude: -78.549973218
Google Maps URL:,-78.549973218

Latitude: 42.872081044, Longitude: -78.549972807
Google Maps URL:,-78.549972807

Latitude: 42.872081426, Longitude: -78.549970823
Google Maps URL:,-78.549970823

Latitude: 42.872081634, Longitude: -78.549968307
Google Maps URL:,-78.549968307

Latitude: 42.872082718, Longitude: -78.549965683
Google Maps URL:,-78.549965683

And opening the URL on Google Maps.

Thanks for reading.

Leave a Reply