Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

report fyp.docx - UniKL BMI by xiuliliaofz

VIEWS: 309 PAGES: 82

									            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               1




1.1 Introduction



   The Vehicle Tracking System is VTS a voter security remotely, whereas GSM &
   GPS technologies were used in order and monitor the location of a vehicle. The
   device incorporates a covertly installed module (which work and communicate
   independently) but has the ability to run in conjunction with your local GSM
   network (DTMF, SMS, GPRS, and GSM). It provides effective real time
   location. GPS tracking unit is a device that uses the Global Positioning System
   to determine the precise location of a vehicle, person, or other asset to which it is
   attached and to record the position of the asset at regular intervals. The recorded
   location data can be stored within the tracking unit, or it may be transmitted to a
   central location data base, or internet-connected computer, using a cellular
   (GPRS, SMS), radio, or satellite modem embedded in the unit. It is a fitted on
   the vehicle (car).The whole controlling of the device is done by the mobile phone
   which provides wireless connection between the VTS device and the user. The
   VTS device has a sim slot in which a GSM SIM which is fitted to receive and
   transmit SMS. The user or owner can send a SMS through mobile phone, know
   the position and speed of the vehicle. Thus, to understand the whole concept or
   operation of VTS, it can be dividing into two parts:


    i. Tracking the location and speed of vehicle.
    ii. Send the data or input based for part (i) via SMS.




1.2 Project Background



        “Vehicle Tracking System” means an Electronics device that reports its
           location by using Global Positioning system (GPS), data receive from



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)        2




        GPS satellites and send SMS by Global System for mobile
          communication (GSM).


        This device is installed in car or vehicle with antenna and
          tracking the vehicle.GPS controlled and handled by microcontroller
          system.


        Thus there is a continuous track of the vehicle which can be stored in a
          database and can be retrieved later




1.3 Project Statement



        Microcontroller based motherboard with regulated power supply
        GPS Receiver for Location and speed information
        GSM Modem and mobile phone for remote communication




1.4 Objective




   1. Integrated GSM and GPS
   2. Exploring GPS and GSM technology
   3. Develop Vehicle Location system using GPS for positioning information and
       GSM for information transmission with following features

   4. To know how troubleshooting and connection tips are discussed followed by
       the first serious example of LCD problem.

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                3




   5. To know about Arduino programmer and startle kit hardware

   6. To know how to use more about instruction every declaration.

   7. To know about GPRS system programming operation

   8. To make sure the student have knowledge a simple computer language
       designed to enable sophisticated object-oriented programming.




1.5 Scope of Project



    This project is developed using GPS and GSM Modem.
       GPS is chosen because it The GPS modem will continuously give the data i.e.
       the latitude and longitude indicating the position of the vehicle and a GSM
       modem is used to send the position (Latitude and Longitude) of the vehicle


    The project testing will be carried out in Gombak area only. The testing
       will be carried out in the Gombak          area only due to time, budget and
       transportation constraints.


    The system will only work well in an open area. This is due to the GPS
       limitation itself. The signal travels by line of sight in which it is able to pass
       through clouds, glass and plastic but will not pass through physical solid
       objects such as mountains, building and so on.


    Users can only determine their current location and available route to
       reach their destination.
       It is not the project concern to provide the best routing since this will involves
       of much and complicated task. Nevertheless, users will be provided with




S’1 2011 (WPB 49806)
              VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            4




       the route to the destination despite the fact that it might be other short cuts
       or better route.




2.1 History



   2.1.1 Previous work



         Reference for this project




        The Vehicle tracking system is a total security protection and fleet
        management solution. By using the latest GSM & GPS technology to
        protect and monitor our car, truck, boat (moveable asset) virtually anywhere
        and then locate it to within a few meter. The device incorporates a covertly
        installed module (which work and communicate independently) but as the
        ability to run in conjunction with your local GSM network (DTMF, SMS
        ,GPRS, GSM). It provides effective real time location. If someone vehicle
        tracking system by using this system we can get accurate location GPS
        tracking unit is a device that uses the Global Positioning System to
        determine the precise location of a vehicle, person, or other asset to which it
        is attached and to record the position of the asset at regular intervals. The
        recorded location data can be stored within the tracking unit, or it may be
        transmitted to a central location data base, or internet-connected computer,
        using a cellular (GPRS, SMS), radio, or satellite modem embedded in the
        unit. This allows the asset's location to be displayed against a map backdrop
        either in real time or when analyzing the track later, using customized
        software. It is a fitted on the vehicle (car, bus, truck).The whole controlling
        of the device is done by the mobile phone which provides wireless
        connection between the VTS device and the user. The VTS device has a sim
        slot in which a GSM SIM is fitted to receive and transmit SMS. The user
S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)              5




        can sending a SMS through its mobile phone, know the position of its
        vehicle and the system also provide the facility to protect the vehicle. So for
        the understanding the whole operation of VTS device, we can divide the
        whole working in the two parts


        1. Tracking the location of vehicle
        2. To provide protection of vehicle


        The VTS consist of GPS receivers which provide real time location of
        vehicle. This real time data is store in MMC after a set time interval by the
        MCU. GSM module directly connected to the MCU which is use to send
        and receive the SMS. GSM modules take the data from the MMC and send
        this data to the user mobile phone. This data consist of longitude, latitude,
        altitude, speed over ground, course over ground, real time and date. By
        using Google maps we can find the exact location of vehicle. The VTS also
        has another special feature which provides not only the location of vehicle
        but also protection of vehicle. To know the location of vehicle, it is
        important to stop the vehicle as soon as possible. For the recovery of
        vehicle, we are using to relays in the circuit in which one are connected to
        the buzzer and other is connected to the power supply of the engine of
        vehicle. User can simply by sending a SMS from mobile, disable the engine
        of vehicle and we can recover the vehicle very soon.




       Working Of Vehicle Tracking System




       In this Project it is proposed to design an embedded system which is used for
       tracking and positioning of any vehicle by using Global Positioning System
       (GPS) and Global system for mobile communication (GSM). In this project
       PIC series microcontroller is used for interfacing to various hardware
       peripherals. The current design is an embedded application, which will

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)             6




       continuously monitor a moving Vehicle and report the status of the Vehicle
       on demand. For doing so an PIC series18F452 microcontroller is interfaced
       serially to a GSM Modem and GPS Receiver. A GSM modem is used to send
       the position (Latitude and Longitude) of the vehicle from a remote place. The
       GPS modem will continuously give the data i.e. the latitude and longitude
       indicating the position of the vehicle. The GPS modem gives many
       parameters as the output. The same data is sent to the mobile at the other end
       from where the position of the vehicle is demanded. An EEPROM is used to
       store the mobile number. When the request by user is sent to the number at
       the modem, the system automatically sends a return reply to that mobile
       indicating the position of the vehicle in terms of latitude and longitude. The
       project is vehicle positioning and navigation system we can locate the vehicle
       around the globe with micro controller, GPS receiver, GSM modem,
       EEPROM. Microcontroller used is PIC18F452.


       The code is written in the internal memory of Microcontroller i.e. ROM. With
       help of instruction set it processes the instructions and it acts as interface
       between GSM and GPS with               help of serial communication of
       microcontroller. GPS always transmits the data and GSM transmits and
       receive the data. GPS pin TX is connected to microcontroller via connector.
       GSM pins TX and RX are connected to microcontroller serial ports.
       Microcontroller communicates with the help of serial communication. First it
       takes the data from the GPS receiver and then sends the information to the
       owner in the form of SMS with help of GSM modem. GPS receiver works on
       9600 baud rate is used to receive the data from space Segment (from
       Satellites), the GPS values of different Satellites are sent to microcontroller
       18F452, where these are processed and forwarded to GSM. From these values
       microcontroller takes only latitude and longitude values excluding time,
       altitude, name of the satellite, authentication etc. E.g. LAT: 1728:2470 LOG:
       7843.3089 GSM modem with a baud rate 57600 .GSM is a Global system for
       mobile communication in this project it acts as a SMS Receiver and SMS
       sender. EEPROM is an Electrically Erasable read only memory which stores
       is used to store the mobile number. The power is supplied to components like

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               7




       GSM, GPS and Micro control circuitry using a 12V/3.2A battery .GSM
       requires 12v,GPS and microcontroller requires 5v .with the help of regulators
       we regulate the power between three components. As shown in circuit
       diagram the microcontroller is the key part of VTS, Crystal oscillator is used
       in the circuit to initiate the microcontroller with the frequency of 10 Mhz. A
       microcontroller r use for providing proper interfacing between the GPS &
       GSM module. A common voltage of 4 voltages is given to all component of
       the circuit. Here AC to DC converter circuit is used which comprises of an
       IC-LN2576. It changes 12V DC supply to 4 V .


       Circuit diagram uses many LEDs (Light Emitting Diode)              for indication
       purpose. When we switch on of our circuit network LED blink fastly for
       searching network. When it get network its blinking time period increases.
       After network is found , Now GSM module LED start blinking to search
       ,after that GPS module LED start blinking, after that mmc LED start blinking
       i.e. data started to being logged in the mmc card ,after that SMS LED start
       blinking and the circuit send message to the registered mobile number which
       send latitude and longitude to the registered mobile number. Now as shown in
       the circuit some relays are used, there are two relays used in the circuit that
       works on +12v. It can support up to 50watt i.e. we can attached a device to it
       which can work safely within 50watt. On relay two LED are placed which is
       used to show the status of the relay ,i.e. when relay LED is glowing then
       relay is in working position , If LED is not glowing then relay is not working
       i.e. device attached to the device will not work. Now according to the circuit
       diagram microcontroller pin number 4 is used to initiate gsm module to pin
       number 12 There are certain command which are used by the subscriber for
       receiving the location of position and for changing the setting.


       The EEPROM is used to store the commands sends by a subscriber.
       Commons sends by mobile are received by GPS. These data are reached to
       the EEPROM by the help of microcontroller. At the time of changing the
       commands the old data are erased and new one save. As shown in fig.
       microcontroller pin no.5 ic connected to the GSM module serially, to the

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               8


       power key of the GSM module. And microcontroller is connected to GPS
       module by pin no.7. Register is used in this circuit for voltage drop and
       capacitor is used for blocking of AC current.. When GSM is initiate it firstly
       check the status of the module, now after that GSM transmitter, receiver
       serially interfaced with microcontroller transmitter, receiver. In GSM DCE is
       used as a client and DTE is used as a terminal, DCE-DTE are connected to
       the following signal.
       There are two ports used,


       1. Serial port 1
       2. Serial port 2


       GSM and GPS module is used here can be switched off due to the insufficient
       supply of voltages so for that in GPS V-BAT pin is used, and in GSM
       BACK_UP         key     is     used.    The   four   pins   of    microcontroller
       RB5,RB4,RB7,RA0,RA1, represent four LED which glows during the
       working of the circuit. The first LED represents MMC LED if it is glowing
       data is stored in MMC card .second LED represent GPS data.If it is blinking
       fastly then GPS module searching for its service ,third LED represent SMS
       SEND LED.


       Its blinking shows SMS is sent by GSM module to the registered mobile
       number and GPRS SEND LED blinking represents that GSM module is
       searching for its service provider. With GSM module SIM is interface with
       pin number 6,7,8,9       .With pin number 9 VSIM which means power is
       supplied        to       the           SIM     card.GSM          module      pins
       SIM_RESET,SIM_CLOCK,SIM_DATA is interfaced with same SIM pins
       and one pin of the SIM is ground. Resistors are used between GSM module
       and SIM to block the excess current. With microcontroller MMC card is also
       interfaced. Pin number 44,43 represents data in and data out pin which
       serially interfaced MMC data out and data in pins. MMC data out pin with
       also connected with EEPROM which is used to store commands. The
       difference between MMC card and EEPROM is that in


S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)        9




       MMC card latitude, longitude which is sent by GSM module is stored while
       in EEPROM commands are saved.




Block Diagram for VTS




                            Figure 2.1: The block diagram




Setup Command’s for GPS Tracker


We can configure your device setup using sms. Sms fomat is like this.
YG:1:12345:+919935149636;
Here YG is your message prefix. Device will respond only that message,
. who contains in starting YG.( should be in capital letter’s).
1 is your function_id. This will inform to device, which type of action we want to
perform. 12345 is your password. Device is 5 digit password protected. If password
does not match in your sms password then device will delete that sms.


+919935149636 is your destination mobile number, where you want to receive all

S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   10


tracking message.


Sms_Command_Set:
Command-1 (To change mobile number)
YG:1:12345:+919935149636;
Back Response From Device
MOBILE OK +9199351496362
Here +919935149636 is mobile number where you want to receive message.
Command-2 ( To change sms interval )
YG:2:12345:1;
Back Response From Device
TIME INTERVAL OK 01
Here 1 is indicating that sms interval is set to 1 minute.
Command-3 ( To change Password )
YG:3:12345:54321;
Back Response From Device
PASSWORD OK
To change password use this command, but you have know your current password.
Command-4 ( To Get current setting )
YG:4:12345:Get;
Back Response From Device
Mobile- +919935149636 , Interval – 01 Minute
Command-5 ( To Turn On relay -1)
YG:5:12345:RL-1;
Back Response From Device
This command works like a toggle.
If RL-1 status is On then Back response is “Relay is On”.
If RL-1 status is Off then Back response is “Relay is Off”.


Command-6 ( To Turn On relay -2)
YG:6:12345:RL-2;
Back Response From Device


This command works like a toggle.

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                11


If RL-2 status is On then Back response is “Relay is On”.
If RL-2 status is Off then Back response is “Relay is Off”.
Command-7 ( To Know current status of Relay-1 & Relay-2)
YG:7:12345:Get;
Back Response From Device
Relay-1 is On, Relay-2 is Off
Command-8 ( To Know IMEI Number of Your Module )
YG:8:12345:Get;
Back Response From Device
IMEI-353351245789458




   2.1.2 Present work




         Our project is The Vehicle Tracking System based on GPS and GSM
Modem is VTS a voter security remotely, whereas GSM & GPS technologies were
used in order and monitor the location of a vehicle. The device incorporates a
covertly installed module (which work and communicate independently) but has the
ability to run in conjunction with the local GSM network (DTMF, SMS, GPRS, and
GSM). It provides effective real time location. GPS tracking unit is a device that uses
the Global Positioning System to determine the precise location of a vehicle, person,
or other asset to which it is attached and to record the position of the asset at regular
intervals. The recorded location data can be stored within the tracking unit, or it may
be transmitted to a central location data base, or internet-connected computer, using a
cellular (GPRS, SMS), radio, or satellite modem embedded in the unit. It is a fitted
on the vehicle (car).The whole controlling of the device is done by the mobile phone
which provides wireless connection between the VTS device and the user. The VTS
device has a sim slot in which a GSM SIM which is fitted to receive and transmit
SMS. The user or owner can send a SMS through mobile phone, know the position
and speed of the vehicle.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)          12




2.3 Summary




   From the history vehicle tracking system, this project similar with “vehicle
   tracking based on GPS and GSM. But this project just use for reference .The
   overall this project same from the operation of work previous project. The
   different is type of component. For example these projects use GPS shield, GSM
   shield and main board.




3.1 GPS Shield

   GPS is a powerful tool that can be fun and easy to use with the help of Arduino.
   Projects ranging from logging a trip in the car, all the way to navigating
   autonomously are all possible with GPS.




                            Figure 3.1: Location at GPS




  This quickstart guide will tell you everything you need to know about how to get
  time and position data with a GPS module. All you need is a GPS module, the
  GPS Shield, and an Arduino.



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   13




                               Figure 3.2: GPS Shield




                       Figure 3.3: The Schematic of GPS Shield




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            14




3.1.1 INTRODUCTION GPS




     We all know GPS can show your immediate location, similar to what you would
     find in a hand held unit or automobile console. GPS is also good for everything
     from tracking and logging, extremely accurate time keeping, to autonomous
     navigation and geo caching. These types of applications rely on more than just
     simple latitude and longitude, but elevation, time, heading, ground speed, and
     signal strength from the satellites. This guide will show you how to get started
     writing code that will parse or pick out meaningful information from the data
     that comes out of the TX pin on a GPS module.




3.1.1.1 Start




       The first thing you want to do is assemble the GPS shield as shown above.
       See the GPS Shield Assembly Guide for detailed assembly instructions.

          GPS Shield Assembly Guide

       Next, choose a GPS module that will work with the GPS Shield (see the
       product page for compatible GPS modules). The GPS Shield has a connector
       for an EM-406, so the EM-406 is the easiest option to get moving.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           15




       Here are the configuration options for the GPS Shield.




                       Figure 3.4: There are two slide switches




       There are two slide switches, one push button switch, and two solder jumpers
       on the GPS Shield as shown above.

       1   - Power Switch: Controls power to the GPS module

       2 - UART Selection Switch: If the UART is selected, the GPS module will
       be connected to Arduino digital pins 0 and 1. If DLINE is selected, the GPS
       will be connected to digital pins 2 and 3 (default) or potentially any other
       digital pin. DLINE must be selected in order to upload code. The reason for
       this is because the UART selection uses the same lines that are used for
       programming. If UART is selected and you load code, you will probably get
       errors in the Arduino IDE, but nothing should get damaged. This is called bus
       contention.

       2   - Solder Jumpers: These jumpers, when disabled (solder removed), will
           disconnect the GPS communication lines (TX and RX) from the Arduino.



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               16




       This allows for the user to connect any digital line to the GPS communication
       lines. To use, simply disconnect the jumpers, then wire the TX and RX
       labelled pins on the shield to any one of the digital pins 2-13 on the shield.

       4 - Reset Switch: This button is directly tied to the Arduino reset switch, so
       hitting this button will restart your Arduino sketch.

       Finally, plug in the GPS module into the Shield, then plug the Shield into an
       unpowered Arduino as shown above. Now ready to read and manipulate GPS
       NMEA data.




3.1.2 How do It make it work




      Once have everything assembled, are almost ready to load the example project
      on the Arduino. But first, will need to create a directory called libraries within
      your arduino sketchbook. Then, download the TinyGPS and NewSoftSerial
      libraries into the newly created libraries folder.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           17




               Figure 3.5: This is what the libraries folder looks like.




       Once have put the new libraries in the correct locations, the example code
       should compile with no errors. Also, Make sure the UART Selection Switch
       is moved to DLINE and proceed to load the example code onto Arduino.

       If everything has gone as planned, code compiles without errors and can
       successfully load code, should be able to open the serial monitor to see what
       the Arduino is outputting.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)     18




   Figure 3.6: Turned on GPS after it has been powered off for a while and GPS




                        Figure 3.7: GPS has a valid lock.


S’1 2011 (WPB 49806)
              VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               19




3.1.3 Using the example code




       All of the parsing and complicated stuff goes on in the Tiny GPS and New Soft
       Serial libraries, the only thing we need to do is invoke the functions available in
       the libraries. To see how this is done, refer to the guide below. For a complete
       list of available Tiny GPS functions look in the keyword.txt file in the Tiny GPS
       library folder located in your Arduino directory.

        Be sure to include the newly added libraries Tiny GPS and New Soft Serial
        Define the pins you are using and the baud rate of your GPS
        Create instances of the objects from the new libraries and define prototypes
        Create function prototypes
        Setup or initialize the hardware
        Main loop
        Get GPS function




3.1.3.1 Be sure to include the newly added libraries Tiny GPS and New Soft

          Serial




          In order for this sketch to compile without errors, you will need to download
          the New Soft Serial and Tiny GPS libraries and include them in your sketch.
          These libraries contain all of the code that allows us to parse the GPS NMEA
          string and receive it through any digital pin on the Arduino.

           #include

         The New Soft Serial library allows us to define any digital pin to work as a
         serial UART pin.


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           20




#include

       The Tiny GPS library is where the GPS parsing takes place. The library has
       many cool features beyond the scope of this tutorial, so be sure to check out
       arduiniana.org for more examples.




3.1.3.2 Define the pins are using and the baud rate of your GPS




         #define RXPIN 2
         #define TXPIN 3



       Since we are using the GPS Shield with the DLINE setting, then we need to
       define which pins on the Arduino the GPS will connect to. The GPS Shield
       uses these pins as the default connections.




         #define GPSBAUD 4800



       We also need to define the baud rate for the GPS module. The EM-406
       works at 4800bps, but if you are using another type of GPS, be sure to check
       what baud rate the GPS is using to communicate.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)          21




3.1.3.3 Create instances of the objects from the new libraries




         TinyGPS gps;
         NewSoftSerial nss(RXPIN, TXPIN);




       These lines of code basically initialize the new libraries, Tiny GPS and New
       Soft Serial, and define how we will use the libraries.




3.1.3.4 Create function prototypes




       We will only use one function to help us grab the data.

         void getgps(TinyGPS &gps);



       The get gps function will organize and print the values we want into the
       serial monitor.




3.1.3.5 Setup or initialize the hardware




         Serial.begin(115200);




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)              22




       Set the baud rate of the outgoing data from the Arduino board that will be
       received by the Arduino serial monitor. It must be at least 115200 bps,
       because we need to print everything before a new sentence comes in. If you
       slow it down, the messages might not be valid and you will get errors.

         uart_gps.begin(GPSBAUD);

       Then set the baud rate for the NewSoftSerial library. This is the baud rate of
       your GPS.




       Main loop




       The main loop constantly runs as long as your Arduino is powered. Here is
       where we want to check to see if there is any serial data coming out of the
       GPS, check to see if that data is valid, and if so, jump to the get gps function
       and print the data we want.




                           while(uart_gps.available())
                           {
                           int c = uart_gps.read();
                           if(gps.encode(c))
                           {
                           getgps(gps);
                           }
                           }



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)              23




       Here is the step through. While there is data on the RX pin, nss.available() is
       TRUE, so jump into the while loop and read one byte off of the RX pin with
       nss.read() and load it into variable 'c'. Then check to see if variable 'c' is a
       finish to a new valid GPS NMEA sentence with gps. encode(c). If there is a
       new valid sentence, GPS.encode (c) is TRUE and we jump into getGPS
       (GPS).




3.1.4 GPS function




     The Get GPS function simply calls the TinyGPS functions which automatically
     load the data into variables then prints them out in a readable format. To get
     latitude and longitude need to define variables and call the TinyGPS function
     responsible for grabing that data.




         float latitude, longitude;
         gps.f_get_position(&latitude, &longitude);



       Why float and not int or byte? Think about the data want and if that data
       will need to have fractional precision. In other words, will the values be
       whole numbers, like the day or month, or will the values be decimals, like
       latitude or elevation (i.e. 40.06477 N). If want to print decimal numbers will
       need to define float variables.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            24




         Serial.print(latitude, 5);
         Serial.print(longitude, 5);



       This will print the latitude and longitude with 5 decimal precision, which
       looks like: 40.06477. If the data want is a whole number, need to define them
       as either int or byte. However, if using the crack date time function, need to
       define the variables in exactly this way.



         int year;
         byte month, day, hour, minute, second, hundredths;
         gps.crack_datetime(&year,                 &month,      &day,       &hour,
       &minute,        &second, &hundredths);




       Then print the value with Serial.print.

         Serial.print(year);
         Serial.print(hour, DEC);
         Serial.print(minute, DEC);




3.1.5 Assembling GPS Shield



      Assembling the GPS Shield is simple. All need to do is solder stackable
      headers onto the GPS shield PCB (printed circuit board), just like the photo
      below. The following guide will show you step-by-step how to professionally
      solder your headers.



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)       25




                        Figure 3.8: Solder stackable headers



3.1.6 Preparation



     To start with a nice clear work area to make job easier. Need some tools to
     assemble the kit and to make sure have them all to gether.

     .




                          Figure 3.9: Soldering iron (TOL-00085)




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   26




                         Figure 3.9.1: Solder (TOL-09161)




These tools are optional but might find them useful.




                          Figure 3.9.2: Third Hand (TOL-09317)




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)             27




All the parts need to assemble the kit are included




                                 Figure 3.9.3: The kit




          1 x GPS Shield PCB
          2 x 8-pin Arduino Stackable Header (PRT-09279)
          2 x 6-pin Arduino Stackable Header (PRT-09280)




       Instead of using stackable header might prefer to use standard Break Away
       Headers - Straight instead. See the header section for more discussion of this.




3.1.7 Soldering



      Now it's time to solder the headers. The notice in these images and the parts
      list we use the stackable headers which allow an additional shield to be stacked


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)             28


      on top of this one. It means can still insert jumpers into the headers to gain
      access to the unused pins. Let's start by soldering one of the six pin headers




      into one of the 6 pin holes on the GPS Shield. Insert one of the 6 pin header
      into the correct location and tack one of the pins down with solder.




                               Figure 3.9.4: Soldering




       Be sure the header pins are coming out of the pin holes at right angles, so the
       shield plugs cleanly into the Arduino Main Board. The reason we start with
       soldering just one pin is because it makes it easier to obtain the correct
       alignment and fix any mistakes. Once soldered one pin might want to test the
       alignment by inserting the shield into an Arduino as shown below. Just be
       careful when do so, because the header is still only held in place with one
       solder joint.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                29




               Figure 3.9.5: Test the alignment by inserting the shield



       The headers should cleanly plug into the Arduino Main board headers and the
       shield PCB should be parallel to the Arduino Main Board PCB. Drop the
       remaining headers into place to see if everything will fit.

       If the alignment of the header isn't quite right carefully reheat the solder joint
       and move the header slightly. Don't move it after      removed the heat or end
       up with a poor or broken joint.




S’1 2011 (WPB 49806)
               VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)         30




                          Figure 3.9.6: Soldering one by one



       Now, repeat the above process for the remaining 3 headers. Make sure you
       solder the 6 pin headers into the 6 pin slots and the 8 pin headers into the 8
       pin slots on the edges of the Arduino.




3.1.8 Completed Soldering



     Once have finished soldering all 4 sets of headers, the board should look at
figure 3.9.7




                           Figure 3.9.7: Complete Soldering
S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           31




   Now's the time to double check all the soldering and fix up any problems

          Do the joints all look shiny and volcano shaped
          Do you have any "shorts" or "bridges" between joints where you've
           accidentally connected the two joints with solder




Check out the soldering guide for advice to avoid these problems. Don't be too fussy
though because re-heating and moving the joints is to be avoided if possible.




3.1.9 Completed shield




      Plug an EM-406 GPS module into the connector and make sure the gray wire
      on the GPS cable is next to the switch, as shown below. Can fix the GPS to
      the shield with some double sided sticky tape.




                           Figure 3.9.8: Complete Shield



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)       32




        Plug the shield into the Arduino and ready to move on to the Quick start
Guide




                       Figure 3.9.9: Plug the Shield into Arduino




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   33




3.1.10 Part List

              Image                 Name    Description      Datasheet    Qt
                                                                          y
                                     PCB    Printed        Adafruit       1
                                            circuit
                                            board v1.1
                                     IC1    3.3V linear    MCP1700-        1
                                            voltage        3302E/TO
                                            regulator,
                                            250mA
                                            current



                                      Q1    PNP            PN2907        1
                                            transistor,
                                            EBC pinout




                                     IC2    3.3v level     74AHC125      1
                                            converter
                                            for SD card

                                            If you don't
                                            have this
                                            part, you
                                            probably
                                            have a v1.0
                                            kit!




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)    34


                                     C1,     0.1uF          Generic         3
                                    C2, C3   ceramic
                                             capacitor




                                      C4     100uF / 6V     Generic         1
                                             capacitor



                                    LED1     Red LED        Generic         1
                                             Lite-On
                                             LTL-1CHE
                                             (or any
                                             3mm LED)
                                    LED2     Green LED      Generic         1
                                             Lite-On
                                             LTL-1CHG
                                             (or any
                                             3mm LED)

                                     R1,   1/4W 5%          Generic         3
                                    R2, R4 1.0K
                                           resistor

                                             Brown
                                             Black Red
                                             Gold
                                      R3     1/4W 5%        Generic         1
                                             10K resistor

                                             Brown,
                                             Black,
                                             Orange,
                                             Gold
                                     SD      SD/MMC         Tyco 2041021-   1
                                             card holder    3




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   35


                                    EM-     6 pin SMT     JST BM06B-       1
                                    406A    connector     SRSS-
                                            for EM-       TB(LF)(SN)
                                            406A
                                            Either
                                            Horizontal
                                            or Vertical
                                    RESE    6mm tactile   B3F-1000         1
                                    T       switch




                                    ICSP    6-pin ICSP    Generic          1
                                            header




                                            8 pin female Generic           1
                                            header
                                            (1x8)



                                    TXJM    Jumper/shu    Generic          1
                                    P       nt




                                            36 pin male   Generic          1
                                            header
                                            (1x36)


                                     IC1    3.3V linear   MCP1700-         1
                                            voltage       3302E/TO
                                            regulator,
                                            250mA
                                            current




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   36


                                      Q1     PNP            PN2907       1
                                             transistor,
                                             EBC pinout




                                     C1,     0.1uF          Generic        3
                                    C2, C3   ceramic
                                             capacitor




                                      C4     100uF / 6V     Generic        1
                                             capacitor



                                    LED1     Red LED        Generic        1
                                             Lite-On
                                             LTL-1CHE
                                             (or any
                                             3mm LED)
                                    LED2     Green LED      Generic        1
                                             Lite-On
                                             LTL-1CHG
                                             (or any
                                             3mm LED)

                                      D1     3.6V Zener     1N5227B        1
                                             diode

                                             If you don't
                                             have this
                                             part, you
                                             probably
                                             have a v1.1
                                             kit!


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   37


                                     R1,    1/4W 5%        Generic         4
                                     R2,    1.0K
                                     R7,    resistor
                                     R11
                                           Brown
                                           Black Red
                                           Gold
                                     R3,   1/4W 5%         Generic         4
                                     R5,   4.7K
                                    R6, R8 resistor

                                            yellow
                                            purple red

                                            If you don't
                                            have this
                                            part, you
                                            probably
                                            have a v1.1
                                            kit!
                                     R4,    1/4W 5%        Generic         3
                                     R9,    10K resistor
                                     R10
                                            Brown,
                                            Black,
                                            Orange,
                                            Gold
                                            SD/MMC         Tyco 1734234-   1
                                            card holder    1




                                    EM-     6 pin SMT      JST BM06B-      1
                                    406A    connector      SRSS-
                                            for EM-        TB(LF)(SN)
                                            406A
                                            Either
                                            Horizontal
                                            or Vertical
                                    RESE    6mm tactile    B3F-1000        1
                                    T       switch




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)    38


                                    ICSP     6-pin ICSP    Generic          1
                                             header




                                             8 pin female Generic           1
                                             header
                                             (1x8)



                                    TXJM     Jumper/shu    Generic          1
                                    P        nt




                                             36 pin male   Generic          1
                                             header
                                             (1x36)


                                    EB-      8 pin SMT     JST BM08B-       1
                                    85A      connector     SRSS-
                                             for EB-85A    TB(LF)(SN)
                                             Either
                                             Horizontal
                                             or Vertical
                                    Trimbl   8 pin SMT     LPPB042NFS
                                    e        header for    P-RC
                                             Trimble
                                             GPS           Digikey

                                    A1035    20 pin SMT    FTSH-111-01-
                                    -D       header for    L-DV
                                             Tyco
                                             A1035-D       Digikey
                                    BATT     Backup        Keystone 3000   1
                                             battery
                                             holder for
                                             GPS
                                             modules
                                             that do not
                                             contain a
                                             supercap or
                                             battery




S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                  39


                                        BATT          12mm 3V         CR1220 or         1
                                                      Lithium         CR1216
                                                      coin cell for
                                                      battery
                                                      backup




3.1.11 TOOLS




       There are a few tools that are required for assembly. None of these tools are
       included. If you don't have them, now would be a good time to borrow or
       purchase        them.    They     are         very     very     handy        whenever
       assembling/fixing/modifying electronic devices! I provide links to buy them,
       but    of   course,     you   should    get     them    wherever        is       most
       convenient/inexpensive. Many of these parts are available in a place like
       Radio Shack or other (higher quality) DIY electronics stores.




                                                 Soldering iron. One with temperature
                                                 control and a stand is best. A conical
                                                 or small 'screwdriver' tip is good,
                                                 almost all irons come with one of
                                                 these.

                                                 A low quality (ahem, $10 model from
                                                 RadioShack) iron may cause more
                                                 problems than its worth!

                                                 Do not use a "ColdHeat" soldering
                                                 iron, they are not suitable for delicate
                                                 electronics work and can damage the
                                                 kit (see here)



S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)         40


                                          Check out my recommended basic
                                          soldering iron and where to buy.
                                          Solder. Rosin core, 60/40. Good
                                          solder is a good thing. Bad solder
                                          leads to bridging and cold solder joints
                                          which can be tough to find. Dont buy
                                          a tiny amount, you'll run out when you
                                          least expect it. A half pound spool is a
                                          minimum.

                                          Check out my recommended basic
                                          solder and where to buy.
                                          Multimeter/Oscilloscope A meter is
                                          helpful   to   check    voltages     and
                                          continuity.

                                          Check out my recommended basic
                                          multimeter and where to buy.


                                          Flush/diagonal cutters. Essential for
                                          cutting leads close to the PCB.

                                          Check out my recommended basic
                                          diagonal cutters and where to buy.




                                          Disordering tool. If you are prone to
                                          incorrectly soldering parts.

                                          Check out my recommended basic
                                          disordering tool and where to buy.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           41


                                             'Handy Hands' with Magnifying Glass.
                                             Not absolutely necessary but will
                                             make things go much much faster.

                                             Check out my recommended basic 3rd
                                             hand tool and where to buy.




3.2 The Main board Arduino




                              Figure 3.2: Main board



      The Arduino Uno is a microcontroller board based on the ATmega328
      (datasheet). It has 14 digital input or output pins (of which 6 can be used as
      PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB
      connection, a power jack, an ICSP header, and a reset button. It contains
      everything needed to support the microcontroller; simply connect it to a
      computer with a USB cable or power it with a AC-to-DC adapter or battery to


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           42




      get started. The Uno differs from all preceding boards in that it does not use
      the FTDI USB-to-serial driver chip. Instead, it features the Atmega8U2
      programmed as a USB-to-serial converter. "Uno" means one in Italian and is
      named to mark the upcoming release of Arduino 1.0. The Uno and version 1.0
      will be the reference versions of Arduno, moving forward. The Uno is the
      latest in a series of USB Arduino boards, and the reference model for the
      Arduino platform; for a comparison with previous versions.




3.2.1 Technical Specification



       Microcontroller ATmega = 328
       Operating Voltage = 5V
       Input Voltage (recommended) = 7-12V
       Input Voltage (limits) = 6-20V
       Digital I/O Pins = 14 (of which 6 provide PWM output)
       Analog Input Pins = 6
       DC Current per I/O = Pin 40 mA
       DC Current for 3.3V = Pin 50 mA
       Flash Memory = 32 KB of which 0.5 KB used by




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   43




                          Figure 3.2.1: The specification




                       Figure 3.22: ATMega 168/328 pinout




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)               44




       Power



       The Arduino Uno can be powered via the USB connection or with an external
       power supply. The power source is selected automatically. External (non-
       USB) power can come either from an AC-to-DC adapter (wall-wart) or
       battery. The adapter can be connected by plugging a 2.1mm center-positive
       plug into the board's power jack. Leads from a battery can be inserted in the
       Gnd and Vin pin headers of the POWER connector. The board can operate on
       an external supply of 6 to 20 volts. If supplied


       With less than 7V, however, the 5V pin may supply less than five volts and
       the board may be unstable. If using more than 12V, the voltage regulator
       may overheat and damage the board. The recommended range is 7 to 12
       volts.




       The power pins are as follows:




            VIN. The input voltage to the Arduino board when it's using an
                external power source (as opposed to 5 volts from the USB
                connection or other regulated power source). You can supply voltage
                through this pin, or, if supplying voltage via the power jack, access it
                through this pin.


            5V. The regulated power supply used to power the microcontroller
                and other components on the board. This can come either from VIN
                via an on-board regulator, or be supplied by USB or another regulated
                5V supply.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           45


           3V3. A 3.3 volt supply generated by the on-board regulator.
               Maximum current draw is 50 mA.


           GND. Ground pins.




       Memory




       The Atmega328 has 32 KB of flash memory for storing code (of which 0,5
       KB is used for the boot loader); It has also 2 KB of SRAM and 1 KB of
       EEPROM (which can be read and written with the EEPROM library).



       Input and Output




       Each of the 14 digital pins on the Uno can be used as an input or output,
       using pinMode(), digitalWrite(), and digitalRead() functions. They operate at
       5 volts. Each pin can provide or receive a maximum of 40 mA and has an
       internal pull-up resistor (disconnected by default) of 20-50kilohms. In
       addition, some pins have specialized functions:


            Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX)
               TTL serial data. These pins are connected to the corresponding pins
               of the ATmega8U2 USB-to-TTL Serial chip .


            External Interrupts: 2 and 3. These pins can be configured to
               trigger an interrupt on a low value, a rising or falling edge, or a
               change in value. See the attachInterrupt() function for details.



           


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            46




            PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the
               analogWrite() function.


            SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support
               SPI communication, which, although provided by the underlying
               hardware, is not currently included in the Arduino language.



            LED: 13. There is a built-in LED connected to digital pin 13. When
               the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
               The Uno has 6 analogue inputs, each of which provide 10 bits of
               resolution (i.e. 1024 different values). By default they measure from
               ground to 5 volts, though is it possible to   change the upper end of
               their range using the AREF pin and the analog Reference() function.
               Additionally, some pins have specialized functionality.


           I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using
              the Wire library. There are a couple of other pins on the board.


           AREF. Reference voltage for the analog inputs. Used with analog
              Reference().



           Reset. Bring this line LOW to reset the microcontroller. Typically
              used to add a reset button to shields which block the one on the board.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            47




       Communication




       The Arduino Uno has a number of facilities for communicating with a
       computer, another Arduino, or other microcontrollers. The ATmega328
       provides UART TTL (5V) serial communication, which is available on
       digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this
       serial communication over USB and appears




       as a virtual com port to software on the computer. The '8U2 firmware uses
       the standard USB COM drivers, and no external driver is needed. However,
       on Windows, an *.inf file is required.. The Arduino software includes a serial
       monitor which allows simple textual data to be sent to and from the
       Arduino board. The RX and TX LEDs on the board will flash when data is
       being transmitted via the USB to serial chip and USB connection to the
       computer (but not for serial communication on pins 0 and 1). A Software
       Serial library allows for serial communication on any of the Uno's digital
       pins. The ATmega328 also support I2C (TWI) and SPI communication. The
       Arduino software includes a Wire library to simplify use of the I2C bus; see
       the documentation for details. To use the SPI communication, please see the
       ATmega328 datasheet.




       Programming




       The Arduino Uno can be programmed with the Arduino software (download).
       Select "Arduino Uno w/ ATmega328" from the Tools > Board menu
       (according to the microcontroller on your board).. The ATmega328 on the
       Arduino Uno comes preburned with a boot loader that allows you to upload


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                48




       new code to it without the use of an external hardware programmer. It
       communicates using the original STK500 protocol (reference, C header files).
       You can also bypass the boot loader and program the microcontroller through
       the ICSP (In-Circuit Serial Programming) header; see these instructions for
       details. The ATmega8U2 firmware source code is available. The
       ATmega8U2 is loaded with a DFU boot loader, which can be activated by
       connecting the solder jumper on the back of the board (near the map of Italy)
       and then resetting the 8U2. You can then use Atmel's FLIP software
       (Windows) or the DFU programmer (Mac OS X and Linux) to load a new
       firmware. Or you can use the ISP header with an external programmer
       (overwriting the DFU boot loader). AUTOMATIC (SOFTWARE) RESET
       Rather than requiring a physical press of the reset button before an upload,
       the Arduino Uno is designed in a way that allows it to be reset by software
       running on a connected computer. One of the hardware flow control lines
       (DTR) of the ATmega8U2 is connected to the reset line of the ATmega328
       via a 100 nano farad capacitor. When this line is asserted (taken low), the
       reset line drops long enough to reset the chip. The Arduino software uses this
       capability to allow you to upload code by simply pressing the upload button
       in the Arduino environment. This means that the boot loader can have a
       shorter timeout, as the lowering of DTR can be well-coordinated with the
       start of the upload. This setup has other implications. When the Uno is
       connected to either a computer running Mac OS X or Linux, it resets each
       time a connection is made to it from software (via USB). For the following
       half-second or so, the boot loader is running on the Uno. While it is
       programmed to ignore malformed data (i.e. anything besides an upload of
       new code), it will intercept the first few bytes of data sent to the board after a
       connection is opened. If a sketch running on the board receives one-time
       configuration or other data when it first starts, make sure that the software
       with which it communicates waits a second after opening the connection and
       before sending this data. The Uno contains a trace that can be cut to disable
       the auto-reset. The pads on either side of the trace can be soldered together to
       re-enable it. It's labelled "RESET-EN". You may also be able to disable the
       auto-reset by connecting a 110 ohm resistor from 5V to the reset line.

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)              49




       USB Over current




       The Arduino Uno has a resettable polypus that protects your computer's USB
       ports from shorts and over current. Although most computers provide their
       own internal protection, the fuse provides an extra layer of protection. If more
       than 500 mA is applied to the USB port, the fuse will automatically break the
       connection until the short or overload is removed.




       Physical Characteristic



       The maximum length and width of the Uno PCB are 2.7 and 2.1 inches
       respectively, with the USB connector and power jack extending beyond the
       former dimension. Three screw holes allow the board to be attached to a
       surface or case. Note that the distance between digital pins 7 and 8 is 160 mil
       (0.16"), not an even multiple of the 100 mil spacing of the other pins.




3.2.2 To use Arduino



     Arduino can sense the environment by receiving input from a variety of sensors
     and can    affect its surroundings by controlling lights, motors, and other
     actuators. The microcontroller on the board is programmed using the Arduino
     programming language (based on Wiring) and the Arduino development
     environment (based on Processing). Arduino projects can be stand-alone or
     they can communicate with software on running on a computer (e.g. Flash,
     Processing, MaxMSP).

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)      50




                           Figure 3.2.2:How to use Arduino




       First step
       File>Sketchbook> Arduino-0017>Examples> Digital>Blink Once you
       have your sketch to see something very close to the screenshot on the
       right.


       Second step
       In Tools>Board select Now you have to go to Tools>Serial Port and select
       the right serial port, the one arduino is attached to.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   51




3.2.3 Dimension Drawing




                        Figure 3.2.3: Dimension Drawing




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   52




3.3 GSM Shield



    3.3.1 Product Overview




                          Figure 3.3: GSM SM5100B


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   53




                       Figure 3.3: The System block diagram




                  Figure 3.3.1: The Schematic of GSM SM5100B




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   54




                  Figure 3.3.2:SIM connection(no power control)




3.3.2 SMS Application


      1: SMS PDU Mode




      A: Sending a message in the PDU mode



       (1) NO SMS SERVICE CENTER

       AT+CMGF=0

       AT+CMGS=16 (PDU length)
       >0011020B803167344256F00008000A00680065006C006C006F<ctrl-z>
       +CMGS: 36
       OK




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)    55




       PDU length is the sum of the receiver number length and TP-User-Data-
       Length (in bytes).


       In   this    case    PDU   length   =    6   (3167344256F0)    +    10
(00680065006C006C006F) = 16




                             Figure 3.3.3: The PDU string




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   56


2) With SMS service centre
AT+CMGF=0
AT+CMGS=24 (PDU length)
>0891683108200105F011020B803167344256F00008000A00680065006C006C0
06F<ctrl-z >
+CMGS: 12
OK
PDU length is the sum of the service centre length, receiver number length
and TP-User-Data-Length (in bytes).
In this case PDU length = 8 (91683108200105F0) + 6 (3167344256F0) + 10
(00680065006C006C006F) = 24




                             Figure 3.3.4: The PDU string




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   57


B: Receiving a message in the PDU mode



AT+CMGF=0
AT+CMGL=0
+CMGL: 1, 0, ,30
0891683108125000F0200D91683167344256F000088050417161332310003100320
0334F60597D006100620063


C: Status report
AT+CNMI=3,0,1,1 (enable SMS status report)
AT+CMGS=16 (PDU length)
>0031000B803167344256F00008000A00680065006C006C006F<ctrl-z>
+CMGS: 36
OK
(Following is status report)
+CDS: 35
0891683108200105F002020D90683167344256F0805021517145238050215171552
300


2: SMS Text Mode


A: Sending a message in the TEXT mode

(1) Default alphabet


AT+CMGF=1
AT+CMGS=“15921272576”
>HELLO9527<ctrl-z >
+CMGS: 36
OK
(2) UCS2 format


AT+CMGF=1
AT+CSMP=19,143,0,2 (<DCS> value is UCS2)

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   58




AT+CMGS=“15921272576”
>4F60597D<ctrl-z >
+CMGS: 36
OK

(3) 8bit format


AT+CMGF=1
AT+CSMP=19,143,0,1 (<DCS> value is 8bit)
AT+CMGS=“15921272576”
>3031<ctrl-z>
+CMGS: 36
OK


B: Receiving a message in the TEXT mode



AT+CMGF=1
AT+CMGL="ALL"
+CMGL: 1,2,"REC READ","+8615921272576","08/05/14,17:16:33+32"
0031003200334F60597D

C: Status report

AT+CSMP=39, 143, 0, 0 (enable SMS status report)
AT+CMGF=1
AT+CNMI=3,0,1,1
AT+CMGS="15921272576"
>00680065<ctrl-z >
>+CMGS: 45
OK
(Following is the status report)
+CDS:                              2,                    45,"+8615921272576,
145,"08/05/15,13:41:15+32""08/05/15,13:41:15+32",0


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)             59




3.4 Block Diagram




           GSM
                                          AT MEGA                           HANDPHONE
                                            328

           GPS




Working of Vehicle Tracking based on GPS and GSM Modem




       In this project it is proposed to design an embedded system which is used for
tracking of any vehicle by using Global Positioning System(GPS) and Global system
for mobile communication(GSM).

       In this project Arduino controller is used AT MEGA 328. The current design
is an application. Which will continuously monitor a moving vehicle and report the
status of the vehicle on demand? For doing so an ATMEGA328 is connected with
GPS Receiver and GSM Modem. A GSM Modem is used to send the position
(Latitude and Longitude) of the vehicle. The GSM Modem will continuously give the
data, the latitude and longitude indicating the location of the vehicle. The GSM
modem gives many parameter output. The same data is sent to the mobile at the other
end form where the location of the vehicle is demanded. When the request by user is
sent to the number at the modem, the system automatically sends a return reply to
that mobile indicating the position of the vehicle in terms of latitude and longitude.
S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           60




       The project is vehicle tracking we can locate the vehicle around the globe
with microcontroller Arduino Uno, GPS Shield, GSM Shield. Microcontroller used
ATMEGA 328.With help of instruction set it processes the instruction and it acts as
interface between GSM and GPS with help of communication of microcontroller.
GPS always transmit the data and GSM transmit and receive the data. GPS pin TX is
connected to microcontroller via pins 2 and 3. GSM pins TX and RX are connecter
to pin 3 and 4. Arduino Uno controller communicates with the help of serial
communication. First it takes the data from the GPS receiver and then sends the
information to the owner in the form of SMS with help of GSM Modem. GPS works
on 9600 baud rate is used to received the data from space segment (from satellites),
the GOS values of different satellites are sent to ATMEGA 328, Where these process
and forwarded to GSM. From the values microcontroller Arduno takes only latitude
and longitude values excluding time, altitude, speed and course. Example, LAT
1728:2470 LOG:7843.3089 GSM Modem with a baud rate 57600. GSM is a global
system for mobile communication in this project it act as a SMS Receiver and SMS
sender. The power is supplied to component like GSM, GPS and Arduino Uno using
a 12v battery. GSM requires 12V and Arduino Uno requires 5V.




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            61




4.0 Introduction




Program Vehicle Tracking based on GPS and GSM Modem

 //NOORUL ASILAH OSMAN

//NORUL AKMA SAIBON

//PROJECT:VEHICLE TRACKING BASED ON GPS AND GSM MODEM

// SUPERVISOR:SIR SAFYZAN SALIM


#include <TimedAction.h>
#include <NewSoftSerial.h>
#include <TinyGPS.h>
#include <string.h>

// Uncomment the defs to send values to Serial for debug

// #define DEBUG_CELL

// Digital pin assignments

#define CELL_RX_PIN 2              // CELL serial receive data
#define CELL_TX_PIN 3              // CELL serial transmit data

#define GPSBAUD 4800              //Set this value equal to the baud rate of your GPS

// Analog pin assignments

// Simple serial protocol
#define STX       0x02    // Start of text
#define ETX 0x03          // End of text
#define CR       0x0D     // Carriage return
#define CTRL_Z 0x1A           // Control-z

TimedAction CELL_NetConnectTimeoutTask = TimedAction( 20000,

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            62


CELL_NetConnectTimeout ); // timeout dlm masa 20 saat
TimedAction CELL_ReplyTimeoutTask = TimedAction( 5000,
CELL_ReplyTimeout ); // timeout dlm masa 5 saat



// Interfaces
TinyGPS gps;            // Create an instance of the TinyGPS object

NewSoftSerial CELL_Serial = NewSoftSerial( CELL_RX_PIN, CELL_TX_PIN );

// Cell protocol Command - Reply
enum CellCmnd
{
  Cmnd_None,
  Cmnd_Connect,
  Cmnd_SMS_Type,
  Cmnd_SMS_Indication,
  Cmnd_CallForwarding,
  Cmnd_Location,
  Cmnd_SendGPSMessage,
  Cmnd_DeleteMsgs,
  Cmnd_OK
} nextCellCmnd = Cmnd_Connect;

enum CellReply
{
  Reply_None,
  Reply_Connect,
  Reply_SMS_Type,
  Reply_SMS_Indication,
  Reply_CallForwarding,
  Reply_Location,
  Reply_SendGPSMessage,
  Reply_MessageText,
  Reply_DeleteMsgs,
  Reply_OK
} nextCellReply = Reply_Connect;

// Cell Module
#define BUFFSIZE       100

// Private cell phone number for fowarding calls and sending location info at startup
// Put your cell phone number here...

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   63


char *privCellPhone = "+60192205169";




char cellMsgBuff[ BUFFSIZE ] = "";

char cellCmndBuff[ BUFFSIZE ] = "";
char cellPhoneNumber[ 20 ] = "";
int cellMsgBuffIndex = 0;
char incomingChar = 0;
int connectRespCnt = 0;
bool cellConnected = false;
bool cellNetConnectTimeout = false;
bool cellReplyTimeout = false;

// GPS
float latitude, longitude;
int year;
byte month, day, hour, minute, second, hundredths;
float x, y, km;
float destinationLat = 3.131200635418334;
float destinationLon = 101.51766434311867;

// This is where you declare prototypes for the functions that will be
// using the TinyGPS library.
void getgps(TinyGPS &gps);

void setup( )
{
  Serial.begin( GPSBAUD );              // Start GPS interface
  CELL_Serial.begin( 9600 );           // Start CELL Module interface

 CELL_NetConnectTimeoutTask.enable( ); // Enable task for Cell Network
Connect timeout
 CELL_NetConnectTimeoutTask.reset( ); // Wait a full time period
 CELL_ReplyTimeoutTask.disable( );   // Disable the Cell reply timeout timer

 // Signal setup complete

 // Serial comm to PC if any debug defs exist
 // Be sure to disable all serial comm when uploading to the TouchShield
 #if defined DEBUG_CELL
 Serial.println( "Debug enabled..." );

S’1 2011 (WPB 49806)
               VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)       64


    #define DEBUG
    #endif
}

//************************
// Start Rolling
//


void loop( )
{

    #ifndef DEBUG       // Can't use GPS if serial port is being used for debugging
    GPS_Update( );
    #endif


    CELL_Update( );
    CELL_Actions( );
    CELL_NetConnectTimeoutTask.check( );
    CELL_ReplyTimeoutTask.check( );

}




void GPS_Update( )
{
  while( Serial.available( ) )
  {
   int c = Serial.read(); // load the data into a variable...
     if(gps.encode(c)) // if there is a new valid sentence...
     {
       getgps(gps);      // then grab the data.
     }
  }

}

void getgps(TinyGPS &gps)
{
  // To get all of the data into varialbes that you can use in your code,
  // all you need to do is define variables and query the object for the
  // data. To see the complete list of functions see keywords.txt file in

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)                65


 // the TinyGPS and NewSoftSerial libs.

  // Then call this function
 gps.f_get_position(&latitude, &longitude);
 gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);



 hour = hour + 8;
 if (hour >= 24) {
   hour = hour - 24; }
   else
    { hour = hour; }

    x = 111.2057 * (destinationLat - latitude);
    y = 85.2952 * (destinationLon - longitude);
    km = sqrt((x * x) + (y * y));
  }
//************************
// Cell Module GSM/GPRS
// CELL_Update( )
// Assemble messages from the Cell Module
//
void CELL_Update( )
{
  while( CELL_Serial.available( ) )
  {
    incomingChar = CELL_Serial.read( );         // Get the character from the cell

  #ifdef DEBUG_CELL
  Serial.print( incomingChar );
  #endif

  // First check to see if we're waiting to be prompted by the cell module
  // (greater than sign) to enter a text message to be sent, or have timed out waiting...
  if( nextCellCmnd == Cmnd_SendGPSMessage )
  {
    if( incomingChar == '>' || cellReplyTimeout )
    {
      SendGPSMessage( );                     // Send text message with our location
      cellMsgBuffIndex = 0;
      cellMsgBuff[cellMsgBuffIndex] = '\0';

    CELL_ResetReplyTimeout( );

S’1 2011 (WPB 49806)
                   VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   66


             nextCellCmnd = Cmnd_None;
             nextCellReply = Reply_SendGPSMessage;
         }


 // Look for a CR which terminates incoming messages and replies from the cell
module...

        else if( incomingChar == '\r' )
        {
          if( cellMsgBuffIndex > 0 )          // Just ignore completely if < 1
          {
            // We have a message...
            ProcessCellReply( );
          }

         // Reset index to beginning for next message
         cellMsgBuffIndex = 0;
         cellMsgBuff[cellMsgBuffIndex] = '\0';
        }
        // Store incoming characters until a CR is received, which indicates
        // a message is ready to be processed
        else if( incomingChar > 0x1F && incomingChar < 0x7F )
        {
          cellMsgBuff[cellMsgBuffIndex] = incomingChar;
          if( ++cellMsgBuffIndex >= BUFFSIZE )
            cellMsgBuffIndex = 0;
          cellMsgBuff[cellMsgBuffIndex] = '\0';
        }
    }

    // Reset message state if timed out waiting for a reply
    // Send AT command in attempt to resync
    if( cellReplyTimeout )
    {
      cellMsgBuffIndex = 0;
      cellMsgBuff[cellMsgBuffIndex] = '\0';
      CELL_ResetReplyTimeout( );
      nextCellCmnd = Cmnd_OK;
      nextCellReply = Reply_None;
    }
}

//************************


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)     67


// Cell Module GSM/GPRS
// ProcessCellReply( )
// Process replies from the Cell Module and determine the next Cmnd
// Refer to SM5100B AT Command Set guide
//
void ProcessCellReply( )
{
  // Reset message state if cell decides to start over...
  if( strncmp( cellMsgBuff, "+SIND: 1", 10 ) == 0)
  {
    nextCellReply = Reply_Connect;
    nextCellCmnd = Cmnd_Connect;
    connectRespCnt = 0;
    cellConnected = false;
    CELL_NetConnectTimeoutTask.enable( );
    CELL_NetConnectTimeoutTask.reset( );
    return;
  }
  // Check to see if we've received an unsolicited message...
  else if( cellConnected && ( strncmp( cellMsgBuff, "+CMT:", 5 ) == 0 ) )
  {
    // We're receiving a message...
    // Get source phone number, then set up to get the text on the next CR...
    strncpy( cellPhoneNumber, &cellMsgBuff[7], 12 );
    cellPhoneNumber[13] = '\0';
    nextCellReply = Reply_MessageText;
    nextCellCmnd = Cmnd_None;
    return;
  }

 /*
  The following automates connecting, configuring call forwarding, and setting
SMS type and return mode, deleting messages
  Stream from cell at startup should look something like the following:
  +SIND: 1
  +SIND: 10,"SM",1,"FD",1,"LD",1,"MC",1,"RC",1,"ME",1
  +SIND: 3
  +SIND: 11
  +SIND: 4
 */

 switch( nextCellReply )
 {
   case Reply_Connect:

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)           68


   if( strncmp( cellMsgBuff, "+SIND: 4", 10 ) == 0 )
     connectRespCnt += 1;
   else if( strncmp( cellMsgBuff, "+SIND: 11", 10 ) == 0 )
     connectRespCnt += 2;

   // If we've gotten a 4 and an 11, assume we're good to go
   if( connectRespCnt > 2 && !cellConnected )
   {
     cellConnected = true;
     CELL_NetConnectTimeoutTask.disable( );
     nextCellCmnd = Cmnd_CallForwarding;
     nextCellReply = Reply_None;
   }
   // Reset the timeout interval with each connect response while waiting to connect
   CELL_NetConnectTimeoutTask.reset( );
   break;

  case Reply_CallForwarding:
   if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
   {
     CELL_ResetReplyTimeout( );
     nextCellCmnd = Cmnd_SMS_Type;
     nextCellReply = Reply_None;
   }
   break;

  case Reply_SMS_Type:
   if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
   {
     CELL_ResetReplyTimeout( );
     nextCellCmnd = Cmnd_SMS_Indication;
     nextCellReply = Reply_None;
   }
   break;

  case Reply_SMS_Indication:
   if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
   {
     CELL_ResetReplyTimeout( );
     nextCellCmnd = Cmnd_DeleteMsgs;
     nextCellReply = Reply_None;

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)        69


   }
   break;

  case Reply_Location:
   if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
   {
     CELL_ResetReplyTimeout( );
     nextCellCmnd = Cmnd_None;
     nextCellReply = Reply_None;
   }
   break;

  case Reply_SendGPSMessage:
   if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
   {
     CELL_ResetReplyTimeout( );
     nextCellCmnd = Cmnd_None;
     nextCellReply = Reply_None;
   }
   break;

  case Reply_MessageText:
    // We received a text message and captured the sending phone number in
cellPhoneNumber.
    // Parse message and reply with GPS location message if requested. We'll be
prompted by the
    // Cell Module for when to send the message data with a '>'.
    nextCellCmnd = ( strncmp( cellMsgBuff, "Loc?", 4 ) == 0 ) ? Cmnd_Location :
Cmnd_OK;
    nextCellReply = Reply_None;
    break;

   case Reply_DeleteMsgs:
    if( ( strncmp( cellMsgBuff, "OK", 2 ) == 0 ) || ( strncmp( cellMsgBuff, "+CME
ERROR", 10 ) == 0 ) )
    {
      CELL_ResetReplyTimeout( );
      strcpy( cellPhoneNumber, privCellPhone );
      nextCellCmnd = Cmnd_Location; // Cmnd_Location if send location on
startup, else Cmnd_None
      nextCellReply = Reply_None;
    }

S’1 2011 (WPB 49806)
                  VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   70


         break;

        case Reply_OK:
         CELL_ResetReplyTimeout( );
         nextCellCmnd = Cmnd_None;
         nextCellReply = Reply_None;
         break;

        default:
         nextCellCmnd = Cmnd_None;
         nextCellReply = Reply_None;
         break;
    }
}

//************************
// Cell Module GSM/GPRS
// CELL_Actions( )
// Execute Cell Module Commands
// Refer to SM5100B AT Command Set guide
//
void CELL_Actions( )
{
  switch( nextCellCmnd )
  {
    case Cmnd_Connect:
     break;

        case Cmnd_CallForwarding:
         strcpy( cellCmndBuff, "AT+CCFC=0,3,\"" );
         strcat( cellCmndBuff, privCellPhone );
         strcat( cellCmndBuff, "\",129" );
         SendATCommand( cellCmndBuff );
         nextCellReply = Reply_CallForwarding;
         nextCellCmnd = Cmnd_None;
         break;

        case Cmnd_SMS_Type:
         SendATCommand( "AT+CMGF=1" );
         nextCellReply = Reply_SMS_Type;
         nextCellCmnd = Cmnd_None;
         break;

        case Cmnd_SMS_Indication:

S’1 2011 (WPB 49806)
                VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)        71


      SendATCommand( "AT+CNMI=3,3" );
      nextCellReply = Reply_SMS_Indication;
      nextCellCmnd = Cmnd_None;
      break;

     case Cmnd_Location:
      strcpy( cellCmndBuff, "AT+CMGS=\"" );
      strcat( cellCmndBuff, cellPhoneNumber );
      strcat( cellCmndBuff, "\"" );
      SendATCommand( cellCmndBuff );
      nextCellReply = Reply_None;
      nextCellCmnd = Cmnd_SendGPSMessage;
      break;

     case Cmnd_DeleteMsgs:
      SendATCommand( "AT+CMGD=1,4" );
      nextCellReply = Reply_DeleteMsgs;
      nextCellCmnd = Cmnd_None;
      break;

     case Cmnd_OK:
      SendATCommand( "AT" );
      nextCellReply = Reply_OK;
      nextCellCmnd = Cmnd_None;
      break;

     default:
      break;
 }

 #ifdef DEBUG_CELL
 while( Serial.available( ) )
 {
   char incoming_char = Serial.read( );    // Get the character from the Serial port.

     if( incoming_char == '~' )        // If it's a tilde...
       incoming_char = CR;             // ...convert to a carriage return
     else if( incoming_char == '^' )     // If it's an up caret...
       incoming_char = CTRL_Z;              // ...convert to ctrl-Z

 CELL_Serial.print( incoming_char );    // Send the character to the cellular
module.
 Serial.print( incoming_char );    // Echo it back to the terminal


S’1 2011 (WPB 49806)
               VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   72


     if( incoming_char == CR || incoming_char == CTRL_Z )
     {
       Serial.println( );
       break;
     }
    }
    #endif
}

void SendATCommand( char *cmnd )
{
  delay( 1000 ); // original 150 too short. Recheck lowest value
  CELL_Serial.println( cmnd );

    CELL_StartReplyTimeout( );

    #ifdef DEBUG_CELL
    Serial.print( "\n>> " );
    Serial.println( cmnd );
    #endif
}

void SendGPSMessage( )
{
  // Send text message with GPS location
  delay( 1000 ); // original 150 too short. Recheck lowest value

    CELL_Serial.print( "Lat/Long: " );
    CELL_Serial.print( latitude, 5 );
    CELL_Serial.print( "," );
    CELL_Serial.print( longitude, 5 );

     if (latitude < 3.14555 && latitude > 3.14225 )
     {
    // Location Bukit Bintang - Pudu
     CELL_Serial.print( " Loc: Bukit Bintang - Pudu " );
     }
      else if (latitude < 3.14555 && latitude > 3.13657)
     {
    // location Bukit Bintang - DBP
    CELL_Serial.print( " Loc: DBP - Bukit Bintang " );
     }
       else if (latitude < 3.13657 && latitude > 3.12847)
     {

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   73


 // location DBP - Loke Yew
 CELL_Serial.print( " Loc: Loke Yew - DBP " );
  }
     else if (latitude < 3.12847 && latitude > 3.12154)
  {
 // location Loke Yew - Istana
  CELL_Serial.print( " Loc: Per.Istana - Loke Yew " );
  }
   else if (latitude < 3.12154 && latitude > 3.09471)
  {
 // location Kuchai Lama - Istana
  CELL_Serial.print( " Loc: Per.KuchaiL - Per.Istana " );
  }
   else if (latitude < 3.09471 && latitude > 3.06370)
  {
 // location Per. MRR - Istana
  CELL_Serial.print( " Loc: Per.MRR2 - Per.KuchaiL " );
  }

   else if (latitude < 3.06370 && latitude > 3.03938)
  {
 // location Sungei Besi - Istana
  CELL_Serial.print( " Loc: Sungei Besi Tol - Per.MRR2 " );
  }
   else if (latitude < 3.03938 && latitude > 2.99915)
  {
 // location UPM Tol - Sungei Besi
  CELL_Serial.print( " Loc: UPM - Sungei Besi Tol " );
  }

  else if (latitude < 2.99915 && latitude > 2.985467)
  {
 // location Kajang Tol - UPM Tol
  CELL_Serial.print( " Loc: Kajang - UPM " );
  }
   else if (latitude < 2.985467 && latitude > 2.93217)
  {
 // location Bangi Tol - Kajang Tol
  CELL_Serial.print( " Loc: Bangi - Kajang " );
  }

   else if (latitude < 2.93217 && latitude > 2.877631)
  {
 // location Putra Mahkota - Bangi Tol

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   74


  CELL_Serial.print( " Loc: Putra Mahkota - Bangi " );
  }
  else if (latitude < 2.877631 && latitude > 2.831961)
  {
 // location Nilai - Putra Mahkota
  CELL_Serial.print( " Loc: Nilai - Putra Mahkota - Bangi " );
  }
   else if (latitude < 2.831961 && latitude > 2.715626)
  {
 // location Seremban - Nilai
  CELL_Serial.print( " Loc: Seremban - Nilai " );
  }
   else if (latitude < 2.715626 && latitude > 2.687847)
  {
 // location PD - Seremban
  CELL_Serial.print( " Loc: PD - Seremban " );
  }
    else if (latitude < 2.687847 && latitude > 2.683518)
  {
 // location Senawang - PD
  CELL_Serial.print( " Loc: Senawang - PD " );
  }
    else if (latitude < 2.683518 && latitude > 2.568089)
  {
 // location Pedas Linggi - Senawang
  CELL_Serial.print( " Loc: Pedas Linggi - Senawang " );
  }
     else if (latitude < 2.568089 && latitude > 2.444397)
  {
 // location Simpang Ampat - Pedas Linggi
  CELL_Serial.print( " Loc: Simpang Ampat - Pedas Linggi " );
  }
   else if (latitude < 2.444397 && latitude > 2.304635)
  {
 // location Ayer Keroh - Simpang Ampat
  CELL_Serial.print( " Loc: Ayer Keroh - Simpang Ampat " );
  }

 else if (latitude < 2.304635 && latitude > 2.269601)
  {
 // location Jasin - Ayer Keroh
  CELL_Serial.print( " Loc: Jasin - Ayer Keroh " );
  }
 else if (latitude < 2.269601 && latitude > 2.246938)

S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   75


  {
 // location Tangkak - Jasin
  CELL_Serial.print( " Loc: Tangkak - Jasin " );
  }

  else if (latitude < 2.246938 && latitude > 2.131815)
  {
 // location Pagoh - Tangkak
  CELL_Serial.print( " Loc: Pagoh - Tangkak " );
  }
   else if (latitude < 2.131815 && latitude > 1.994849)
  {
 // location Yong Peng - Pagoh
  CELL_Serial.print( " Loc: Yong Peng - Pagoh " );
  }
   else if (latitude < 1.994849 && latitude > 1.926739)
  {
 // location Air Hitam - Yong Peng
  CELL_Serial.print( " Loc: Air Hitam - Yong Peng " );
  }
   else if (latitude < 1.926739 && latitude > 1.888694)
  {
 // location Machap - Air Hitam
  CELL_Serial.print( " Loc: Machap - Air Hitam " );
  }
  else if (latitude < 1.888694 && latitude > 1.792914)
  {
 // location Simpang Renggam - Machap
  CELL_Serial.print( " Loc: Simpang Renggam - Machap " );
  }
   else if (latitude < 1.792914 && latitude > 1.70537)
  {
 // location Sedenak - Simpang Renggam
  CELL_Serial.print( " Loc: Sedenak - Simpang Renggam " );
  }
   else if (latitude < 1.70537 && latitude > 1.647824)
  {
 // location Kulai - Sedenak
  CELL_Serial.print( " Loc: Kulai - Sedenak " );
  }
   else if (latitude < 1.647824 && latitude > 1.606148)
  {
 // location Senai - Kulai
  CELL_Serial.print( " Loc: Senai - Kulai " );

S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   76


 }
     else if (latitude < 1.606148 && latitude > 1.582275)
  {
 // location Skudai Tol - Senai
  CELL_Serial.print( " Loc: Skudai Tol - Senai " );
  }
   else if (latitude < 1.582275 && latitude > 1.547913)
  {
 // location Per.UTM - Skudai Tol
  CELL_Serial.print( " Loc: Per.UTM - Skudai Tol " );
  }

  else if (latitude < 1.547913 && latitude > 1.503597)
  {
 // location Tampoi - Per.UTM
  CELL_Serial.print( " Loc: Tampoi - Per.UTM " );
  }

   else if (latitude < 1.503597 && latitude > 1.488753)
  {
 // location Larkin - Tampoi
  CELL_Serial.print( " Loc: Larkin - Tampoi " );
  }

  else
  {
 // Location undefined
   CELL_Serial.print( " Loc: Undefined " );
  }

 CELL_Serial.print( " Date: " );
 CELL_Serial.print( month, DEC );
 CELL_Serial.print( "/" );
 CELL_Serial.print( day, DEC );
 CELL_Serial.print( "/" );
 CELL_Serial.print(year);
 CELL_Serial.print( " Time: " );
 CELL_Serial.print( hour, DEC );
 CELL_Serial.print( ":" );
 CELL_Serial.print( minute, DEC );
 CELL_Serial.print( ":" );
 CELL_Serial.print( second, DEC );
 // CELL_Serial.print( "." );
 // CELL_Serial.print( hundredths, DEC );

S’1 2011 (WPB 49806)
                VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   77




    // CELL_Serial.print( " Altitude(meters): " );
    // CELL_Serial.print( gps.f_altitude());

    // CELL_Serial.print( " Course(degrees): " );
    // CELL_Serial.print( gps.f_course());

    CELL_Serial.print( " Remain Distance: " );
    CELL_Serial.print( km, 2 );
    CELL_Serial.print( "km" );

    CELL_Serial.print( " Speed(kmph): " );
    CELL_Serial.print( gps.f_speed_kmph());

    CELL_Serial.print( CTRL_Z, BYTE );

    CELL_StartReplyTimeout( );

    #ifdef DEBUG_CELL
    Serial.println( "Sent location..." );
    #endif
}
//***************************************************
// Cell Module Message Repy Timeout
// Timed Action
// Manages the timer for cell message replies
//
void CELL_ReplyTimeout( )
{
  cellReplyTimeout = true;
  CELL_ReplyTimeoutTask.disable( );

    #ifdef DEBUG_CELL
    Serial.println( "ReplyTimeout" );
    #endif
}

void CELL_StartReplyTimeout( )
{
  // Start reply timeout task...
  cellReplyTimeout = false;
  CELL_ReplyTimeoutTask.enable( );
  CELL_ReplyTimeoutTask.reset( );
}

S’1 2011 (WPB 49806)
              VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   78




void CELL_ResetReplyTimeout( )
{
  cellReplyTimeout = false;
  CELL_ReplyTimeoutTask.disable( );
}

//***************************************************
// Timeout for Cell Module Network Connection
// Timed Action
// Re-enables serial comm with TouchShield after timeout
//
void CELL_NetConnectTimeout( )
{
  cellNetConnectTimeout = true;
  CELL_NetConnectTimeoutTask.disable( );

    #ifdef DEBUG_CELL
    Serial.println( "NetConnectTimeout" );
    #endif
}




S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   79




4.1 Result



The longitude/latitude, date, course and speed at UNIKL-BMI




S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)   80


4.2 The Step How Vehicle Tracking works




                 • The engine is ON (start)
  step1

                 • Handphone (the owner) will received message"engine ON"
  step2

                 • The owner reply message.Type "Loc"
  step3


                 • The GSM received message from handphone "Loc"
  step4

                 • GPS search the location,log/latitude
  step5

                 • GSM read and reply message to handphone
  step6


S’1 2011 (WPB 49806)
            VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)            81


4.3 How the system work




       How the System “Vehicle Tracking Based on GPS and GSM” works.



4.4 Summary




     This part, result and analysis just inform about the function GSM shield and GPS
shield about the one situation if the car was stolen. The step how the GPS and GSM
function and works. The longitude and latitude just refer in goggle map Malaysia.
The overall result in this project not accurately longitude and latitude but can help
the people to know where the vehicle and protect from the theft situation.




S’1 2011 (WPB 49806)
             VEHICLE TRACKING BASED ON GPS AND GSM MODEM (FINAL YEAR PROJECT)             82


5.1 Conclusion




Vehicle Tracking based on GPS and GSM Modem is the technology used to
determine the location of a vehicle using different methods like GPS through
satellites and ground based stations. The GSM modem in the control centre receives
the coordinates via SMS and updates the main database which contains all the
whereabouts of all the vehicles. By following triangulation or trilateration methods
the tracking system enables to calculate easy and accurate location of the vehicle.
Vehicle information like location details, speed, longitude and latitude can be viewed
on a digital mapping with the help of software via Internet. Even data can be stored
and downloaded to a computer from the GPS unit at a base station and that can later
be used for analysis. This system is an important tool for tracking each vehicle at a
given period of time and now it is becoming increasingly popular for people having
expensive cars and hence as a theft prevention and retrieval device. Vehicle Unit it
is the hardware component attached to the vehicle having either a GPS/GSM modem.
The unit is configured around a primary modem that functions with the tracking
software by receiving signals from GPS satellites or radio station points with the help
of antenna. The controller modem converts the data and sends the vehicle location
data to the server.




S’1 2011 (WPB 49806)

								
To top