GPS receiver using arduino interface and working

This project describes the method to display the NMEA format GPS data on the PC monitor.gps interfacing with arduino uno

GPS module sim28ml

Here a SIMCom SIM28ML GPS Module is using to receive the GPS data. Using the module the received data can be displayed directly on any serial terminals. Hyper terminal, putty, Arduino serial monitor, etc. can be used to display the data.

To connect the module to the PC, it has to be interfaced via a USB port. The interface option available for the module would be either Rs232 or TTL or both. Use a suitable converter such as Rs232-USB or TTL-USB converter for connecting to the PC (TTL to USB converter using arduino Uno board). The module can power with a 12V DC input through a DC jack socket. Also, a +5V  or +3.3V supply can use directly with the board.

arduino gps module interface

Select the port connection of the device, which has listed such as COM1, COM2…COMX. Set the baud rate exactly as specified for the GPS module. The baud rate may be different for various module devices. So, it should be ensured that both the serial terminal and module has the same baud rate. Commonly the module has a baud rate of 9600bps.

After the Power On, the module takes few minutes to receive the signal. After modem establishes a connection with the GPS, the TIMEMARK LED begins to blinks once in a second. Once the signal has received, the serial monitor display’s the GPS data in NMEA (National Marine Electronics Association standard) sentence. NMEA is a specification for communication between various marine electronic equipment.

GPS NMEA data format

nmea output text, gps nmea data

NMEA output sentence on Arduino serial monitor.

$GPRMC,062652.000,A,1005.2307,N,07626.0931,E,0.06,163.36,151216,,,A*60

$GPGGA,062653.000,1005.2304,N,07626.0930,E,1,4,5.63,24.3,M,-93.5,M,,*45

$GPGSA,A,3,21,24,32,20,,,,,,,,,5.70,5.63,0.93*0C

$GPGSV,3,1,09,21,68,066,44,32,60,271,33,18,35,016,19,39,30,261,24*76

$GPGSV,3,2,09,24,24,060,43,20,07,074,34,193,,,39,14,,,27*40

$GPGSV,3,3,09,25,,,33*77

hyperterminal gps dataNMEA format data on hyperterminal

A direct interface to the serial monitor gives the output data in a set of lines of information, including longitude, latitude, time, date, etc.

Considering the value of latitude and longitude only.

$GPRMC,062652.000,A,1005.2307,N,07626.0931,E,0.06,163.36,151216,,,A*60

     RMC        Recommended Minimum sentence

$GPGGA,062653.000,1005.2304,N,07626.0930,E,1,4,5.63,24.3,M,-93.5,M,,*45

     GGA         Global Positioning System Fix Data

1005.230, N  – Latitude is in DDMM.MMMMM format,  Latitude 10 deg 05.230’N

     07626.093, E  – Longitude is in DDDMM.MMMMM format, Longitude 76 deg 26.093′ E

N, E, W, S represents North, East, West, and South respectively.

Get Your GPS Latitude and Longitude on screen

A direct interface to the serial monitor gives the output in the form of standard NMEA sentence, which includes many data as bulk content of lines. But, here we are extracting the Latitude and Longitude coordinate values from the NMEA standard sentence.  So, this program will be more useful for those who are looking to get only the latitude and longitude from the long NMEA text.

arduino gps latitude longitude

For the Arduino coding, we are using a library function called TinyGPS. In the code, the variable “slat” and “slon” hold the coordinate values of the latitude and longitude respectively. The GPS module is interfaced with Arduino using software serial; pin 5 is defined as Receiver (RX) and pin6 as Transmitter (TX).

GPS Interfacing with Arduino Uno

Arduino Pin GPS Module Pin
TX (pin 6) RX
Rx (pin 5) TX
GND GND

Arduino GPS module code

#include <SoftwareSerial.h>
#include <TinyGPS.h>

TinyGPS gps;
SoftwareSerial sgps(5, 6);

void setup()
{
  Serial.begin(9600);
  sgps.begin(9600);
}

void loop()
{
  while (sgps.available())
  {
    int c = sgps.read();
    if (gps.encode(c))
    {
float slat,slon;
      gps.f_get_position(&slat, &slon);
      Serial.print("Latitude :");
      Serial.println(slat, 6);
      Serial.print("Longitude:");
      Serial.println(slon, 6);
    }
  }
}
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

41 Responses

  1. Anand Yadav says:

    Could you please put a working circuit diagram of the above connection. I am same GPS receiver that is SIM28ML, and arduino board. I am not getting any value in serial monitor.
    I need help!! Please . Or can you suggest me where should I look for?

    • admin says:

      The interface of sim28ml with arduino is just a TTL interface.
      Rx->Txpin6
      Tx->Rxpin5
      3.3v->3.3v
      GND->GND

      First of all make sure that your gps module is receiving data(green TMRK led flashes when GPS is fixed). Try directly to a hyper terminal or serial monitor, and check whether the module is receiving NMEA sentence data. While using with arduino, make sure that your arduino IDE has a gpstiny library function.

  2. Nagamallasaiteja says:

    Bro same problem that I received that the gps doest works after twrk blinks

    • admin says:

      If the TIMEMARK LED blinks every second, it means the GPS is receiving the signal. So, you should check the communication between the GPS and the Arduino or Hyperterminal.

  3. aajkiya mukesh says:

    i work GPS program run success but location is not found so plzzz help me

  4. Pramod says:

    tmrk isnt blinkig at all , need help.

    • admin says:

      Timemark LED takes some time to start blinking. In indoors or under any roofing it doesn’t work fine. So try placing the antenna at different locations, mainly at outdoors and Wait for at least 3 or 5 minutes at each spot.

  5. Ankit tripathi says:

    Thanks it works perfect! But I want latitude and longitude to be shown once on Serial Monitor… tell.me the changes on code

    • admin says:

      Replace the code inside the void loop with below code. Also intialize the int “value” at the begining as ‘0’. Here once the gps is availabe the variable “value” set to ‘1’ and afterwards the if condition always returns false, hence the latitude and longitude can print only once.

      if (sgps.available() && value == 0 )
      {
        value = 1;
        int c = sgps.read();
        if (gps.encode(c))
        {
          float slat, slon;
          gps.f_get_position(&slat, &slon);
          Serial.print("Latitude :");
          Serial.println(slat, 6);
          Serial.print("Longitude:");
          Serial.println(slon, 6);
        }
      }
      
      • Nsaiteja says:

        Sir I need to store the GPS latitude and longitude to a variable how can I do this by changing the code

        • admin says:

          “slat” & “slon” itself a float variable stores the latitude and longitude values respectively. Just use those variables or pass the values to another variables.

  6. Akanksha Singh says:

    why have you taken 6 for both the slat n slon? what does it mean?

    • admin says:

      It is the number of decimal places to use. That is the number of digits to be displayed after the decimal point; here it is 6 digits.

  7. Sarthak Tanwani says:

    Hello Sir, Thanks for the tutorial

    However in my case the GPS module is not transmitting any value.
    The TMRK LED is blinking correctly at 1 Hz. But when I upload code and use it withe my arduino mega, I get nothing on my serial monitor.
    Could you help?
    Thanks

    • admin says:

      Did you try connecting directly to the serial monitor, HyperTerminal, putty, etc (via TTL to USB or RS232 to USB)? Can you able to receive the data as NMEA Text?

  8. velraj says:

    how to connect 16*2 lcd display with this circuit

  9. Albert D says:

    Hi, Anybody have the GPS code for Arduino to display all the data from the receiver.

    • Rovin Mez says:

      This is the complete code to display almost all the available data in the GPS.

      #include <SoftwareSerial.h>
      #include <TinyGPS.h>
      
      TinyGPS gps;
      SoftwareSerial serialgps(4,3);
      int year;
      byte month, day, hour, minute, second, hundredths;
      unsigned long chars;
      unsigned short sentences, failed_checksum;
      
      void setup()
      {
      
      Serial.begin(9600);
      serialgps.begin(9600);
      Serial.println("");
      Serial.println("GPS Shield QuickStart Example Sketch v12");
      Serial.println(" ...waiting for lock... ");
      Serial.println("");
      }
      
      void loop()
      {
      while(serialgps.available()) 
      {
      int c = serialgps.read(); 
      if(gps.encode(c)) 
      {
      float latitude, longitude;
      gps.f_get_position(&latitude, &longitude);
      Serial.print("Lat/Long: "); 
      Serial.print(latitude,6); 
      Serial.print(", "); 
      Serial.println(longitude,6);
      gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
      Serial.print("Date: "); Serial.print(month, DEC); Serial.print("/"); 
      Serial.print(day, DEC); Serial.print("/"); Serial.print(year);
      Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":"); 
      Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC); 
      Serial.print("."); Serial.println(hundredths, DEC);
      Serial.print("Altitude (meters): "); Serial.println(gps.f_altitude()); 
      Serial.print("Course (degrees): "); Serial.println(gps.f_course()); 
      Serial.print("Speed(kmph): "); Serial.println(gps.f_speed_kmph());
      Serial.print("Satellites: "); Serial.println(gps.satellites());
      Serial.println();
      gps.stats(&chars, &sentences, &failed_checksum);
      }
      }
      }
      
      
  10. Ganesh Ram says:

    I am having a sim 900a GSM MODULE and SIM28 GPS module and an infrared sensor. I am doing a project that if any flame occurs near the sensor then the GPS location should be transmitted to a particular mobile number through GSM Module. So can you please post me the code for this project.

    • admin says:

      Refer the project : Send GPS Location Via SMS Arduino.
      The above project might be the best you are looking for.
      This project has a code for sending the GPS location via SMS to a mobile number by a push switch. That is when the switch has pressed the digital pin 9 gets a HIGH state input, and the Arduino send the GPS coordinates.

      I think your IR flame detector has a Digital and Analog output.
      If using digital just connect directly the DO to the pin 9. Whenever the DO has a high state an SMS send. The threshold can be adjusted by the pot in the sensor module.
      If using with analog output connect to an analog input pin and change the same “if” condition so as to check whether the input value reaches above the threshold, and send an SMS whenever the value rises above the threshold.

  11. Vairamuthu J says:

    I have SIM 900A MINI V3.8.2. I don’t know the connection for this module using Arduino UNO. Please send me the connection pins and diagram as well as the code to send SMS and my GSM module is does not searching signals even though our area receives 4G Signals and you please give us the solutions.

  12. GANESHRAM K says:

    the code which u posted is working only in arduino uno only. To get output in arduino mega what has to be done

  13. vaishnovi says:

    The GPS module is not transmitting any value. The TMRK LED is blinking correctly. But when I upload code it gives error message .Plz help me..

  14. Girish says:

    i am using gps sim28ml module and arduino uno. I had uploaded the same code with given circuit connection but tmrk light on the gps is not blinking at all.
    Please help.

    • admin says:

      If the TMRK LED is not blinking it means the GPS is not getting any data. Sometimes it takes a few minutes to start blinking. Try adjusting the antenna of the module. It is recommended to place outdoor, open roof or at least near to the window because GPS receivers require a line of sight to fix their position.

    • Tarunsree says:

      I am using sim28 ml and aurdino uno .tmrk light is not blinking at all .I tried keeping it outdoor but still no use.Please help

  15. Vairamuthu J says:

    i have used library ting gps downloaded from
    https://github.com/mikalhart/TinyGPS
    this website

    the gps shows the same location at every where we did not provide same in buit values but sam gps value is printed every where even in different places

    give me a solution to tracking

    • admin says:

      Did you wait a few minutes at new location points? The module needs some time at each location to pick up new coordinates. Try another library.
      Try directly to receive data in NMEA format without the library and check whether the coordinates at the line “$GPGGA,0…” are changing with location.

      • Vairamuthu J says:

        i waited more than 30 min but it showed the same location in different places
        could you give steps how to receive data in NMEA format without the library ?

        • admin says:

          It is briefed in the first few paragraphs of this article about connecting GPS module using TTL to USB converter and view data through putty, Arduino serial monitor or Hyper terminal.

  16. Mahesh says:

    How to store the slat value in a variable up to 6 decimal points…?

    • admin says:

      “slat” itself a variable which stores up to 6 decimal points. If you need to transfer to another variable just add ” float variable1; Variable1=slat;”.

Leave a Reply

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