Get position from GPS using Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello uh I'm going to write a little Python program to get the GPS data from a GPS device and I'm just going to get the latitude and longitude and uh the device I'm going to use is a GPS device from bang good it's uh this one it's very cheap but every standard GPS module Works uh GPS module I have use this also is the same it's not USB serial because the GPS devices uses a standard protocol called nmo and enemia has different sentences with different kind of information and the one I'm going to look at is G GPR RMC recommend minimum specifications this one so I have the GPS connected to my computer let's check it uh T let's connect to it and see uh I use Linux but uh it should python Works in Windows and Mac and all kind of system also and the speed is 9,600 BPS no oh I Ty wrong ACM Z yeah here I get the data and I get RMC here time V means no fix I have it by my computer here so it can't see this guy at the moment and in this folder here I have a file called GPS test.py and that's the same file I have open in Sublime Text Editor so let's start programming I use a library called python serial import serial and then I'm just going to open the device I'm going to name it GPS and serial do seral and the device that is Dev TTU AC AC ACM Z and then Bo rate equals 9,600 so I'm first I'm going to check to see if it works I run it by just typing Python and the file name and it seems to work otherwise it would have shown an error message here but this is looks nice and now I'm going to create the endless loop while true and then I'm going to read a line from the DPS line equal DPS do read line and we can print it first to check if it works now we should just print the sentences here and it does so now I just I'm going to divide everything here is comma every value here is comma separated so now I'm going to divide the lines up into uh a list that's like an array let's call it data equals line dolit and the split CH is one of these and then I'm going to print the first one one here now it's just that's number zero so print data zero so if it works now it will only print the first things there yeah and it does and now we're only interested in the RMC so if data Z equals to uh dollar DPR RMC then print line now I will just check and print the line if the data is equal to GP RMC they recommend a minimum sentence there and it works uh and now I'm going to check this here if it's valid or not so it's 0 one 2 print let's see to print data two yeah that's working and now I want it only to print the latitude and longitude if it has connection if data 2 equals uh I think it was a let's check the information yeah validity a okay V invalid and here is latitude and longitude yeah so here it checks if it's valid and then it's going to show the latitude then I do Tre print uh latitude uh data three longitude four I think it was no five I'm just going to ignore North and South and West in this video here just this is just a demonstration uh wait I have an error yeah I think I need to do it like this perhaps let's Che now no uh why isn't that working print latitud is it s% no% let is string wait a minute let me check what what might be wrong uh print yeah maybe just let's check now yeah now it works and now it doesn't see anything because it hasn't any connection so I'm going to open my window here and I have it on a wire I'm going to put it outside here and wait for it to get connection of course there is in Linux there is a a demon called gpsd that you can use and it's a little bit different but I like to interface with the GPS device directly because uh I work a lot on open VT devices like mini routers and stuff like that that doesn't have a lot of memory yeah now it works it's getting latitude and longitude that's pretty cool so let's say I quit it here and now I just want to save it to a file instead uh for transmission like if you have a Remote device you want to transmit then I can do uh I think I do like this now that's everything that's going to be I just try this first this is going to be in a text file later I think yeah now would print just did that clear that and now I'm going to instead of printing it out I'm going to print it to a file uh with open and then the name of the file uh TPS uh position position. txt and I want it to be writable that's the W there and as py P then I change that P right there if that work I'm not sure if that work doing it like that but let's try it seem to work so let's open up another terminal and go to this directory slash python GPS Test LS position. txt it works but there is one problem it doesn't write a new line so let's add a new line like that and try again start this and chat position yeah now it works so let's say I want to send this uh to another device you can use like in Python can open ports and stuff like that but what I tend to do I just SCP it it's like Linux kind file transfer yeah and now I'm going to show how I send the position to another computer uh now we have a text file that updates automatically every time it gets a new position and now we want to transmit that to another computer so for doing that I do SCP uh position and I transmit it to my router in this case to my home directory there it's been transmitted I have set up public and private key so I don't need to type a password and if you we want to do it once every five five second then we do like this while do sleep five done now it will automatically upload it every fifth second and that's how you do that but I can show you that it's updated on my router too there we have it I can C it there there it changed so that's how I do it with sending GPS position from a remote GPS to uh to uh my computer at home here so I can like track something uh in the next video I can show how I do it convert it to a KML file that can be shown in Google Earth and stuff but yeah that's later have a nice day goodbye
Info
Channel: petleh82
Views: 77,759
Rating: undefined out of 5
Keywords:
Id: _DuMjcl52BU
Channel Id: undefined
Length: 18min 17sec (1097 seconds)
Published: Sun Oct 09 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.