Unable to obtain GPS data

Hi there,

I am not being able to get GNSS data. So far, I have configured my raspberry pi with an internet connection using ECM mode, connected the sixfab base HAT with EC25-E module to raspberry pi along with the antenna, and have run the following code for about 10 minutes under good reach to open sky,

from time import sleep

import serial

portwrite = "/dev/ttyUSB2"

port = "/dev/ttyUSB1"

def parseGPS(data):

    if data[0:6] == "$GPRMC":

        sdata = data.split(",")

        if sdata[2] == 'V':

            print(sdata)

            print("No satellite data available.")

            return

        #  -----Parsing GPRMC-----  #

        time = sdata[1][0:2] + ":" + sdata[1][2:4] + ":" + sdata[1][4:6]

        lat = decode(sdata[3]) #latitude

        dirLat = sdata[4]      #latitude direction N/S

        lon = decode(sdata[5]) #longitute

        dirLon = sdata[6]      #longitude direction E/W

        speed = sdata[7]       #Speed in knots

        trCourse = sdata[8]    #True course

        date = sdata[9][0:2] + "/" + sdata[9][2:4] + "/" + sdata[9][4:6] #date

        variation = sdata[10]  #variation

        degreeChecksum = sdata[12]

        dc = degreeChecksum.split("*")

        degree = dc[0]        #degree

        checksum = dc[1]      #checksum

        latitude = lat.split() # parsing latitude

        longitute = lon.split() # parsing longitute

        print("\nLatitude: " + str(int(latitude[0]) + (float(latitude[2])/60)) + dirLat) 

        print("Longitute: " + str(int(longitute[0]) + (float(longitute[2])/60)) + dirLon)

        #print("time : %s, latitude : %s(%s), longitude : %s(%s), speed : %s, 

        #True Course : %s, Date : %s, Magnetic Variation : %s(%s),Checksum : %s "%  

        #(time,lat,dirLat,lon,dirLon,speed,trCourse,date,variation,degree,checksum))    

  

def decode(coord):

    #Converts DDDMM.MMMMM -> DD deg MM.MMMMM min

    x = coord.split(".")

    head = x[0]

    tail = x[1]

    deg = head[0:-2]

    min = head[-2:]

    return deg + " deg " + min + "." + tail + " min"

print("Connecting Port..")

try:

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

    serw.write('AT+QGPS=1\r'.encode())

    serw.close()

    sleep(0.5)

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)

while True:

   data = ser.readline().decode('utf-8')

   parseGPS(data)

I am only getting the following error.

a. How might be the cause?
b. How do I assign port and portwrite values? Can that be the reason?
c. Can a static charge issue on the Quectel module damage the GPS?

Thanks in advance.

Regards,
Saman

Hi Saman,

Which GPS antenna are you using?
Please confirm the antenna is clipped firmly to the port.