Home › Forums › Forums › General discussion › Getting Lat, lng from GPS at the occurrance of an event
- This topic has 2 replies, 2 voices, and was last updated 2 weeks, 2 days ago by gius22.
- August 1, 2022 at 4:56 am #17375gius22Participant
Hi, I am new here and in programming.
I have a RPI zero connected to a beitan bn220 gps moodule on /dev/serial0, with Rsapberry pi OS (32bit), Bullseye, gpsd installed.
My question is not related to a specific gps module.
I would like to get Lat and Lng at a specific moment when an event occurs, e.g. “pushing ” a button and then write these waypoint Lat and Lng on a file. I can manage the “switch” part.
I would need help for this (in pseudo code):
if an event occurs
get Lat, Lng from nmea string; #this is the important part
write data on a file;
I read your guide:
I am trying to modifying the code in “Manually parsing NMEA sentences” (almost the same as in “Using pynmea2 to parse NMEA sentences”) accordingly as for my purpose. The important part:
ser = serial.Serial(port, baudrate = 9600, timeout = 0.5) #my gps module baudrate is 9600; what means “timeout = 0.5”? Does it stop the data stream for 0.5 s?
while True: # I suppose here I have to put the occurrance of an event
data = ser.readline()
And in def parseGPS(data) do I have to change the print part with “write to a file”?
Sorry for such a long question.
Thank you for any help,
GiuseppeDecember 12, 2022 at 7:33 am #17645djmaxwellParticipant
First, the timeout value is how long your read will block waiting for the data.
Moving on to the other part of your question, the GGA messages come at a fixed rate from the GPS. This defaults to 1Hz, but many modules allow you to increase that. You want to be continually reading the data and potentially storing at least some amount of history.
If you are wanting to get the position at a specific time, you have a few options, depending on your velocity and accuracy needs.
1) The simplest approach would be to take the most recent GPS position as the requested position
2) Dead reckon to the requested time. This would use your data history to calculate where you will be at the requested time.
3) Wait for the next position message and interpolate between the two positions to the requested time.May 19, 2023 at 2:22 am #18194gius22Participant
Thank you very much,
I have left the project aside during the last months due to my job.
I would like to use rpi and gps module to save lat and lng of points where I take pictures (my camera has no gps) this way:
when I take a picture I push a button connected to rpi and gps module to write lat and lng of that point on a file.
As far as I know Python would be fine for the coding.
I am looking on the net for some tutorial because I know nothing of programming.
Any hints would be much useful.
- You must be logged in to reply to this topic.