Professional Documents
Culture Documents
Vehicle Tracking System
Vehicle Tracking System
Vehicle Tracking System
Presented by
Azhar Muhammed, Ahmed Azawi, and Iyad Basem
2nd Stage (Evening Study)
Introduction 2-4
System assembly 14
CODE 22-29
1
Vehicle Tracking System
Introduction:
2
components and software code but to give a general idea of the
steps from designing to testing and producing. tracking system is a
total security and fleet management solution. It is the technology
used to determine the location of a vehicle using different methods
like GPS and other navigation system operating via satellite and
ground based stations. Modern vehicle tracking system use GPS
technology to monitor and locate our vehicle anywhere on earth,
but sometimes different types of automatic vehicle location
technology are also used. The vehicle tracking system is fitted inside
the car that provides effective real time location and the data can
even be stored and downloaded to a computer which can be
used for analysis in future. This system is an essential device for
tracking car any time the owner wants to monitor it and today it is
extremely popular among people having expensive cars, used as
theft prevention and recovery of the stolen car. The data collected
can be viewed on electronic maps via internet and software. The
vehicle unit incorporates the hardware part that is the Arduino, GPS
and GSM modem kept inside the vehicle that is to be tracked. The
unit is mainly based on a modem that receives signals from the
satellite with the help of GPS antenna. This modem then converts the
data and sends the vehicle location information via SMS as well as a
mobile application named “VTS‟ which is synchronized with the web
page and to a server which can be displayed on digital mapping.
HARDWARE:
Modules
4
A module is a part of a project whose goal is to execute a specific
task. By dividing the project into several functional modules, it is easy
to try, analyze and improve each functionality separately.
Arduino
Why Arduino?
5
simplifies the way to work with microcontrollers and offer several
advantages for teachers, students and hobbyists:
6
advanced electronics designers can create their own version of the
Arduino board. Even less advanced users can build the breadboard
version in order to understand how it works and save money.
Arduino boards
There are several types of Arduino boards. The common basic version,
Uno uses the Atmel ATmega328 microcontroller. A more advanced
version (i.e., more capabilities and more powerful) named Mega is
based on the ATmega1280.
7
Figure 1 Arduino UNO
Arduino uno
a reset button.
Arduino Software
8
connect to the Arduino board to transfer programs
The Arduino software also has a serial terminal that is used to display
text messages received from the Arduino and send characters to the
Arduino. This functionality is really useful to display the state of
variables or results of calculations. It is an essential element to improve,
test, and correct programs loaded in the microcontroller.
9
Figure 2 Arduino IDE
GPS
Hardware Components:
Ingredients:
10
GPRS +GPS:
1 x Arduino Uno
1 x 9V Alkaline Battery
Figure 3 components
11
GPRS+GPS shield diagram:
12
Figure 5 gps Shield
he LED of the shield shows the status of the GPRS+GPS module. The
table below shows the meaning of the blink of the LED.
13
System assembly:
Important Issues:
14
antenna. It's fragile.
The GPS antenna must
be in horizontal position.
For improving the satellites signal,
the antenna has to be in a place with a clear
sky view (no trees, no buildings...).
Figure 7 assembling
Final assembly:
You can fix the batteries to the module with flanges so the whole
system will need less room and you will be able to place it better in
your car
15
Figure 8 final assembly
Software Component:
16
something explicit from those data but if it is used with an
application designed properly, it can work with them and create
custom features. This helps to focus the hardware part on providing
the bare minimum (raw) data and focus on performance where the
software will analyse the data and work with them using high power
calculations. When designing an application, one has to list the top
priorities. The main requirement for the application was to make it
available on any platform. This already scopes down the possibilities
and Java comes in mind when talking about cross platform
compatibility. Java was indeed the first solution but, in my opinion,
has a really bad user interface so further researches were necessary.
I decided to go for a web application, using Bootstrap with jQuery as
a front end and PHP as a back end. I had little knowledge of
bootstrap and jQuery and that could be a way to improve my skills in
this area.
Algorithm
17
Figure 9 code flowchart
18
Identify your phone number and send GPS coordinates
When you call to the module and your phone number is correct, the
GPS obtains longitude and latitude, send you a SMS with the position
and send the GPS data through the Internet to the php script in your
computer.
First step. Load the next sketch into your arduino and then assemble
the GPRS+GPS shield with the antennas and the simcard installed.
Remember, you must configure your APN, login and password. If you
don't do this, the GPRS+GPS cannot connect to the GPRS network.
Also, you must set the URL with the IP address of your computer
(external IP, not the LAN IP address) or your server's domain. To use
the php script you need an Apache server with php active. You can
run the script in a PC installing Apache with php.
Application digram:
19
Display of Result:
Google Map:
With the Google Maps API, we add maps based on Google
Maps data to the web application. The API automatically
handles access to Google Maps servers. We also use API calls
to add markers. We set the center location of map by using
google.maps.LatLng (). As Google Maps API providesdifferent kind
of maps view, we used ROADMAP for this web application. For
fetching the data into the Google Map, we have used
getElementByID () method.
20
SMS:
For monitoring the vehicle location, we have also included the
feature which will send SMS to the user according to user request.
SMS will be included the value of latitude and longitude of the
vehicle. A link is also attached with the SMS, so that the user can see
the location by using Googlemap. View of location on website
through Google map.
Figure 11 SMS
21
Code:
#include “softwareSerial.h” mynumber[7]='7';
int onModulePin= 2;
char frame[200];
char aux_string[30]; pinMode(onModulePin,
OUTPUT);
int flag = 0;
char latitude[15]; Serial.begin(115200);
char number [20];
char longitude[15];
char realnumber[9];
power_on();
char mynumber[9];
char altitude[6]; power_onGPS();
int a=0;
char date[16]; power_onSMS();
int b=0;
char time[7];
int c=0;
char satellites[3]; delay(5000);
//Your phone number
char speedOTG[10];
Char
phone_number[]="0123456 char course[10];
78"; sendATcommand("AT+CPI
N=****", "OK", 2000);
void setup(){
char data[100];
mynumber[0]='0'; delay(3000);
int data_size;
mynumber[1]='1';
mynumber[2]='2'; while(
char aux_str[30]; (sendATcommand("AT+CR
mynumber[3]='3';
char aux; EG?", "+CREG: 0,1", 1000)
mynumber[4]='4'; ||
int x = 0; sendATcommand("AT+CRE
mynumber[5]='5'; G?", "+CREG: 0,5", 1000))
char N_S,W_E; == 0 );
mynumber[6]='6';
22
delay(1000); Serial.flush();
while(Serial.available() flag = 1;
!= 0)
}
sendATcommand("AT+CLIP {
=1", "OK", 1000); //Stores phone
Serial.read(); calling number
sendATcommand("AT+SAP
BR=3,1,\"APN\",\"*******\"", realnumber[3]=number[i];
"OK", 2000); if ( flag == 0){
i++;
{
realnumber[6]=number[i];
// gets the GPRS bearer delay (50);
i++;
while }
(sendATcommand("AT+SA
//Stores phone realnumber[7]=number[i];
PBR=1,1", "OK", 20000) == 0)
number
{ i++;
number[i] =
delay(5000); Serial.read();
realnumber[8]=number[i];
}
break;
}
23
} if (b==1){ ATcommand, char*
expected_answer,
} get_GPS(); unsigned int timeout){
//Check phone number send_HTTP();
} delay(100);
sendATcommand("ATH",
"OK", 1000);
b=1; if (ATcommand[0] !=
'\0')
c=1;
digitalWrite(onModulePin,H {
} IGH);
break; delay(3000); Serial.println(ATcommand);
} // Send the AT command
}else{ digitalWrite(onModulePin,L }
OW);
Serial.println("Wrong
number"); while(answer == 0){ //
Send AT every two x = 0;
break;
seconds and wait for the previous = millis();
} answer
} answer =
sendATcommand("AT", // this loop waits for the
a=0; "OK", 2000); answer
answer=0; } do{
flag = 0; } if(Serial.available() !=
} 0){ // if there are data in
the UART input buffer,
//Send SMS once and int8_t reads it and checks for the
position to HTTP sendATcommand(char* asnwer
24
response[x] = delay(3000);
Serial.read(); sendATcommand("AT+CG
PSSTATUS?", "3D Fix", 5000))
digitalWrite(onModulePin,L == 0 ) &&
//Serial.print(response[x]); OW);
((millis() - previous) <
x++; 90000));
if (strstr(response, // waits for an answer
expected_answer) != from the module
NULL) // check if the if ((millis() - previous) <
desired answer (OK) is in while(answer == 0){ 90000)
the response of the // Send AT every
module {
two seconds and wait for
{ the answer return 1;
answer = 1; answer = }
sendATcommand("AT",
} "OK", 2000); else
} } {
previous = millis();
uint8_t answer=0; // starts the GPS // First get the NMEA
string
if (answer == 0) sendATcommand("AT+CG
// waits for fix GPS PSINF=0",
{ "AT+CGPSINF=0\r\n\r\n",
// power on pulse while(( 2000);
(sendATcommand("AT+CG
PSSTATUS?", "2D Fix", 5000)
digitalWrite(onModulePin,H || counter = 0;
IGH);
25
answer = 0; * Sign '+' is set for positive
strcpy(latitude,strtok(NULL, latitudes/longitudes (North,
memset(frame, '\0', ",")); // Gets latitude East)
100); // Initialize the string
* Sign '-' is set for negative
previous = millis(); strcpy(altitude,strtok(NULL, latitudes/longitudes (South,
// this loop waits for the ".")); // Gets altitude West)
NMEA string strtok(NULL, ","); *
do{ strcpy(date,strtok(NULL, */
".")); // Gets date
int8_t
if(Serial.available() != strtok(NULL, ","); convert2Degrees(char*
0){ input){
strtok(NULL, ",");
frame[counter] =
Serial.read(); strcpy(satellites,strtok(NULL, float deg;
counter++; ",")); // Gets satellites
float minutes;
// check if the boolean neg = false;
desired answer is in the strcpy(speedOTG,strtok(NU
response of the module LL, ",")); // Gets speed over
ground. Unit is knots.
if (strstr(frame, "OK") //auxiliar variable
!= NULL)
strcpy(course,strtok(NULL, char aux[10];
{ "\r")); // Gets course
answer = 1;
if (input[0] == '-')
}
convert2Degrees(latitude); {
}
neg = true;
// Waits for the asnwer convert2Degrees(longitud
with time out strcpy(aux,
e); strtok(input+1, "."));
}
deg = atof(aux);
26
index++;
strcpy(aux, strtok(NULL, float numberFloat=deg;
'\0'));
int intPart[10];
minutes=atof(aux); numberFloat=(numberFloa
int digit; t-(int)numberFloat);
minutes/=1000000;
long for (int i=1; i<=6 ; i++)
if (deg < 100) newNumber=(long)numbe
rFloat; {
{
int size=0;
minutes += deg; numberFloat=numberFloat
deg = 0; *10;
while(1){ digit=
}
size=size+1; (long)numberFloat;
else
digit=newNumber%10;
{ numberFloat=numberFloat
-digit;
minutes += int(deg) % newNumber=newNumber/
100; 10;
input[index]=char(digit)+48
deg = int(deg) / 100; intPart[size-1]=digit; ;
} if (newNumber==0){ index++;
break; }
// add minutes to } input[index]='\0';
degrees
}
deg=deg+minutes/60;
int index=0; }
if( neg ){
if (neg == true)
index++; void send_HTTP(){
{
input[0]='-';
deg*=-1.0;
} uint8_t answer=0;
}
for (int i=size-1; i >= 0; i--) // Initializes HTTP service
{ answer =
neg = false; sendATcommand("AT+HTT
PINIT", "OK", 10000);
input[index]=intPart[i]+'0';
if( deg < 0 ){ if (answer == 1)
index++;
neg = true; {
}
deg*=-1; // Sets CID parameter
} answer =
input[index]='.'; sendATcommand("AT+HTT
27
PPARA=\"CID\",1", "OK", // checks if the module
5000); Serial.println(F("Error getting is started
url"));
if (answer == 1) answer =
} sendATcommand("AT",
{ "OK", 2000);
// Sets url if (answer == 0)
}
sprintf(aux_str, {
"AT+HTTPPARA=\"URL\",\"ht else
tp://%s/demo_sim908.php // power on pulse
?", url); {
Serial.print(aux_str); digitalWrite(onModulePin,H
Serial.println(F("Error setting IGH);
sprintf(frame, the url"));
"visor=false&latitude=%s&lo delay(3000);
ngitude=%s&altitude=%s&ti }
me=%s&satellites=%s&spee }
dOTG=%s&course=%s", digitalWrite(onModulePin,L
else OW);
latitude, longitude,
altitude, date, satellites, {
speedOTG, course); // waits for an answer
Serial.println(F("Error
Serial.print(frame); setting the CID")); from the module
answer = } }
sendATcommand("AT+HTT
PACTION=0",
"+HTTPACTION:0,200", }
30000); sendATcommand("AT+HTT
PTERM", "OK", 5000);
if (answer == 1)
void sendSMS(){
{
}
sendATcommand("AT+CPI
N=****", "OK", 2000);
Serial.println(F("Done!")); void power_onSMS(){
} delay(3000);
else uint8_t answer=0;
28
}
Serial.println("Connecting
to the network..."); Serial.print(" /
Longitude: ");
i = 0;
while(
(sendATcommand("AT+CR
EG?", "+CREG: 0,1", 500) || while(longitude[i]!=0){
sendATcommand("AT+CRE Serial.print(longitude[i]);
G?", "+CREG: 0,5", 500)) == i++;
0 );
}
Serial.write(0x1A);
Serial.print("Setting SMS
mode..."); answer =
sendATcommand("", "OK",
20000);
sendATcommand("AT+CM
GF=1", "OK", 1000); // sets if (answer == 1)
the SMS mode to text
{
Serial.println("Sending
SMS"); Serial.print("Sent ");
else
sprintf(aux_string,"AT+CMG {
S=\"%s\"", phone_number);
Serial.print("error ");
answer =
sendATcommand(aux_strin }
g, ">", 2000); // send the
}
SMS number
else
if (answer == 1)
{
{
Serial.print("error ");
Serial.print("Help me!
I've been stolen. Find me Serial.println(answer,
in:"); DEC);
Serial.print("Latitude: }
");
int i = 0;
}
while(latitude[i]!=0){
Serial.print(latitude[i]);
i++;
29