Obtaining GPS position with Telit module

Hi there,

I was trying to figure out how to obtain GPS position with the 3g-4g-lte Base HAT and a Telit LE910C4-EU using this tutorial. My final goal here is to have a python script that obtains NMEA sentences as soon as the RPi is turned on.

When following the instructions under the “Telit Modules” section, I noticed I can’t write any commands after running sudo minicom -b 115200 -D /dev/ttyUSB2 in the terminal, like the tutorial suggests. I got some messages I honestly don’t understand:

After that I tried to run the following command:
sudo minicom -b 115200 -D /dev/ttyUSB3
And it worked, I was able to perform all the steps in the tutorial:

And when running the last command in the tutorial, sudo minicom -b 115200 -D /dev/ttyUSB1 I was able to see the NMEA stream (without real data because I was sitting inside a building, but that is not the issue).

After that, I tried to run the python code suggested in the “Quectel Modules” section, with the unnecessary part removed:

from time import sleep
import serial

port = "/dev/ttyUSB1"

def parseGPS(data):
    print(data, end='') #prints raw data
    if data[0:6] == "$GPRMC":
        sdata = data.split(",")
        if sdata[2] == 'V':
            print("\nNo satellite data available.\n")
        print("-----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[13] #Checksum
        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("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')

And it seemed to work - gave me a stream of NMEA sentences.
The problem is when I reboot the RPi, I have to set up the module’s GPS configuration from the beginning, as it probably goes back to its default settings. So, my question is:

  1. Is there a way to perform the configuration step (with the minicom command, shown in the second image) using some python lines?
  2. Alternatively, is there a way to make the module not reset its settings when rebooted?
  3. What was I seeing when I ran the sudo minicom -b 115200 -D /dev/ttyUSB2 command? (in the first image)

Thanks in advance,

Hi Guy,

The purpose of the Python script is to make the raw data readable. If you want, you can read unparse data by just listening to the port.

You can do it with a service or a script.

It shows the operations of the module in the background on the serial port.