Send GPS Location Via SMS GSM Arduino

The main three components in this project are GPS (Global Positioning System) module, GSM Module, and an Arduino Uno. Here we are sending the live coordinates received by the GPS receiver module to a mobile phone via SMS using the GSM module.

GPS Receiver Module

A GPS receiver module is a device that receives information from GPS satellites and obtains the geographical position of the device.

GPS Module Arduino Connection

Pin configuration as in the below code and given circuit diagram.

Arduino Pin GPS Module Pin
Tx (Digital Pin 5 ) Rx
Rx (Digital Pin 4) Tx
GND GND

GSM Module

gsm module
A GSM module is a device used to establish communication over a mobile network. GSM or GPRS Module requires a SIM card to operate or to register a connection with the network operator or service provider.

GSM module Connection with Arduino

Arduino Pin  GSM Module Pin
Tx (Digital Pin 3) Rx
Rx (Digital Pin 2) Tx
GND GND

Refer the tutorial links given below for detailed working, codes, and interface of the GPS and GSM modules with Arduino.

gps gsm arduino, gps sms, send gps

The GPS receiver obtains the data as a whole NMEA format text. Only the latitude and longitude coordinates are taken from it; using the Arduino TinyGPS library. Then the GSM module sends SMS to the number specified in the code.

This code is useful for GPS and GSM projects like Vehicle Tracker and other Arduino based live location sharing or tracking devices, similar prototypes etc.

The switch input based GPS needs a manual action to operates or send SMS. It is to just send the location by ourselves. By just simple modifications the circuit can be integrated with a wide range of sensors to detect flame, vibration, or similar devices to automatically operates on specific events. Such as, using with a flame detector sensor to automatically send the location of the fire accident, vehicle accident detection system to send the location of accident vehicle to rescue team, etc…

Arduino code for sending GPS Longitude and Latitude coordinates on switch press.

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

int state = 0;
const int pin = 9;
float gpslat, gpslon;

TinyGPS gps;
SoftwareSerial sgps(4, 5);
SoftwareSerial sgsm(2, 3);

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

void loop()
{
  while (sgps.available())
  {
    int c = sgps.read();
    if (gps.encode(c))
    {
      gps.f_get_position(&gpslat, &gpslon);
    }
  }
  {
    if (digitalRead(pin) == HIGH && state == 0) {
      sgsm.print("\r");
      delay(1000);
      sgsm.print("AT+CMGF=1\r");
      delay(1000);
      /*Replace XXXXXXXXXX to 10 digit mobile number &
        ZZ to 2 digit country code*/
      sgsm.print("AT+CMGS=\"+ZZXXXXXXXXXX\"\r");
      delay(1000);
      //The text of the message to be sent.
      sgsm.print("Latitude :");
      sgsm.println(gpslat, 6);
      sgsm.print("Longitude:");
      sgsm.println(gpslon, 6);
      delay(1000);
      sgsm.write(0x1A);
      delay(1000);
      state = 1;
    }
    else {
      state = 0;
    }
  }
}

If we need to track the location of a moving device from a distant place or monitor the position of an object at a regular interval of time it can be obtained by just removing the  “if” condition to send SMS, instead just add time delay of few seconds or minutes. Then you can receive the current location of the receiver at fixed intervals.

To receive the SMS in a URL format to open directly on google maps the above message code can be replaced with,

      sgsm.print("https://www.google.com/maps/?q=");
      sgsm.print(gpslat, 6);
      sgsm.print(",");
      sgsm.print(gpslon, 6);

The resultant google map website address received as SMS will be, https://www.google.com/maps/?q=27.988139,86.924974 (GPS coordinate location @ ) which takes you directly to the map.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

You may also like...

8 Responses

  1. Ganesh Ram says:

    Which mobile sim should i use??
    Either 2G or 3G or 4G Sim ??

    • admin says:

      For a SIM900 module, it is just 2G. The 3G, 4G sim works in it but just as 2G.
      The sim should support 2G, it does not work with 4G SIM works on LTE and VOLTE only.

  2. Ganesh Ram says:

    Really thank you so much this code really works. whereas coding from other websites is not helping us and we gained some knowledge through this. We need one more help. we got latitude and longitude in a mobile phone using that how can I plot in a map automatically in a mobile phone.

    • admin says:

      It is described in the project how to receive the SMS in a URL format to plot directly on google maps. Did you mean something more?

  3. Obaidullah Khan says:

    Hi,

    Instead of a switch can we get the GPS Coordinates by sending the sms to the tracker

  4. Ganesh Ram says:

    Actually we are having ARDUINO MEGA , GPS , GSM MODULE. We tried our best with the following code.

    SoftwareSerial sgps(4, 5);
    SoftwareSerial sgsm(2, 3);

    But we can’t get output in mobile. So could you please post the exact PINNUMBER which i can use in the code to get output in mobile.

    Sir/Madam it is enough if you just edit and post the correct pin number

Leave a Reply

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