Jpeg

In this tutorial we will learn how to get GPS data using 3G, 4G/LTE shield.

GPS(Global Positioning System) also known as NavStar indicates the position of an individual on the earth. The Satellites orbiting around the earth sends precise details of their positions at a regular interval of time. Once information are received by a GPS receiver, a GPS receiver can pinpoint the location.

There are also navigation systems which support in their in specific regions like GLONASS provided in Russia.

For this tutorial we will need
a. Raspberry Pi
b. 3G, 4G/LTE Shield
c. 3G, 4G/LTE module (for 3G UC20 and for 4G EC25 is used)
d. PCB Mobile Antenna (2x)
e. GPS Antenna
Here it goes

 

1. Connect EC25 module to the shield.

Jpeg

Sixfab 3G,4G/LTE shield and EC25 module

Jpeg

EC25 module connected to shield

2. Insert SIM in the sim slot

Jpeg

Inserting Sim

3. Connect the shield to a Raspberry Pi

Jpeg

Shield attached to Raspberry Pi 3

4. Now connect antenna to the ports as shown in the figure below

Jpeg

Connecting Antenna

5. Now connect a microUSB to the shield from Raspberry Pi.

Jpeg

Tracker setup

So the setup is ready for tracking.

Now we can power our Raspberry Pi and control trough terminal as done in previous tutorials.

GPS data can be obtained either using minicom or writing your own python code.

***************************************MINICOM***************************************

6a. Type

to bring up the minicom settings screen

7Opening minicom

6b. Select Serial port setup

8

minicom configuration screen

6c. Make the following changes

Serial Device : /dev/ttyUSB2

Hardware Flow Control : No

9

Configuring Serial Port Setup

6d. Now Exit from the setting screen

10

Exiting from minicom configuration screen

6e. Check connectivity with ‘AT’ which in response gives ‘OK’ or returns an error.
11

minicom screen

12

minicom screen

6f. Now type ‘AT+QGPS=1’ turns on the GNSS(Global Navigation Satellite Systems) engine.

13

minicom screen

6g. Again go to minicom settings > Serial Port Setup and make the following changes.

Serial device : /dev/ttyUSB1  

Hardware Flow Control : No

14

Configuring Serial Port Setup

6h. Exit from the settings screen which will bring up following screen with GPS NMEA data.

15

GPS Data

 

****************************************************Pyhton****************************************************

Now we will write a python code to obtain the GPS values

7a. First create a python file by the following command.

16

Opening .py file

 

7b. Now type the following python code in the file and save it.

 

7c. After saving it we will run the code with following command.

18

Running .py file

19

GPS data received

Similarly depending on the code required values from the data can be extracted.

 

9 thoughts on “GPS Tracker with 3G, 4G/LTE shield”

  1. I’m getting the broken pipe error when running the serial.Serial function from the script, any idea on this one? It works fine from the minicom though.

  2. I am using same code as mention, but getting following error.
    Can you please guide.

    [email protected]:~ $ sudo python gps.py
    Connecting port
    Receiving GPS data
    raw: $GPVTG,,T,,M,,N,,K,N*2C

    —–Parsing GPRMC—–
    Traceback (most recent call last):
    File “gps.py”, line 48, in
    parseGPS(data)
    File “gps.py”, line 14, in parseGPS
    time = sdata[1][0:2] + “:” + sdata[1][2:4] + “:” + sdata[1][4:6]
    UnboundLocalError: local variable ‘sdata’ referenced before assignment
    [email protected]:~ $

    1. The issue is related to the indentation of the code:
      – lines 12 and 13 should be more indented in order to be considered part of the “if” statement at line 11
      – lines 14 to 29 should be indented at the same level as line 10 and 11. Doing that will make lines 14 to 29 part of the same block as sdata (line 10) and thus will resolve the issue.

      I also had to change “degreeChecksum” at line 25 from index 11 to 12

  3. When my pi loses power it seems the minicom setting are resetting. how to make theses setting persistent?

Leave a Reply

Your email address will not be published. Required fields are marked *