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 1 post (of 1 total)
  • Author
  • #17375

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

    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,


Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop…