How to get GPS data?

Tried to get GPS position but not getting a response.

I turn on the GPS with:

AT+QGPS=1

that works fine (I get an OK response). But then I send the command:

AT+QGPSLOC=2

and not response is given by the module.

Hi @miguel.won,
Read the data from another port.(ex. /dev/ttyUSB1)
Python code to obtain the GPS values:

  1. Download gpstest.py script
    wget https://raw.githubusercontent.com/sixfab/Sixfab_RPi_3G-4G-LTE_Base_Shield/master/tutorials/GPS/gpstest.py

  2. Change the permission of the script.
    sudo chmod +x gpstest.py

  3. And run the code with the following command.
    sudo python3 gpstest.py

And ensure that you are able to see the sky.

Best regards.

Thanks.
I’m getting some odd raw data:

Receiving GPS data
raw: b'$GPVTG,,T,,M,,N,,K,N*2C\r\n'
Printed data is b'$GPVTG'
raw: b'$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n'
Printed data is b'$GPGSA'
raw: b'$GPGGA,,,,,,0,,,,,,,,*66\r\n'
Printed data is b'$GPGGA'
raw: b'$GPRMC,,V,,,,,,,,,,N*53\r\n'
Printed data is b'$GPRMC'
raw: b'$GPVTG,,T,,M,,N,,K,N*2C\r\n'
Printed data is b'$GPVTG'
raw: b'$GPGSA,A,1,,,,,,,,,,,,,,,*1E\r\n'
Printed data is b'$GPGSA'
raw: b'$GPGGA,,,,,,0,,,,,,,,*66\r\n'
Printed data is b'$GPGGA'
raw: b'$GPRMC,,V,,,,,,,,,,N*53\r\n'

Hi @miguel.won,

We recommend to test it under the open sky. How long did you test it?
No problem with an internet connection, right?
Did you check the antenna if they are loosely connected? Did you try with a different antenna?

Ok, I will test in the open sky. Internet connection is ok.

Noob question about the antena. Do I have to connect a GPS antenna like this one?

Currently, I’m only using this antenna.

Yes, you should use a GNSS antenna.

Ok, thanks. That’s probably why I’m not reading good numbers. I’ll order a antenna.

The provided tutorial script requires a few modifications when working with python3.
Most notably serial requires encode() for writing and .decode() for reading.

1 Like

For those who might find this helpful. Open gpstest.py file.

Replace:
data = ser.readline()
With:
data = ser.readline().decode(‘utf-8’)

Replace:
serw.write(‘AT+QGPS=1\r’)
With:
serw.write(‘AT+QGPS=1\r’.encode())