In this tutorial, we will learn how to get GPS data using Sixfab HATs with Quectel modules.
GPS(Global Positioning System) also known as NavStar indicates the position of an individual on the Earth. The satellite orbiting around the Earth sends precise details of their positions at a regular interval of time. Once the information is received by a GPS receiver, a GPS receiver can pinpoint the location. There are also navigation systems that support their specific regions like GLONASS provided in Russia.
In this article, we’ll explain how to use Python to obtain the positioning data from the LTE module and use it in your own projects.
It is important to properly setup your hardware before you get started.
They send strings that contain GPS data and other status messages. These strings are called NMEA sentences. You can access those commands by directly reading the serial port.
To use the GPS data in Python, you can directly read the strings that the module sends to the Raspberry Pi’s serial port. However, you’ll have to do all the parsing and error handling yourself.
The Python script below shows how to access GPS data by connecting directly to the serial interface.
It filters on $GPRMC NMEA sentences and then splits the well know attributes into different variables.
pip3 install pyserial
sudo chmod +x GPS.py
- Make sure the USB is connected.
- Check whether there is any interference in your test environment and see if a quality GPS signal is received.
- Place the GPS antenna in a location that has a clear line of sight to the sky in all directions.
- If sufficient GPS signal still can't be acquired, test your modem in a different location.
- Place the GPS antenna as high as physically possible.
- Please check the module firmware version with ATI command, we need to confirm whether the module you used can support GPS or not.
- It is better to check the satellite signal quality via NEMA sentence.
- Please inquire the GPS/GNSS on/off state. If it's off, you need to turn on GPS/GNSS.
- Check the module's configuration with the AT commands below:
AT+QGPS? # Should return 1
AT+QGPS=1 # If previous command returns 0
AT+QGPSLOC? # Obtain Positioning Information. Wait few seconds before sending this command.
AT+QGPSCFG="outport" # GNSS output port configuration, should return usbnmea
If you are getting +CME ERROR: 516, this means the location is not fixed yet. Either continue to wait for a few minutes, or move the GPS antenna near a window or outside.