Getting Lat, lng from GPS at the occurrance of an event

Home Forums Forums General discussion Getting Lat, lng from GPS at the occurrance of an event

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17375
    gius22
    Participant

    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:

    Using python with a GPS receiver on a Raspberry Pi

    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()
    parseGPS(data)

    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,

    Giuseppe

    #17645
    djmaxwell
    Participant

    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.

    #18194
    gius22
    Participant

    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.

    Best regards,

    Giuseppe

     

     

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop…