Linkit One GPS (sending SMS of GPS Location to Mobile)

Introduction: Linkit One GPS (sending SMS of GPS Location to Mobile)

About: I love all things related to electronics . Follow me for awesome instructables. Science lover. Chemistry hater. Arduino ,linkit one, pro mini etc. familiar with these microcontrollers .

This instructable solves the problem of printing GPS location on serial monitor .

We'll send that location in the form of SMS to our mobile than we will take the important part and than paste it on Google maps.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts

Parts:
• Linkit One
• Linkit One USB cable
• GSM Antenna
• GPS Antenna
• Battery (Linkit one)
• Sim card

Step 2: Code

#include

gpsSentenceInfoStruct info;

char buff[256];

static unsigned char getComma(unsigned char num,const char *str)

{

  unsigned char i,j = 0;

  int len=strlen(str);

  for(i = 0;i < len;i ++)

  {

     if(str[i] == ',')

      j++;

     if(j == num)

      return i + 1;

  }

  return 0;

}

static double getDoubleNumber(const char *s)

{

  char buf[10];

  unsigned char i;

  double rev;

  i=getComma(1, s);

  i = i - 1;

  strncpy(buf, s, i);

  buf[i] = 0;

  rev=atof(buf);

  return rev;

}

static double getIntNumber(const char *s)

{

  char buf[10];

  unsigned char i;

  double rev;

  i=getComma(1, s);

  i = i - 1;

  strncpy(buf, s, i);

  buf[i] = 0;

  rev=atoi(buf);

  return rev;

}

void parseGPGGA(const char* GPGGAstr)

{

  /* Refer to http://www.gpsinformation.org/dale/nmea.htm#GGA

* Sample data: $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47

* Where:

* GGA Global Positioning System Fix Data

* 123519 Fix taken at 12:35:19 UTC

* 4807.038,N Latitude 48 deg 07.038' N

* 01131.000,E Longitude 11 deg 31.000' E

* 1 Fix quality: 0 = invalid

* 1 = GPS fix (SPS)

* 2 = DGPS fix

* 3 = PPS fix

* 4 = Real Time Kinematic

* 5 = Float RTK

* 6 = estimated (dead reckoning) (2.3 feature)

* 7 = Manual input mode

* 8 = Simulation mode

* 08 Number of satellites being tracked

* 0.9 Horizontal dilution of position

* 545.4,M Altitude, Meters, above mean sea level

* 46.9,M Height of geoid (mean sea level) above WGS84

* ellipsoid

* (empty field) time in seconds since last DGPS update

* (empty field) DGPS station ID number

* *47 the checksum data, always begins with *

*/

  double latitude;

  double longitude;

  int tmp, hour, minute, second, num ;

  if(GPGGAstr[0] == '$')

  {

    tmp = getComma(1, GPGGAstr);

    hour = (GPGGAstr[tmp + 0] - '0') * 10 + (GPGGAstr[tmp + 1] - '0');

    minute = (GPGGAstr[tmp + 2] - '0') * 10 + (GPGGAstr[tmp + 3] - '0');

    second = (GPGGAstr[tmp + 4] - '0') * 10 + (GPGGAstr[tmp + 5] - '0');

    sprintf(buff, "UTC timer %2d-%2d-%2d", hour, minute, second);

    Serial.println(buff);

    tmp = getComma(2, GPGGAstr);

    latitude = getDoubleNumber(&GPGGAstr[tmp]);

    tmp = getComma(4, GPGGAstr);

    longitude = getDoubleNumber(&GPGGAstr[tmp]);

    sprintf(buff, "latitude = %10.4f, longitude = %10.4f", latitude, longitude);

    Serial.println(buff);

    tmp = getComma(7, GPGGAstr);

    num = getIntNumber(&GPGGAstr[tmp]);

    sprintf(buff, "satellites number = %d", num);

    Serial.println(buff);

  }

  else

  {

    Serial.println("Not get data");

  }

}

void setup() {

  // put your setup code here, to run once:

  Serial.begin(115200);

  LGPS.powerOn();

  Serial.println("LGPS Power on, and waiting ...");

  delay(3000);
while(!LSMS.ready){
delay(1000);
}

}

void loop() {

  // put your main code here, to run repeatedly:

  Serial.println("LGPS loop");

  LGPS.getData(&info);
LSMS.beginSMS(" Enter No.");


  LSMS.print((char*)info.GPGGA);

  parseGPGGA((const char*)info.GPGGA);

  delay(2000);
LSMS.endSMS();

}


Step 3: Finding It on Google Maps

8960.0000,N,00000.0000,E,

Copy this and paste it on Google maps replace , with ° and search you' ll get your location.

Good Luck.

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge

    Discussions