Table of Contents List of Figures... 3 Acknowledgements... 4 Abstract... 5 Chapter 1: Introduction... 6 1.1 General Introduction... 6 1.2 Aims and Objectives... 7 1.3 The GPS + GSM modem... 8 1.4 GSM modem... 8 1.5 System Architecture diagram... 9 Chapter 2: Literature Review... 10 2.1 Programming Languages Required... 10 2.1.1 PHP... 10 2.1.2 Java Script... 10 2.2 XAMPP... 11 2.3 Adobe Dreamweaver... 11 2.4 ODBC... 11 2.5 SMS Engine... 11 2.6 IntelliTrac X1 Wizard... 12 2.7 No-IP... 12 2.8 Google Maps API... 12 Chapter 3: Getting Started... 13 3.1 Step 1: Create a Microsoft Access Database... 14 3.2 Step 2: Configure and Test the SMS Engine Software... 16 3.3 Step 3: Configure the ODBC... 19 3.4 Step 4: Install, Test and Configure the IntelliTrac X1... 21 3.4.1 Installing the IntelliTrac X1... 21 3.4.2 Testing the IntelliTrac X1... 22 Akila Wajirakumara Page 1
3.4.3 Configuring the IntelliTrac X1 Wizard... 23 3.5 Step 5: Adding the Google Maps API... 25 Chapter 4: Creating the Online Vehicle Tracking System... 27 4.1 View Information of all the Vehicles Page... 28 4.2 Locate and Track the Vehicle s last position Page... 29 4.3 Find Closest Vehicle to your Location Page... 31 4.4 View Complete Vehicle Log Page... 32 Chapter 5: Conclusion... 33 5.1 Important features of this project... 33 5.2 Practical Implementations... 34 5.3 Future Development... 34 References... 35 Appendix... 36 Codes... 36 Google Maps codes to Locate and Track Vehicle... 36 Functions for Updating the Main Database... 39 Akila Wajirakumara Page 2
List of Figures Figure 1 - IntelliTrac X1 08 Figure 2 - Q24 08 Figure 3 - Table containing all the information of the drivers in the database 14 Figure 4 - Vehicle log of all the drivers in the database 15 Figure 5 - Configuring SMS Engine 16 Figure 6 - Starting SMS Engine 17 Figure 7 - SMS Engine Database 18 Figure 8 - ODBC Create Data Source 19 Figure 9 - ODBC Microsoft Access Setup 19 Figure 10 - ODBC Data Source Administrator 20 Figure 11 - Installing the IntelliTrac X1 21 Figure 12 - Setting parameters for Port Settings in Hyper Terminal 22 Figure 13 - Test Output for X1 on Hyper Terminal 23 Figure 14 - COM Port Setting in X1 Wizard 23 Figure 15 - Enter Unit Password to Reboot in X1 Wizard 24 Figure 16 - Reboot Complete in X1 Wizard 24 Figure 17 - Communications Setting in X1 Wizard 24 Figure 18 - Configuring the X1 to Track using X1 Wizard. 25 Figure 19 - Uploading data into the X1 using X1 Wizard 25 Figure 20 Signing up for the Google Maps API Key 26 Figure 21 Google Maps API Key 26 Figure 22 GPS Modem Table Web Page 28 Figure 23 Vehicle Query page prompts Vehicle number 29 Figure 24 Vehicle Query page showing the Vehicle s log 29 Figure 25 Vehicle Query page showing the map 30 Figure 26 Find closest Vehicle Page prompting user to enter location 31 Figure 27 Find closest Vehicle Page Map 32 Figure 28 Vehicle Log Page 32 Akila Wajirakumara Page 3
Acknowledgements I would like to thank my supervisor, Dr Lim Wee Gin for his undying support, attention and his abundance of guidance which helped me throughout this project. He was most understanding and patient with his supervision over my project. Mr. Ng Kong Leng, the marketing director of MOBITEK System Sdn Bhd for supplying me with all the relevant equipments to fulfill my project. Also for the training which gave me a good head start on my project, thank you. And finally to my family and friends who always believed in my abilities and potential. My parents, for all your support and love, thank you all. Akila Wajirakumara Page 4
Abstract This project deals with an SMS (Short Message Service) enabled vehicle tracking system. The heart of this project lies with the use of a GPS + GSM modem which is installed in the vehicle and is in charge of tracking the vehicle and sending the coordinates to the GSM (Global System for Mobile communication) modem. The GSM modem in the control center receives the coordinates via SMS and updates the main database which contains all the whereabouts of all the vehicles at specified times. The information is uploaded in a website where the vehicle s position can be located in a map with the aid of the Google Maps application. This thesis explores the foundation of GPS, GSM, and all the software related in the project; and the use of their concepts to produce a vehicle tracking system which is cheaper and more effective than most commercial car tracking features in the market today. Akila Wajirakumara Page 5
Chapter 1: Introduction 1.1 General Introduction GSM (Global System for Mobile communication) is a cellular network that mobile phones use to acquire connectivity in their immediate vicinity. These networks operate in different frequency ranges, mainly between 900 MHz and 1800 MHz. It uses a narrowband variation of Time Division Multiple Access (TDMA), which allows eight simultaneous calls on the same radio frequency. SMS (Short Message Service) is a protocol for sending and receiving text messages over GSM networks. The text can comprise of words, numbers or an alphanumeric combination. A message can go up to 160 characters of text in length using GSM coding. GPS (Global Positioning System) is a satellite based navigation system made up of a network of 24 satellites placed into the orbit. These satellites transmit coded information which allows us to identify locations on earth precisely by measuring the distance from the satellites. The Vehicle Tracking System (VTS) also uses GPS to take the location, speed, direction and time data via satellite from the Global Positioning System to the GPS + GSM receiver in a vehicle and also transmits it to a central computer connected to a private network or the internet. It is an electronic device installed in a vehicle to enable the owner or a third party to track the vehicle s location. Most of these systems combine with mobile phones through SMS to communicate the vehicle s location to a remote user. The market for GPS vehicle tracking systems is considered as one of the fastest growing markets for GPS applications. There are many levels of sophistication, but what all systems have in common is a GPS receiver and software to put the tracking results on a map. The Vehicle Tracking System has several applications such as stolen vehicle recovery, fleet management, asset tracking, field service management, field sales and trailer tracking. PHP (Hypertext Pre-processor) is a server-side; HTML embedded scripting programming language used to create web pages with dynamic features. In this project it is used for designing an online Vehicle Tracking Report. Akila Wajirakumara Page 6
1.2 Aims and Objectives The aim of this project is to produce an SMS (Short Message Service) enabled vehicle tracking system using GPS and SMS. This project is divided into three main parts namely the GPS + GSM modem, the GSM modem and the website with the Google Maps application. My objectives for this project are 1. Install the GPS + GSM modem in a vehicle a developing a remote configuration tool. 2. Connecting the GSM modem to the control center and ensure it receives the information sent from the GPS + GSM modem. 3. Design an online Vehicle Tracking Report which includes a map. Akila Wajirakumara Page 7
1.3 The GPS + GSM modem The GPS + GSM modem used in this project is the IntelliTrac X1. The modem can function as a standalone system once programmed using the IntelliTrac X1 Wizard software. The GPS + GSM modem will be the core of this project as it will be used to SMS the coordinates of the vehicle s location at specified time or distance intervals to the GSM modem in the control center. There is a SIM card connected to this device. 1.4 GSM modem Figure 1 - IntelliTrac X1 The GSM modem used in this project is the Q24. This modem is connected to the control center where it receives SMS from the GPS + GSM modem and is stored in a Microsoft Access Database with the aid of the SMS Engine software. There is a SIM card connected to this device as well. Figure 2 - Q24 Akila Wajirakumara Page 8
1.5 System Architecture diagram IntelliTrac X1 (GPS Terminal) Automatically sends out GPS data through SMS Q24 (GSM Modem) Receive the incoming SMS and insert a new record to SMS Engine SMS Engine Updates the database and uses Google Maps to locate the vehicle [1] Google Maps Web Application Locate the vehicle Track the vehicle Show GPS report Akila Wajirakumara Page 9
Chapter 2: Literature Review This thesis covers the basis of a Vehicle Tracking System using GPS and SMS.This chapter introduces all the theories and information related to this project to aid understanding of the other chapters in this thesis. 2.1 Programming Languages Required There are two programming languages, PHP and Java Script which are required to develop the Vehicle Tracking System. These programming languages are highly essential for this project in order to interact with the Microsoft Access Databases via ODBC to read the information and to add the Google Maps API Application. 2.1.1 PHP PHP (Hypertext Pre-Processor) is a widely used general purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP Scripts are enclosed within tags (starts with <?php and ends with?>) and because of that, the programmer has the flexibility to jump between HTML and PHP instead of having to rely on heavy amounts of code to output HTML. Since PHP is executed on the server, the codes cannot be viewed by clients [11]. In addition, PHP can send HTTP headers, set cookies, manage authentication and redirect users. It offers excellent connectivity to many databases such as Microsoft Access through ODBC and integration with various external libraries that let you do everything from generating PDF documents to parsing XML [12]. 2.1.2 Java Script Java Script is a scripting language developed by Netscape to enable Web designers to create interactive websites. Despite the name, Java Script is unrelated to the Java programming language even though the two of them have superficial similarities; Java Script was developed independently. Both these languages use syntaxes influenced by that of C syntax, and Java Script copies many Java names and naming conventions. It can interact with HTML enabling Web designers to make their websites more interactive with dynamic content [13]. Akila Wajirakumara Page 10
2.2 XAMPP XAMPP is an easy to install Apache distribution that contains MySQL, PHP and Pearl [4]. Apache is a freely available web server that is distributed under an open source license and XAMPP is a free open source cross-platform web server package. It is used as a web development tool to allow web designers and programmers to test their work on their own computers without any access to the Internet [5]. In this project, we use XAMPP to test our website in PHP before it is hosted on the World Wide Web. 2.3 Adobe Dreamweaver Adobe Dreamweaver is an industry standard website authoring program created by Macromedia and now developed by Adobe Systems. It enables users to create fullyfunctional websites using both programming code and design view where the user is able to see the layout of the page. In this project I used Adobe Dreamweaver to do my PHP coding. 2.4 ODBC Open Database Connectivity (ODBC) refers to a software API (Application Programming Interface) for using Database Management Systems (DBMS). ODBC is created to be independent of programming languages or operating systems and offers access to different database systems [6] via SQL queries. It can be used as an access tool to various databases such as Microsoft Access, Microsoft Excel, Text and dbase. Through these Call Level Interface (CLI) specifications of the SQL Access group, ODBC allows a neutral way if accessing the data stored in personal computers and various databases [7]. ODBC allows us to grab information from our Microsoft Access Databases and insert them into our PHP codes to be viewed in our website. 2.5 SMS Engine SMS Engine is a part of the SMS Gateway Development Kit (SMS GDK) which is given free when the GSM modem was purchased. With SMS Engine, the System Integrator and Software Developer (SI/SD) does not need to write any code to write an SMS Gateway. It will read and send SMS, with the use of a Microsoft Access database it will store the incoming SMS and also check if there is any pending SMS to be sent. The SI/SD only needs to insert record into the database to send the SMS and receive record from the database to read the SMS. The SMS Engine takes care of all the SMS transactions in this project. Akila Wajirakumara Page 11
2.6 IntelliTrac X1 Wizard The IntelliTrac X1 Wizard is the software used to program the X1 to send SMS of the coordinates of the vehicle s location at specified intervals to the GSM modem (Q24). It records the latitude, longitude, satellite strength, timestamp, heading, altitude, ReportID, input and output at the specific location, coverts and compresses into an SMS and sends it. The IntelliTrac X1 Wizard enables you to program the X1 to send SMS at different time or distance intervals depending on the user s needs. 2.7 No-IP No-IP is a Dynamic DNS (Domain Name Service) provider for free services. Dynamic DNS is a technology that allows the user to update the IP address of a domain in real time. It is capable of notifying a domain name server to change for networked devices such as routers or computer systems using the Internet Protocol Suite. The active DNS configuration of its configured hostnames, addresses or other information are stored in DNS in real time. A popular Dynamic DNS application is that it provides a residential user s Internet gateway that has a variable often changing IP address with a well known hostname resolvable by network applications through standard DNS queries [8]. No-IP s Dynamic DNS applications allow the user to remotely connect to their computer from work and also run a personal website. Once signed up to the No-IP free service at http://www.no-ip.com, it allows the user to create a domain to use instead of a hard to remember IP address or URL. Additionally it also uses a dynamic update client to keep track of the user s dynamic IP address. Hence the user will always be able to get to their computer even if the user s IP address is dynamically assigned [9]. In this project No-IP is used to host the PHP pages and the real time updating Microsoft Access databases in the control center into the World Wide Web. 2.8 Google Maps API Google Maps is a free web mapping service application and technology provided by Google that powers many map-based Google Maps website, Google Ride Finder and embedded maps on third party websites via Google Maps API (Application Programming Interface). An API (Application Programming Interface) is a set of routines and/or protocols provided by libraries and/or operating system services in order to support the building of the applications. Google Maps offers street maps, a route planner, and an urban business locator for numerous countries worldwide. Google Earth is a stand-alone program for Microsoft Windows and other Operating Systems which is more sophisticated and offers more globe-viewing features. Google created the Google Maps API to facilitate web developers to integrate Google Maps into their websites with their own data points. It embeds Google Maps into your website with Java Script and is currently free of charge. The Google Maps API provides a vast number of utilities for manipulating maps, just like in the Google Maps website http://maps.google.com and adds content to the map through a variety of services. In order to use the Google Maps API, you first need to sign up for an API key on http://code.google.com/apis/maps/signup.html which will then allow you to develop the map application on your website [1][10]. Akila Wajirakumara Page 12
Chapter 3: Getting Started This chapter covers all the important steps that have to be carried out in order to start designing the PHP website. The steps are as follows. Step 1: Create a Microsoft Access Database Step 2: Configure and Test the SMS Engine Software Step 3: Configure the ODBC Step 4: Install, Test and Configure the IntelliTrac X1 Step 5: Adding the Google Maps API Akila Wajirakumara Page 13
3.1 Step 1: Create a Microsoft Access Database A main Microsoft Access database is created which contains all the information of all the drivers and also a log that contains all the coordinates sent by the IntelliTrac X1 at different times. The database has two tables, namely the GPS_modem table which contains information of all the vehicles that has the X1 device, and the vehicle_log table that contains a log of all the coordinates sent by the X1. We shall start off by entering fake details before connecting the GPS + GSM modem and the GSM modem. The fields in the GPS_modem table are modem_id, vehicle_no, date_created, vehicle_type, vehicle_desc and #number. Figure 3 - Table containing all the information of the drivers in the database Akila Wajirakumara Page 14
The fields in the vehicle_log table are modem_id, longitude, latitude, satellite_strength, timestamp, speed, Heading, Altitude, ReportID, Input an Output. Figure 4 - Vehicle log of all the drivers in the database Akila Wajirakumara Page 15
3.2 Step 2: Configure and Test the SMS Engine Software The Q24 GSM modem is now connected to the control center and the SMS Engine software is installed. Firstly it is configured to our requirements and the SIM card number is entered. SIM Setting SIM Card no: also known as MSISDN PIN: to unlock SIM operator depending on the number Modem COM: Enter the port number which the GSM Modem is connected to the PC Poll: Set how frequent the SMS Engine should access the database. If you set it to 3 seconds, then the SMS Engine will read incoming SMS, store into Inbox and query the Outbox to send out SMS in every 3 seconds. Delivery Status Report: If checked, SMS Engine will check for the report for each outgoing SMS. Routing: Check All to instruct SMS Engine to send SMS to all mobile numbers or checked the appropriate box to instruct SMS Engine to send out SMS selective numbers only. If you set to Maxis (012), then the SMS Engine will only send SMS to mobile numbers starting with 012 only. [1] Figure 5 - Configuring SMS Engine Direction: Set the GSM modem to 2 way, 1 way read only, or 1 way send only. If you set it to 1 way read, the SMS Engine will only read incoming SMS and will not send out. Akila Wajirakumara Page 16
The settings are then saved and then the connection is established by clicking the Start button. Incoming Message will increase one if the SMS Engine receive a message Sent Message will increase one if the SMS Engine sent out a message Figure 6 - Starting SMS Engine Fail Message will increase one if the SMS Engine fail to sent out a message [1] Akila Wajirakumara Page 17
All the received SMS is automatically saved in a Microsoft Access Database in the same folder as the SMS Engine software is installed in the hard disk. Figure 7 - SMS Engine Database The SMS Engine can be tested by sending it an SMS from a mobile phone. The SMS should be displayed in the SMS Engine window as well as in the Inbox table in the database. Akila Wajirakumara Page 18
3.3 Step 3: Configure the ODBC The ODBC has to be configured in order to connect both our databases to our PHP code. Setting up an ODBC connection is very simple; the steps are as follows. Go to Control Panel, click on Administrative Tools and then click on the Data Sources (ODBC) icon. Open the System DSN tab and click the Add button. The following window will open. Figure 8 - ODBC Create Data Source Select Microsoft Access Driver (*.mdb,*.accdb) and click the Finish button. Figure 9 - ODBC Microsoft Access Setup Akila Wajirakumara Page 19
For the main database type X1 under Data Source Name, then click the Select button and browse to the location of the database and click OK. Repeat the same procedure for the SMS Engine database; name it SMS Engine. After completed, click the OK button. [1] Figure 10 - ODBC Data Source Administrator Akila Wajirakumara Page 20
3.4 Step 4: Install, Test and Configure the IntelliTrac X1 3.4.1 Installing the IntelliTrac X1 GSM Antenna Input/Output Cable RS 232 Cable GPS Receiver Figure 11 - Installing the IntelliTrac X1 Akila Wajirakumara Page 21
3.4.2 Testing the IntelliTrac X1 In order to test and configure the IntelliTrac X1, the Hyper Terminal program is setup to which the appropriate COM Port is selected which connects the X1 by the RS-232 cable; in my case it is COM6. The parameters of the Port Settings are then setup as follows Bits per second: 57600bps Data bits: 8 Parity: None Stop bits: 1 Flow control: None Figure 12 - Setting parameters for Port Settings in Hyper Terminal Next, click on Properties on the toolbar menu, select the Settings tab and click the ASCII Setup button. Check on the boxes Send line ends with line feeds and Echo typed characters locally and then click OK. Akila Wajirakumara Page 22
Back to the main screen, please type the $ST then press [Enter], if the communication has established correctly, the unit should return the message $ER: =0 as follows. Figure 13 - Test Output for X1 on Hyper Terminal If there is no response from the IntelliTrac X1, please check with the serial port connection. [2] 3.4.3 Configuring the IntelliTrac X1 Wizard Open the IntelliTrac X1 wizard; select the appropriate COM Port and the default Baud Rate to 57600bps. The incorrect will lead to unavailable communication between the X1 device and the X1 Wizard. Figure 14 - COM Port Setting in X1 Wizard Turn ON the power in the IntelliTrac X1 and in order to make the connection between the device and the X1 wizard, select Tool in the menu bar and click on Reboot. It then prompts a password, enter the default password 0000 and click OK. Akila Wajirakumara Page 23
Figure 15 - Enter Unit Password to Reboot in X1 Wizard Figure 16 - Reboot Complete in X1 Wizard Once it has completed rebooting, next click on the Communication icon on the left and enter the following settings. Primary communication type: SMS SMS base phone number: Enter the phone number of the GSM modem (Q24) CSD base phone number: Enter the phone number of the GPS + GSM modem (X1) Figure 17 - Communications Setting in X1 Wizard Go to File and save it so that this procedure does not have to be carried out the next the X1 wizard is opened. Akila Wajirakumara Page 24
Next go to Track, select the Start Function button configure the X1 to send SMS to any specified interval according to your personal requirements. Figure 18 - Configuring the X1 to Track using X1 Wizard. Click on Backup Battery on the left and select Turn ON backup battery. This procedure can be skipped if there is an alternate method of supplying power to the IntelliTrac X1. Once all this is done it is now ready to upload all this information to the device. Select Tool from the menu bar and click on Upload. Figure 19 - Uploading data into the X1 using X1 Wizard Remove the Serial cable and the power cable; and the X1 is ready to be taken for a drive. [3] 3.5 Step 5: Adding the Google Maps API Akila Wajirakumara Page 25
In Order to use the Google Maps API, we need to sign up for the API Key which is found in the website http://code.google.com/apis/maps/signup.html Figure 20 Signing up for the Google Maps API Key After accepting the terms and conditions and entering the URL, the Key will be automatically generated in the next page. Google Maps API Key Figure 21 Google Maps API Key We are now ready to add the Google Maps API into our website. Akila Wajirakumara Page 26
Chapter 4: Creating the Online Vehicle Tracking System Before the web pages are designed, there is a function that has to be included in the beginning of every page. This is the function that updates the main database. Whenever the X1 sends and SMS to the Q24, the message is automatically saved into the SMS Engine database as a string. Using PHP, this message is broken down into ten different fields namely longitude, latitude, timestamp, speed, satellite strength, heading, altitude, ReportID, input and output. The database is updated with the use of the timestamp. The timestamp the GPS modem gets from the satellite is 8 hours behind. This problem is rectified using PHP coding and the new timestamp is being updated. In order to update the main database, this new timestamp is converted to seconds. This is done my using a simple algorithm where the timestamp is in the format yyyy-mm-dd H:m:s. Timestamp in seconds = s + (m*60) + (H*60*60) + (dd*24*60*60) + (mm*30*24*60*60) + (yyyy*365*24*60*60) This calculation is also done using PHP. Next the latest timestamp in the vehicle_log table in the main database is found and is also converted to seconds. The maximum timestamp in seconds in the main database is then compared with the timestamps in seconds in the SMS Engine. A PHP function is created to update the main database if the received phone number in the SMS Engine database matches with the phone numbers in the main database and only if the timestamps in seconds in the SMS Engine database are greater than the maximum timestamp in seconds in the main database. This function is included in every page in the website. The Online Vehicle Tracking System website consists of four pages excluding the index page. 1. View Information of all the Vehicles Page 2. Locate and Track Vehicle's last position Page 3. Find Closest Vehicle to your location Page 4. View Complete Vehicle Log Page Akila Wajirakumara Page 27
4.1 View Information of all the Vehicles Page This page contains a table of the information of all the drivers that has the IntelliTrac X1. This is taken from the GPS_modem table in the main database through ODBC. Figure 22 GPS Modem Table Web Page In this page it not only shows the table, it also has links on the Vehicle Number to connect to the page that shows the particular vehicle s complete log and also tracks down its five latest position on the map. Akila Wajirakumara Page 28
4.2 Locate and Track the Vehicle s last position Page In this page, the user is prompted to enter their Vehicle Number. Once the Vehicle Number is submitted, it will display a table containing the log of the particular and also a map with markers added to the five latest positions. Figure 23 Vehicle Query page prompts Vehicle number Figure 24 Vehicle Query page showing the Vehicle s log Akila Wajirakumara Page 29
Figure 25 Vehicle Query page showing the map The balloon shaped marker is the vehicle s latest position and the crossed markers are the next four positions. The blue lines connecting the markers are called polylines which allows the user to understand the vehicle s route more clearly. Akila Wajirakumara Page 30
4.3 Find Closest Vehicle to your Location Page This page allows the user to key in their desired latitude and longitude and the time period in hours. Once this information is submitted, it will automatically calculate that distance of the closest vehicle to the location entered along with its timestamp. It also shows the position of the vehicle in the map. Figure 26 Find closest Vehicle Page prompting user to enter location Figure 27 Find closest Vehicle Page Map Akila Wajirakumara Page 31
When the submit button is clicked after the data is entered, it first creates a table of each car s latest timestamp using an SQL statement in the PHP code and calculates the distance between the coordinates and that on the table for each car. These timestamps in the table are converted to seconds in the same manner explained earlier in the thesis. The current timestamp is created and it is also converted to seconds. The number of hours entered by the users is then converted to seconds and is then deducted from the current timestamp in seconds. A while loop is created which will then eliminate the information of the vehicles in the table whose timestamp is less than the value calculated earlier. From the vehicles that are left in the table, the one with the least distance is chosen and displayed on the map. 4.4 View Complete Vehicle Log Page This page contains a table of all the GPS data received from all the vehicles that has the IntelliTrac X1. This is taken from the vehicle_log table in the main database through ODBC. Figure 28 Vehicle Log Page Akila Wajirakumara Page 32
Chapter 5: Conclusion All the deliverables and objectives were completed. The GPS + GSM modem was configured, tested and implemented to track the vehicle s location and displayed on a map with the aid of Google Maps API in the online Vehicle Tacking Report. The IntelliTrac X1 can function as a standalone system once the embedded application is transferred into it. The Q24 can successfully receive all the GPS data sent by the IntelliTrac through without any delay provided there is GSM connectivity in the location of the two parties, the GPS + GSM modem and the GSM modem. The control center can automatically update the main database each time GPS data is received. The online Vehicle Tracking System is able to locate, track and calculate the distance of the closest vehicle available to a desired location at any period of time. These equipments and data can only help to a certain extent because practical comprehension is more challenging and requires greater analysis with comparison to hypothetical understandings. This project has vastly broadened my knowledge about the theory of GPS and also improved my programming skills in PHP. During the course of completing the project, there were many expediency issues which were added to ensure that the product realization is complete, robust and usable for commercialization of this system. 5.1 Important features of this project 1. GPS + GSM modem can send GPS data to the GSM modem via SMS at user desired intervals of time and/or distance. 2. Ability to track a vehicle s last five positions and displayed on a map with different markers clearly distinguishing their time and location. 3. Polylines on the map when tracking a vehicle. Polylines are imaginary lines connecting the five latest positions in order of time giving a higher approximation of the vehicle s route. 4. Finding and calculating the distance of the nearest vehicle to a specific location entered by the user at given period of time. Akila Wajirakumara Page 33
5.2 Practical Implementations The Online Vehicle Tracking System can be used in many places like buses, taxis and other transporting companies. The following are a few scenarios where the Vehicle Tracking System can be really helpful. Fleet Management: When managing a fleet of vehicles, with the ability of finding the real-time location of all drivers would allow the management to meet the customer need in a more effective manner. Drivers would only need an internet connection to track and dispatch the vehicle e.g. Boss said, "I want to know which lorry is closest to the pick-up point so that I can call that nearest lorry to pick-up the goods. Asset Tracking: If a company needs to track valuable assets for monitoring and other purposes, it could closely monitor its movement and status on the map. Field Service Management: Companies with a service workforce for services must be able to plan the workers time, scheduled subsequent customer visits and be able to operate efficiently. With vehicle tracking, it allows the companies to quickly locate a field engineer and dispatch the closest one to meet a new customer request. 5.3 Future Development The potential of this project can be further explores and improved to its functionality and features. The GSM can also send SMS, but this hasn t been used in this project. This can open doors to lot improvements for the Vehicle Tracking System in the commercial world. A program can be made where an SMS can be sent from the control center to driver s mobile phone giving him the location of his next destination. An Immobilizer could be connected to the X1 which can be programmed to function through SMS where the control center could trigger the immobilizer if the driver is violating orders such as speeding or going out of track. The IntelliTrac X1 has an RF (Radio Frequency) reader output which can be implemented in a school bus for example. In this case, each student would have their own RFID cards and once a student enters the bus the student s details can be recorded along with the GPS location when the student entered and left. The control center can monitor the student s attendance and where they entered and left the bus. Akila Wajirakumara Page 34
References [1] Vehicle Tracking System Guide provided by MOBITEK Sdn Bhd. [2] IntelliTrac X1 Installation Guide provided by MOBITEK Sdn Bhd. [3] X1 Wizard User Manual provided by MOBITEK Sdn Bhd. [4] http://www.apachefriends.org/en/xampp.html [5] http://en.wikipedia.org/wiki/xampp#use [6] http://www.ntchosting.com/postgresql/odbc-jdbc-with-php-perl-and-python.html [7] http://www.tech-faq.com/odbc.shtml [8] http://en.wikipedia.org/wiki/dynamic_dns [9] http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html [10] http://www.google.com/enterprise/maps/ [11] http://www.webopedia.com/term/p/php.html [12] http://articles.techrepublic.com.com/5100-22_11-5074693.html [13] http://www.webopedia.com/term/j/javascript.html Akila Wajirakumara Page 35
Appendix Codes Google Maps codes to Locate and Track Vehicle <html> <head><title>find Closest Vehicle</title> <script src="http://maps.google.com/maps?file=api&v=2& key=abqiaaaariochz5ghxw6nsrm8tsdcxqjp_kvici9jgaasy-ka4tp3s-s4rq9vv829aiek0cyi6jqspbuxhkpsq" type="text/javascript"></script> <script type="text/javascript"> var UnitID="<?php echo $vehicleid;?>"; var datetime="<?php echo $fts;?>"; var lat="<?php echo $flat;?>"; var long="<?php echo $flng;?>"; var datetime1="<?php echo $fts1;?>"; var lat1="<?php echo $flat1;?>"; var long1="<?php echo $flng1;?>"; var datetime2="<?php echo $fts2;?>"; var lat2="<?php echo $flat2;?>"; var long2="<?php echo $flng2;?>"; var datetime3="<?php echo $fts3;?>"; var lat3="<?php echo $flat3;?>"; var long3="<?php echo $flng3;?>"; var datetime4="<?php echo $fts4;?>"; var lat4="<?php echo $flat4;?>"; var long4="<?php echo $flng4;?>"; function loadearth() if (GBrowserIsCompatible()) var point; var cicon = new GIcon(); cicon.image = 'cross.png'; Akila Wajirakumara Page 36
cicon.iconsize = new GSize(25,25); cicon.iconanchor = new GPoint(16,11); var map=new GMap2(document.getElementById("map")); map.addcontrol(new GOverviewMapControl()); map.enabledoubleclickzoom(); map.enablescrollwheelzoom(); map.addcontrol(new GMapTypeControl()); map.addcontrol(new GSmallMapControl()); var marker = new GMarker(new GLatLng(lat,long)); var marker1 = new GMarker(new GLatLng(lat1,long1),cIcon); var marker2 = new GMarker(new GLatLng(lat2,long2),cIcon); var marker3 = new GMarker(new GLatLng(lat3,long3),cIcon); var marker4 = new GMarker(new GLatLng(lat4,long4),cIcon); map.setcenter(new GLatLng(lat,long),17); GEvent.addListener(marker, "click", function() map.openinfowindowhtml(map.getcenter(),("vehicle No: <b>" + UnitID + "</b>" + "<br>datetime: <b>" + datetime + "</b>" + "<br>longitude:<b>" + long + "</b>" + "<br>latitude:<b>" + lat + "</b>")); ); GEvent.addListener(marker1, "click", function() map.openinfowindowhtml(map.getcenter(),("vehicle No: <b>" + UnitID + "</b>" + "<br>datetime: <b>" + datetime1 + "</b>" + "<br>longitude:<b>" + long1 + "</b>" + "<br>latitude:<b>" + lat1 + "</b>")); ); GEvent.addListener(marker2, "click", function() map.openinfowindowhtml(map.getcenter(),("vehicle No: <b>" + UnitID + "</b>" + "<br>datetime: <b>" + datetime2 + "</b>" + "<br>longitude:<b>" + long2 + "</b>" + "<br>latitude:<b>" + lat2 + "</b>")); ); GEvent.addListener(marker3, "click", function() map.openinfowindowhtml(map.getcenter(),("vehicle No: <b>" + UnitID + "</b>" + "<br>datetime: <b>" + datetime3 + "</b>" + "<br>longitude:<b>" + long3 + "</b>" + "<br>latitude:<b>" + lat3 + "</b>")); ); GEvent.addListener(marker4, "click", function() map.openinfowindowhtml(map.getcenter(),("vehicle No: <b>" + UnitID + "</b>" + "<br>datetime: <b>" + datetime4 + "</b>" + "<br>longitude:<b>" + long4 + "</b>" + "<br>latitude:<b>" + lat4 + "</b>")); ); Akila Wajirakumara Page 37
map.addoverlay(marker); map.addoverlay(marker1); map.addoverlay(marker2); map.addoverlay(marker3); map.addoverlay(marker4); map.setcenter(new GLatLng(lat,long), 16); map.setmaptype(g_satellite_map); var polyline = new GPolyline([ new GLatLng(lat, long), new GLatLng(lat1, long1), new GLatLng( lat2, long2), new GLatLng(lat3, long3), new GLatLng(lat4, long4) ], "#3333cc", 10); map.addoverlay(polyline); </script> </head> <?php if($showmap) echo "<body onload='loadearth()' onunload='gunload()' >"; echo "<div id='map' style='margin: 2px auto; width: 650px; height: 400px'></div>";?> </body> </html> Akila Wajirakumara Page 38
Functions for Updating the Main Database <?php function gps_timestamp_to_second($gpst) $gpsyr = substr($gpst, 0, 4); $gpsmnth= substr($gpst, 4, 2); $gpsday = substr($gpst, 6, 2); $gpshr = substr($gpst, 8, 2); $gpsmin = substr($gpst, 10, 2); $gpssec = substr($gpst, 12, 2); $gpshr = $gpshr + 8; if ($gpshr<10) $gpshr = "0$gpshr"; else if ($gpshr>=24) $gpshr = $gpshr - 24; if ($gpshr<10) $gpshr = "0$gpshr"; switch ($gpsmnth) case "01": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) Akila Wajirakumara Page 39
else if ($gpsday==31) $gpsmnth = "02"; $gpsday = "01"; break; case "02": if ($gpsyr%4 ==0) if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<29) else if ($gpsday==29) $gpsmnth = "03"; $gpsday = "01"; else if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<28) Akila Wajirakumara Page 40
else if ($gpsday==28) $gpsmnth = "03"; $gpsday = "01"; break; case "03": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "04"; $gpsday = "01"; break; case "04": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) Akila Wajirakumara Page 41
else if ($gpsday==30) $gpsmnth = "05"; $gpsday = "01"; break; case "05": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "06"; $gpsday = "01"; break; case "06": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) Akila Wajirakumara Page 42
$gpsmnth = "07"; $gpsday = "01"; break; case "07": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "08"; $gpsday = "01"; break; case "08": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "09"; Akila Wajirakumara Page 43
$gpsday = "01"; break; case "09": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "10"; $gpsday = "01"; break; case "10": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "11"; $gpsday = "01"; Akila Wajirakumara Page 44
break; case "11": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "12"; $gpsday = "01"; break; case "12": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "01"; $gpsday = "01"; $gpsyr = $gpsyr + 1; break; Akila Wajirakumara Page 45
else $gpshr = $gpshr; $gpsts = "$gpsyr-$gpsmnth-$gpsday $gpshr:$gpsmin:$gpssec"; $gpstss = $gpssec + ($gpsmin * 60) + ($gpshr * 60 * 60) + ($gpsday * 24 * 60 * 60) + ($gpsmnth * 30 * 24 * 60 * 60) + ($gpsyr * 365 * 24 * 60 * 60); return $gpstss; function gps_to_timestamp($gpst) $gpsyr = substr($gpst, 0, 4); $gpsmnth= substr($gpst, 4, 2); $gpsday = substr($gpst, 6, 2); $gpshr = substr($gpst, 8, 2); $gpsmin = substr($gpst, 10, 2); $gpssec = substr($gpst, 12, 2); $gpshr = $gpshr + 8; if ($gpshr<10) $gpshr = "0$gpshr"; else if ($gpshr>=24) $gpshr = $gpshr - 24; if ($gpshr<10) $gpshr = "0$gpshr"; switch ($gpsmnth) case "01": if ($gpsday<9) Akila Wajirakumara Page 46
$gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "02"; $gpsday = "01"; break; case "02": if ($gpsyr%4 ==0) if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<29) else if ($gpsday==29) $gpsmnth = "03"; $gpsday = "01"; else Akila Wajirakumara Page 47
if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<28) else if ($gpsday==28) $gpsmnth = "03"; $gpsday = "01"; break; case "03": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "04"; $gpsday = "01"; break; case "04": if ($gpsday<9) Akila Wajirakumara Page 48
$gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "05"; $gpsday = "01"; break; case "05": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "06"; $gpsday = "01"; break; case "06": if ($gpsday<9) Akila Wajirakumara Page 49
$gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "07"; $gpsday = "01"; break; case "07": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "08"; $gpsday = "01"; break; case "08": if ($gpsday<9) $gpsday = "0$gpsday"; Akila Wajirakumara Page 50
else if ($gpsday>9 && $gpsday<31) else if ($gpsday==31) $gpsmnth = "09"; $gpsday = "01"; break; case "09": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "10"; $gpsday = "01"; break; case "10": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) Akila Wajirakumara Page 51
else if ($gpsday==31) $gpsmnth = "11"; $gpsday = "01"; break; case "11": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<30) else if ($gpsday==30) $gpsmnth = "12"; $gpsday = "01"; break; case "12": if ($gpsday<9) $gpsday = "0$gpsday"; else if ($gpsday>9 && $gpsday<31) Akila Wajirakumara Page 52
else if ($gpsday==31) $gpsmnth = "01"; $gpsday = "01"; $gpsyr = $gpsyr + 1; break; else $gpshr = $gpshr; $gpsts = "$gpsyr-$gpsmnth-$gpsday $gpshr:$gpsmin:$gpssec"; return $gpsts; function timestamp_to_second($ts) $yyyy= substr($ts, 0, 4); $mm= substr($ts, 5, 2); $dd= substr($ts, 8,2); $hr= substr($ts, 11, 2); $min= substr($ts, 14,2); $sec= substr($ts,17, 2); $tss = $sec + ($min * 60) + ($hr * 60 * 60) + ($dd * 24 * 60 * 60) + ($mm * 30 * 24 * 60 * 60) + ($yyyy * 365 * 24 * 60 * 60); return $tss; function add_log_entry($modem_id,$longitude,$latitude,$sattelite_str,$timestamp,$speed,$heading,$altitude, $report_id,$input,$output) $query = "INSERT INTO vehicle_log(modem_id,longitude,latitude,sattelite_strength,[timestamp],speed,heading,altitude,rep ortid,input,output) values Akila Wajirakumara Page 53
('$modem_id','$longitude','$latitude','$sattelite_str','$timestamp','$speed','$heading','$altitud e','$report_id','$input','$output')"; $dbc = odbc_connect("x1","",""); // Trying to establish connection with database if (!$dbc) exit("connection failed:".$dbc); $rs = odbc_exec($dbc,$query); odbc_close($dbc); function get_modem_id_for_number($number) $query = "SELECT modem_id FROM GPS_modem WHERE `#number` = '$number'"; $dbc = odbc_connect("x1","",""); // Trying to establish connection with database if (!$dbc) exit("connection failed:".$dbc); $rs = odbc_exec($dbc,$query); if (!$rs) exit("error in SQL. ".$rs); $result = odbc_result($rs,1); return $result; odbc_close($dbc); function get_latest_timestamp_in_db() $dbc = odbc_connect("x1","",""); // Trying to establish connection with database if (!$dbc) exit("connection failed:".$dbc); Akila Wajirakumara Page 54
$query = "SELECT TOP 1 timestamp FROM vehicle_log order by timestamp desc"; Statement // SQL $rs = odbc_exec($dbc,$query); if (!$rs) exit("error in SQL. ".$rs); while (odbc_fetch_row($rs)) $ts = odbc_result($rs, "timestamp"); $yyyy= substr($ts, 0, 4); $mm= substr($ts, 5, 2); $dd= substr($ts, 8,2); $hr= substr($ts, 11, 2); $min= substr($ts, 14,2); $sec= substr($ts,17, 2); $tss = $sec + ($min * 60) + ($hr * 60 * 60) + ($dd * 24 * 60 * 60) + ($mm * 30 * 24 * 60 * 60) + ($yyyy * 365 * 24 * 60 * 60); return $tss; odbc_close($dbc); function get_message_and_number() $dbc = odbc_connect("smsengine","",""); // Trying to establish connection with database if (!$dbc) exit("connection failed:".$dbc); $query = "SELECT message,mobile FROMInbox"; $rs = odbc_exec($dbc,$query); $i=1; while (odbc_fetch_row($rs)) $message = odbc_result($rs, "Message"); Akila Wajirakumara Page 55
$mobile = odbc_result($rs, "Mobile"); $message_exploded = explode(',',$message); for($j=0;$j<=11;$j++) $message_number[$i][$j] = $message_exploded[$j]; $message_number[$i][12]=$mobile; $i++; return $message_number; odbc_close($dbc); function update_main_db() $latest_time_stamp_in_db = get_latest_timestamp_in_db(); $message_number = get_message_and_number(); for($i=1;$i<=count($message_number);$i++) $id = get_modem_id_for_number($message_number[$i][12]); if(!empty($id)) $gps_timestamp_to_sec = gps_timestamp_to_second($message_number[$i][1]); if($gps_timestamp_to_sec>$latest_time_stamp_in_db) //part where the copying will happen $gps_to_timestamp = gps_to_timestamp($message_number[$i][1]); add_log_entry($id,$message_number[$i][2],$message_number[$i][3],$message_number[$i][7],$gps_to_ti mestamp,$message_number[$i][4],$message_number[$i][5],$message_number[$i][6],$message_number[$i][ 8],$message_number[$i][9],$message_number[$i][10]);?> Akila Wajirakumara Page 56