Introduction: Version 2.0 Arduino Controlled Car Tracking System Based on SMS

About: Computer engineer

This system is upgraded version of previous project... 
You will be able to track your car after you build this system,
you will call the device then it will send you an sms which includes LAT, LON and Google Map link for just one touch to see where it is.

Firstly required materials :

TTL to RS232 Module
VGA socket
SkyLab SKM53 GPS Module
Arduino Pro
Wavecom GSM modem

Before you start to build them, you should connect the Wavecom to PC to adjust Serial Com. Baud Rate to 9600
then make it save this configuration via AT commands. (It is written in Wavecom AT command datasheet).





Step 1: Preparing the Wavecom for Fastening the Modules

Secondly, disassemble the wavecom GSM module and drill many holes for screws, our modules hold on these screws..

Step 2: Preparing the Datacable

Let's make a datacable between Wavecom and RS232 module,
you use just 3 pinouts, it's enough for communication..

Step 3: Connecting the Other Parts

Now let's connect the RS232 and GPS module to our Arduino,

We use 3 pinouts of GPS module ,
These are TX, VCC , Ground (on Skylab SKM53).
connect
GPS TX pinout ----> Arduino PIN 5
RS232 Module RX---> Arduino PIN 10
RS232 Module TX---> Arduino PIN 11
also do not forget to connect Vcc and GND pinouts of RS232 module, GPS module and Arduino

Step 4: Finishing the Tracker Device

Not fix these modules on Wavecom with silicon...
You also can connect a buzzer to PIN7 , I do it because I'll put this device in a hidden place then power it on/off with wireless RF switch. So, I can hear the buzzer when I power it on..

Now .. upload program on arduino.. (next step)

Step 5: Program

it has a few Turkish lines , some of them

GPS VERISI HAZIR DEGIL ====>>> GPS DATA IS NOT READY
KoordinatBilgisiGonder =====> SendGPSData
ENLEM ======>>>  LATITUDE
BOYLAM ========>>> LONGITUDE
HIZ===========>> SPEED












==========================================  CODE===================================================



#include
#include
#include

TinyGPS gps;

SoftwareSerial gsmSerial(10,11);
//SoftwareSerial gsmSerial(3,2);
SoftwareSerial ss(5,6);

String inData = "";
boolean inputAvailable = false;
String recievedNumber = "";
String gpsMesajIcerik = "";
int callback_counter=0;
int indexofMsgStr = 0;
float flat, flon, fkmph;
unsigned long age;
char okunanKarakter = '*';
float flat_store = 0.0;
float flon_store = 0.0;
int buzzer = 7;

void setup()
{

    pinMode(buzzer, OUTPUT);
Serial.begin(9600);
ss.begin(9600);
gsmSerial.begin(9600);

Timer1.initialize(8388480); //yaklasik 8.3 saniye
Timer1.attachInterrupt(callback);

delay(2000);
gsmSerial.listen();

Serial.println("basla");
delay(1000);
gsmSerial.listen();

        fastbuzzer();
}

void loop() // run over and over
{
while(gsmSerial.available())
{
  inputAvailable = true;
  okunanKarakter = (char) gsmSerial.read();
  inData += okunanKarakter;
  if(okunanKarakter == ','){
   break;
  }
}

if(inputAvailable)
{
  inputAvailable=false;
  processData();
  inData="";
}
}

void printGPSDATA()
{
gps.f_get_position(&flat, &flon, &age);

if( flat > 0.0 )
flat_store = flat;

if( flon > 0.0 )
flon_store = flon;

fkmph = gps.f_speed_kmph(); // speed in km/hr

}

void TAKEGPSDATA(){
Serial.println("---->TAKEGPSDATA");
boolean gps_valid = false;
ss.listen();
delay(1000);


for(int i =0 ; i < 200 ; i++)
{
  if(!gps_valid)
  {
   while (ss.available())
   {
    char c = ss.read();
    if (gps.encode(c)) // Did a new valid sentence come in?
    {
     printGPSDATA();
     gps_valid = true;
                                        break;
    }
   }
   delay(5);
  }
}

gsmSerial.listen();
delay(1000);
Serial.println("<----TAKEGPSDATA");

}

void processData(){
Serial.println(inData);

if(IsRinging())
{ // telefon caliyor
  Serial.println("telefon caliyor");
  indexofMsgStr = inData.indexOf("05");
  recievedNumber = inData.substring(indexofMsgStr , indexofMsgStr+11);
  Serial.print("recieved number=");
  Serial.println(recievedNumber);

  if(IsAdminNumber())
  {
   Serial.println("admin ok!");
   TAKEGPSDATA();
   if(gpsDataOk())
   {
           KoordinatBilgisiGonder();
   }
   else
   {
    HazirDegilBilgisiGonder();
   }
  }

}
}

void KoordinatBilgisiGonder(){

gpsMesajIcerik = "AT+CMGS=\"";
gpsMesajIcerik+= "+9";
gpsMesajIcerik+=recievedNumber;
gpsMesajIcerik+= "\"";

gsmSerial.println("AT+CMGF=1");
delay(2000);
gsmSerial.println(gpsMesajIcerik);
delay(1000);

gsmSerial.print("ENLEM =");
gsmSerial.println(flat_store,6);
gsmSerial.print("BOYLAM =");
gsmSerial.println(flon_store,6);

gsmSerial.print("HIZ =");
gsmSerial.print(fkmph);
gsmSerial.println(" km/saat");

gsmSerial.println("LINK =");
gsmSerial.print("http://maps.google.com/?ie=UTF8&hq=&ll=");
gsmSerial.print(flat_store,6);
gsmSerial.print(",");
gsmSerial.print(flon_store,6);
gsmSerial.print("&z=20");
gsmSerial.write(26);
}


void HazirDegilBilgisiGonder()
{
gpsMesajIcerik = "AT+CMGS=\"";
gpsMesajIcerik+= "+9";
gpsMesajIcerik+=recievedNumber;
gpsMesajIcerik+= "\"";

gsmSerial.println("AT+CMGF=1");
delay(2000);
gsmSerial.println(gpsMesajIcerik);
delay(1000);

gsmSerial.println("GPS VERISI HAZIR DEGIL ");
gsmSerial.print(flat_store,6);
gsmSerial.print("-");
gsmSerial.println(flon_store,6);

gsmSerial.write(26);
}

int IsRinging()
{
if (inData.indexOf("CLIP:") >= 0 )
{
  return 1;
}
else
{
  return 0;
}
}
int IsAdminNumber()
{
if(recievedNumber.equals("05558237477"))
{
  return 1;
}
else
{
  if(recievedNumber.equals("05073674078"))
  {
   return 1;
  }
  else
  {
   if(recievedNumber.equals("05323375412"))
   {
    return 1;
   }
   else
   {
    if(recievedNumber.equals("05398523288"))
           {
         return 1;
             }
                                else
                                {
                                    if(recievedNumber.equals("05532766541"))
         { 
                                        return 1;
                                    }                                      
                                    else
                                    {
                                       return 0;
                                    } 
                                }
   }
  }
}
}

int gpsDataOk()
{
if(( flat > 0.0 ) && ( flon > 0.0 ) )
{
  return 1;
}
else
{
  return 0;
}
}

void callback()
{
callback_counter++;
if(callback_counter >= 80)
{
  Serial.print("callback ok!");
  callback_counter = 0;
  TAKEGPSDATA();
}
}

void fastbuzzer()
{
for(int i = 0; i< 10; i++)
{
  digitalWrite(buzzer, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(buzzer, LOW);    // turn the LED off by making the voltage LOW
  delay(100);
}
}