Python Program To Send Coordinate GPS to Server


This article continues a previous article about the use of GPS devices Ublox Neo 6M on Raspberry Pi. where in the previous article only discussed how to configure GPS Ublox Neo 6M on Raspberry Pi. This time it will be discussed how the python programming language used to transmit GPS coordinates which can to a server.

Before following this article, make sure you have configured the GPS device Ublox Neo 6M as in the previous article so this experiment can succeed. Python used here is using Python version 3, which is also present in the OS Raspbian Strecth. Here are the steps:

1. Install Python Library for gpsd

To access the GPS device Ublox Neo 6M there is python library that makes it easier is gpsd . You can check it on the following link.

to do python library installation can be done by using pip3 command as below:

pip3 install gpsd-py3

Make sure the install process has been successful, with the output as below:

2. Creating Python Scripts

Before creating a python script it's a good idea to try to test whether your GPS device gets a signal, by committing cpgs -s or gpsmon.

After you get the GPS signal. create a python script, the easy way that is with the terminal using nano:


Then create with the script below:

from datetime import datetime
import gpsd
import requests
received = False
packet = gpsd.get_current()
 pos = packet.position()
 received = True
except Exception:
 print("no signal")
if received == True:
 url = "http://your server address fill here/"
 lat = pos[0]
 lon = pos[1]
 tgl ='%Y-%m-%d')
 wkt ='%H:%M:%S')
 data = {'waktu':wkt, 'tanggal':tgl, 'lat':lat, 'lon':lon}
 r =, data=data)
 print (r.status_code)

Please note that sending data using POST method so that in PHP script on server need to take data with POST method, data is sent that is time, date, latitude and longitude. date and time data obtained from Raspberry Pi not from GPS data.

After creating the script as above. save the program by pressing CTRL + O and exit with CTRL + X.

To run the program that is with the command in the terminal as follows:

If data is sent will produce output 200 which is code response that the request has succeeded

That;s sharing Raspberry Pi project from me, hope useful and good luck :)

Python Program To Send Coordinate GPS to Server Python Program To Send Coordinate GPS to Server Reviewed by rayakyfa on May 29, 2018 Rating: 5


  1. Woah this blog is wonderful i like studying your posts. Keep up the great work! You understand, lots of persons are hunting around for this info, you could help them greatly.
    python Training institute in Chennai
    python Training institute in Bangalore

  2. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    Uipath Training in Chennai with Placement
    AWS Training in Chennai with Placement
    Blue Prism Training in Chennai with Placement

  3. how can I take data with php script. Please give me that code. Thanks!

    1. This is

      $lat = $_POST['lat'];
      $lon = $_POST['lon'];
      $time = $_POST['wkt'];


  4. There is lots of Post about Python But your way of Writing is so Good & Knowledgeable. Thanks for Sharing a Nice & Informative Information
    Python Training in Delhi
    Python Training in Noida
    Python Training in Gurgaon

  5. We’ve also seen an alarming number of complaints about connection issues with SkyBell cameras. The SkyBell Trim Plus, the newer, slimmer sibling of the SkyBell HD, was a solid contender due to its modest size, ability to integrate with other smart devic wireless door bell

  6. GPS (Global Positioning System) technology is undoubtedly one of the most important and critical technologies present in the world right now. The applications of an ideal GPS tracking software range from simple personal activities like driving to complex business activities like assets management. Electronic Logging Devices

  7. When you consolidate the intrigue of the customary space machine with the advancement of electronic games, video poker is the thing that you will get. machine learning certification

  8. GPS runs via a network of around 30 US satellites, using the Global Navigation Satellite System (GNSS) to transmit microwave signals to GPS devices. By figuring out how far away it is from the satellites, a GPS tracker (or any kind of GPS device, such as a sat nav), is able to pinpoint its exact location from anywhere on the planet. Electronic Logging Devices


Powered by Blogger.