8-second delay observed between successive $GPGGA or $GPRMC sentences

Hello,

I’ve encountered an issue with the NMEA sentences I’m receiving from my Quectel module.

Problem: When I read the NMEA sentences, I observe a consistent delay of 8 seconds between two successive $GPGGA or $GPRMC sentences. This delay is unexpected, as the timestamps within the NMEA sentences themselves suggest they should be generated 1 second apart. For example:

  • The first $GPGGA message is timestamped at 075623.00.
  • The second $GPGGA message is timestamped at 075624.00.

This implies a 1-second interval between the messages based on their timestamps. However, in practice, I’m seeing them with a 8-second delay when reading them via Python’s serial library.

I’ve double-checked my Python code and the serial communication setup, and there doesn’t seem to be any issue on that end that could introduce such a delay.

Setup:

  • Quectel module configuration:
    Sixfab Raspberry Pi 3G/4G & LTE Base HAT
    EG25-G Mini PCIe.
    EG25GGBR07A08M2G_30.006.30.006
  • Using Python with the serial library for communication.
    portwrite = “/dev/ttyUSB2”
    port = “/dev/ttyUSB1”

serw = serial.Serial(portwrite, baudrate=115200, timeout=1, rtscts=True, dsrdtr=True)
ser = serial.Serial(port, baudrate=115200, timeout=0.5, rtscts=True, dsrdtr=True)

Database:

45.20855215 5.760656866666 232.3 0 2023-09-17T07:53:42.056269Z
45.208552116666 5.76065685 232.3 0 2023-09-17T07:53:50.130236Z
45.2085521 5.76065685 232.3 0 2023-09-17T07:53:58.196584Z
45.208552116666 5.760656816666 232.3 0 2023-09-17T07:54:06.269056Z
45.208552116666 5.760656783333 232.3 0 2023-09-17T07:54:14.353320Z
45.208552116666 5.76065675 232.3 0 2023-09-17T07:54:22.421426Z
45.208552116666 5.760656733333 232.3 0 2023-09-17T07:54:30.480493Z
45.208552116666 5.760656716666 232.3 0 2023-09-17T07:54:38.549212Z
45.208552133333 5.760656633333 232.2 0 2023-09-17T07:54:47.639518Z

Has anyone else encountered a similar issue? Any suggestions on what could be causing this discrepancy and how to fix it?

Thank you in advance for your insights!

Hi Bouarfa Mahi,

  1. Can you read the NMEA output directly from EG25G?

  2. Can you add timestamp in your program? So that we can check if there is delay on the program or not.

Best regards.

Hi Raphael

below is the output of the data stream processor.
between each $GPGGA sequence there are 7 seconds.

Raw Data: $GPGGA,101639.00,4512.510029,N,00545.640676,E,1,08,0.8,230.3,M,49.0,M,*63

Raw Data: $GPVTG,0.0,T,0.8,M,0.0,N,0.0,K,A*2B

Raw Data: $GPRMC,101639.00,A,4512.510029,N,00545.640676,E,0.0,0.0,211223,0.8,W,A,V*54

Raw Data: $GPGSA,A,3,07,13,14,15,20,22,24,30,1.1,0.8,0.7,1*23

Raw Data: $GPGSV,4,1,13,05,50,220,31,07,10,064,33,13,76,338,44,15,41,302,49,1*63

Raw Data: $GPGSV,4,2,13,20,21,188,36,22,55,126,33,24,16,255,40,30,39,061,39,1*63

Raw Data: $GPGSV,4,3,13,08,03,028,14,55,088,17,03,119,18,08,298,1*6B

Raw Data: $GPGSV,4,4,13,23,06,326,1*56

Raw Data: $GPGGA,101640.00,4512.510035,N,00545.640658,E,1,09,0.8,230.3,M,49.0,M,*6D

import psycopg2
from time import sleep
import serial

# Database Configuration
conn = psycopg2.connect(
    dbname="qdb",
    user="admin",
    password="quest",
    host="docker_host_ip_address",
    port="8812"
)

# Create table if it doesn't exist
with conn:
    cursor = conn.cursor()
    cursor.execute("CREATE TABLE IF NOT EXISTS gps_data (latitude DOUBLE, longitude DOUBLE, altitude DOUBLE, speed DOUBLE, timestamp TIMESTAMP) TIMESTAMP(timestamp) PARTITION BY DAY;")


# Serial Configuration
portwrite = "/dev/ttyUSB2"
port = "/dev/ttyUSB1"

def parseGPS(data, speed=None):
    if data[0:6] == "$GPGGA":
        sdata = data.split(",")
        time = sdata[1]
        lat = sdata[2]
        dirLat = sdata[3]
        lon = sdata[4]
        dirLon = sdata[5]
        altitude = sdata[9]

        latitude = float(lat[:2]) + float(lat[2:])/60
        if dirLat == 'S':
            latitude = -latitude

        longitude = float(lon[:3]) + float(lon[3:])/60
        if dirLon == 'W':
            longitude = -longitude

        altitude = float(altitude)

        with conn:
            cursor = conn.cursor()
            cursor.execute("INSERT INTO gps_data (latitude, longitude, altitude, speed, timestamp) VALUES (%s, %s, %s, %s, NOW());",
                           (latitude, longitude, altitude, speed))

    elif data[0:6] == "$GPRMC":
        sdata = data.split(",")
        speed = float(sdata[7]) * 1.852  # Convert knots to km/h

    return speed

print("Connecting Port..")
try:
    serw = serial.Serial(portwrite, baudrate=115200, timeout=1, rtscts=True, dsrdtr=True)
    
    # Enable GPS
    serw.write('AT+QGPS=1\r'.encode())
    response = serw.readline().decode('utf-8')
    print("Modem Response for AT+QGPS=1:", response.strip())    
    serw.close()
    
except Exception as e: 
    print("Serial port connection failed.")
    print(e)

print("Receiving GPS data\n")
ser = serial.Serial(port, baudrate=115200, timeout=0.5, rtscts=True, dsrdtr=True)
speed = None
while True:
    data = ser.readline().decode('utf-8')
    print("Raw Data:", data)  
    speed = parseGPS(data, speed)
    sleep(1)