[Project] Display GPS Location on OLED
-
I have finally gotten my project to work and can now display my current GPS location in a formatted way on the OLED screen. Thanks to help on this community, I finally had the last 2 lines of code that allowed the string to be manipulated like I needed it to. I have put up a project on Hackster.io that shows everything I did to get it working. I dont want to reinvent the wheel here, so I will link to that project.
Who knows, maybe it will be good enough to link in the Onion WIKI?
GPS Info to OLED Project on Hackster.io
Here is what the output looks like: (crappy photo, I know)
-
I have the "TODO" finished, and will upload it when I get back to my computer. Basically, if the GPS does not have a fix, it returns {"signal":"false}. I have the Python script testing for the existence of the "signal" key, and it if exists, it prints to the OLED there is no signal. If it doesn't exist, it checks for the existence of the "latitude" key, and if it exists, it prints the GPS location info to the OLED. If that doesn't exist (empty file, for some reason) the script will display that as well, and then exit.
-
Project has been updated on Hackster.io. It now takes into account for a 0 byte (empty) file as well as a file that notes there is no GPS signal. I hope you find it interesting, or at least learn something to use in other project. I mean, the meat of the script is really just to do a file-dump to the OLED screen.
-
Hey mate,
super cool project. loved tinkering with this. just what i needed. i left you some feedback on hackster.io regarding improvements that can be made from some issues i encountered. nothing big though. i'll leave the feedback here too. Well done, really like this
-
in OKPG installs please add the component: python-light . If you don't install this component the python script will fail in the "import time" line
-
in showgps.py line 17 the method is actually oledExp.setTextColumns() not oledExp.setTextColums()
-
in showgps.py line 45 the "if" has to be in small letters. it is currently with a capital I at the moment which is not recognised by python
-
in showgps.py line 51 the "elif" has to be in small letters. it is currently with a capital E at the moment which is not recognised by python
-
Don't forget to remind people that they have to chmod getgps.sh with executable permissions like "chmod 775 getgps.sh" for example.
Love the project mate keep it up
-
-
@Andrew-De-Bono Thanks man! I made the changes to the project, everything should be good to go now.
I want to do the same thing, but with weather now. So, looking how to do pull and format that info. Hope to have a new project up on that soon as well. Maybe this week or so.
-
@Brad-Buskey Line 51 in showgps.py is missing a : at the end.
-
@Brian-Delicata said in [Project] Display GPS Location on OLED:
@Brad-Buskey Line 51 in showgps.py is missing a : at the end.
Got it, thanks.
-
I am working on my next project, which springboards off this one. Using the GPS to grab the current location and then pulling the weather from Weather Underground's API to display the current conditions. I am about 60% complete, most has been written, but now I need to go home and test.
I will post another project up once completed. And I will watch the syntax better this time.
-
Very cool- pretty similar to what I did. I added an animation while it was getting the fix. Just starts marching across the screen. I'll have to upload my script at some point.
FYI, you don't need to save a file with the data. You can call ubus directly:
gpsDataProcess = Popen(["ubus", "call", "gps", "info"], stdout=PIPE) gpsDataJSON = gpsDataProcess.communicate()[0] gpsDataProcess.stdout.close() if ( gpsDataProcess.returncode == 0 ): # gps available gpsData = json.loads(gpsDataJSON)
-
I have this set up and working now but I was wanting to try and leave the heading info off and replace it with the time or something.
I can easily add the system time but I can't see a way (yet) of getting the gps time out. I am thinking at the moment that I will need to extract it from the NMEA data as the ogps calls don't supply it .
-
@Ian-Marchant You could also just grab the system time instead.
-
@Brad-Buskey That's what I am doing at the moment but i know that the GPS time is much more likely to be correct (Unless there is a way of setting the time from the GPS and then it won't matter)
-
Thank you for this project. Nice and easy as a first project with Omega 2.
In my case there is a systematic error in the position returned by "ubus -S call gps info". Not a major one; just a few miles away but it is annoying for a device that should have an accuracy of a few meters
I looked at the source code on github and identified a bug in ugps when the NMEA data is converted.
I was wondering if you ever checked the accuracy of your results, for example by plotting the latitude and longitude on Google Map?
Did you find a fix?
-
@Pi-Phea Thanks for the comments. I have not found any kind of fix, nor would I be the one to likely find it - not a programmer, and no real training. This is really my first forray into this world.
When the name came up on the OLED for the local weather station, it was one that is close enough. (from a different project), but now I am curious to see where my Omega thinks it is.
-
@Matthew-Butch said in [Project] Display GPS Location on OLED:
Very cool- pretty similar to what I did. I added an animation while it was getting the fix. Just starts marching across the screen. I'll have to upload my script at some point.
FYI, you don't need to save a file with the data. You can call ubus directly:
gpsDataProcess = Popen(["ubus", "call", "gps", "info"], stdout=PIPE) gpsDataJSON = gpsDataProcess.communicate()[0] gpsDataProcess.stdout.close() if ( gpsDataProcess.returncode == 0 ): # gps available gpsData = json.loads(gpsDataJSON)
I must be missing something here. I get the following when I run the .py file.
Initializing display
Writing '+-------------------+' to display
Writing '| Current GPS Info: |' to display
Writing '+---------+---------+' to display
Traceback (most recent call last):
File "showgps2.py", line 23, in <module>
gpsDataProcess = open(["ubus", "call", "gps", "info"], stdout=PIPE)
NameError: name 'PIPE' is not defined
-
@Brad-Buskey Did you happen to declare PIPE?
from subprocess import Popen, PIPE
-
Yes sorry missed that part:
from subprocess import Popen, PIPE