Arduino based Vehicle Tracker using GPS and G - Internet of Things

Arduino based Vehicle Tracker using GPS and G

Vehicle Tracking System using GPS and Arduino

In our previous article, we have learned about How to interface GPS module with Computer and How to make a GPS updated Clock”. In this project we are going one step ahead with GPS and going to track a vehicle using GPS and GSM. This Vehicle Tracking System can also be used for Accident Detection Alert System, Soldier Tracking System and many more, by just making few changes in hardware and software.

Tracking of vehicle is a process in which we track the vehicle location in form of Latitude and Longitude (GPS coordinates). GPS Coordinates are the value of a location. This system is very efficient for outdoor application purpose.
This kind of Vehicle Tracking System Project is widely in tracking Cabs/Taxis, stolen vehicles, school/colleges buses etc.

Components Required:
·         Arduino
·         GSM Module
·         GPS Module
·         16x2 LCD
·         Power Supply
·         Connecting Wires
·         10 K POT

GPS Module and Its Working:
GPS stands for Global Positioning System and used to detect the Latitude and Longitude of any location on the Earth, with exact UTC time (Universal Time Coordinated). GPS module is the main component in our vehicle tracking system project. This device receives the coordinates from the satellite for each and every second, with time and date.
GPS module sends the data related to tracking position in real time, and it sends so many data in NMEA format (see the screenshot below). NMEA format consist several sentences, in which we only need one sentence. This sentence starts from $GPGGA and contains the coordinates, time and other useful information. This GPGGA is referred to Global Positioning System Fix Data. Know more about Reading GPS data and its strings here.
We can extract coordinate from $GPGGA string by counting the commas in the string. Suppose you find $GPGGA string and stores it in an array, then Latitude can be found after two commas and Longitude can be found after four commas. Now these latitude and longitude can be put in other arrays.

Below is the $GPGGA String, along with its description:
$GPGGA,104534.000,7791.0381,N,06727.4434,E,1,08,0.9,510.4,M,43.9,M,,*47
$GPGGA,HHMMSS.SSS,latitude,N,longitude,E,FQ,NOS,HDP,altitude,M,height,M,,checksum data

Identifier
Description
$GPGGA
Global Positioning system fix data
HHMMSS.SSS
Time in hour minute seconds and milliseconds format.
Latitude
Latitude (Coordinate)
N
Direction N=North, S=South
Longitude
Longitude(Coordinate)
E
Direction E= East, W=West
FQ
Fix Quality Data
NOS
No. of Satellites being Used
HPD
Horizontal Dilution of Precision
Altitude
Altitude from sea level
M
Meter
Height
Height
Checksum
Checksum Data

Circuit Explanation:
Circuit Connections of this Vehicle Tracking System Project is simple. Here Tx pin of GPS module is directly connected to digital pin number 10 of Arduino. By using Software Serial Library here, we have allowed serial communication on pin 10 and 11, and made them Rx and Tx respectively and left the Rx pin of GPS Module open. By default Pin 0 and 1 of Arduino are used for serial communication but by using SoftwareSerial library, we can allow serial communication on other digital pins of the Arduino. 12 Volt supply is used to power the GPS Module.
GSM modules Tx and Rx pins of are directly connected to pin Rx and Tx of Arduino. GSM module is also powered by 12v supply. An optional LCDs data pins D4, D5, D6 and D7 are connected to pin number 5, 4, 3, and 2 of Arduino. Command pin RS and EN of LCD are connected with pin number 2 and 3 of Arduino and RW pin is directly connected with ground. A Potentiometer is also used for setting contrast or brightness of LCD.

Working Explanation:
In this project, Arduino is used for controlling whole the process with a GPS Receiver and GSM module. GPS Receiver is used for detecting coordinates of the vehicle, GSM module is used for sending the coordinates to user by SMS. And an optional 16x2 LCD is also used for displaying status messages or coordinates. We have used GPS Module SKG13BL and GSM Module SIM900A.
When we ready with our hardware after programming, we can install it in our vehicle and power it up. Then we just need to send a SMS, Track Vehicle, to the system that is placed in our vehicle. We can also use some prefix (#) or suffix (*) like #Track Vehicle*, to properly identify the starting and ending of the string, like we did in these projects: GSM Based Home Automation and Wireless Notice Board

Sent message is received by GSM module which is connected to the system and sends message data to Arduino. Arduino reads it and extract main message from the whole message. And then compare it with predefined message in Arduino. If any match occurs then Arduino reads coordinates by extracting $GPGGA String from GPS module data (GPS working explained above) and send it to user by using GSM module. This message contains the coordinates of vehicle location.

Programming Explanation:
In programming part first we include libraries and define pins for LCD & software serial communication. Also define some variable with arrays for storing data. Software Serial Library is used to allow serial communication on pin 10 and 11.
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

#include <SoftwareSerial.h>
SoftwareSerial gps(10,11); // RX, TX
char str[70];
String gpsString="";
... ....
.... ....
Here array str[70] is used for storing received message from GSM module and gpsString is used for storing GPS string. char *test=”$GPGGA is used to compare the right string that we need for coordinates.
After it we have initialized serial communication, LCD, GSM & GPS module in setup function and showed a welcome message on LCD.
void setup()
{
  lcd.begin(16,2);
  Serial.begin(9600);
  gps.begin(9600);

  lcd.print("Vehicle Tracking");
  lcd.setCursor(0,1);
  ... ....
  .... ....
In loop function we receive message and GPS string.
void loop()
{
  serialEvent();
  if(temp)
  {
    get_gps();
    tracking();
  }
}
Functions void init_sms and void send_sms() are used to initialising and sending message. Use proper 10 digit Cell phone no, in init_sms function.  
Function void get_gps() has been used to extract the coordinates from the received string.
Function void gpsEvent() is used for receiving GPS data into the Arduino.
Function void serialEvent() is used for receiving message from GSM and comparing the received message with predefined message (Track Vehicle).
void serialEvent()
{
  while(Serial.available())
  {
    if(Serial.find("Track Vehicle"))
    {
      temp=1;
      break;
    }
    ... ....
    .... ...
Initialization function gsm_init() is used for initialising and configuring the GSM Module, where firstly, GSM module is checked whether it is connected or not by sending ATcommand to GSM module. If response OK is received, means it is ready. System keeps checking for the module until it becomes ready or until OKis received. Then ECHO is turned off by sending the ATE0 command, otherwise GSM module will echo all the commands. Then finally Network availability is checked through the AT+CPIN?command, if inserted card is SIM card and PIN is present, it gives the response +CPIN: READY. This is also check repeatedly until the network is found. This can be clearly understood by the Video below.

  Demo & Code

Arduino based Vehicle Tracker using GPS and G Arduino based Vehicle Tracker using GPS and G Reviewed by XXX on สิงหาคม 27, 2560 Rating: 5

ไม่มีความคิดเห็น