GPS Vehicle Tracking System
This article mainly focuses on the idea and logic behind GPS Vehicle Tracking System with remote monitoring and security access using mobile phone. The GPS-GSM module is interfaced using a single microcontroller and the real-time GPS location of the system is inquired using SMS feature. The system is designed to operate only by the registered users. There is an option to add or remove the users in real-time.
How does Car Tracking System Work?
The GSM Module is used to manually interface with the system, through the SMS feature. To know the GPS location of the object, the user has to send an SMS to the system with a predefined template. The system will read the message and acquires the GPS location instantaneously. Then after, the system sends an SMS to the user with the GPS data i.e. Latitude and Longitude as a message. Thus, an object or a system is traced.
How Vehicle Tracking System Works?
To track a vehicle, a continuous stream of data is required. So, by sending an SMS to the car with a tracking template, the system will continuously update the GPS location of the object through SMS, until a stop indication is sent. The update frequency is sent along with the tracking template. This frequency is in terms of minutes, i.e. for example if the frequency mentioned is 5 then the system will update the data (sends SMS) after every 5 minutes. This value ranges from 1 to 10 and this can be varied to desired range in the program.
Is the GPS Based Vehicle Tracking System Secure?
Yes, the system is secured. The system will respond positively, only to the messages received from the authorised contact numbers. The system is built with user verification feature that filters the unauthorised contact numbers, making the system secured. So, even if anyone gets the contact number of the system, they cannot communicate with their mobile phones until you authorise their contact numbers.
Is it possible to add a new contact number in real-time?
Yes, the system is designed to add new users (contact numbers) in real-time. Also, the authorised users can be deleted. Through the respective message templates, new contact numbers can be added and the existing contact numbers can be deleted from the memory. All these contact numbers are stored in the EEPROM of the microcontroller (Choose a microcontroller that contains inbuilt EEPROM).
Adding a New User
In order to add a new user, a registered user has to send 3 as a message to the system and the system will send a template to add a user. The template is as below,
Add User (User Name) (10-Digit Number)
Edit the User name up to 10 letters Edit the 10-Digit mobile number and send
The braces should not be removed because they are used as identifiers in the program code. The new user details will be updated in the EEPROM also.
Removing a User
In order to remove a user from the system, a registered user has to send 4 as a message to the system and the system will send a template to remove a user. The template is as below,
Users List 1. User1 1234567890 2. User2 0123456789 To remove user#1 reply RU1
By sending RU1 user number 1 will be removed from the system permanently. If there is only one user in the list, the system does not accept the request to remove the user, as the system cannot be operated then after. However, it is better to program a contact number of a user within the program code.
Similarly, there are options to know the account balance and to clear the message counter which is useful if an SMS plan is used.
How Many UART Ports Should the Microcontroller Possess?
Only one UART port is sufficient. As the system uses two Modules namely the GSM and the GPS, which are by default interfaced through UART ports provided on each module, two UART ports are required in the microcontroller. But, by using an AND, OR logic gates based input selector circuit, both the modules can be interfaced using one UART port of the microcontroller.
The system should monitor the real-time requests from the user through the GSM module. So, by default the microcontroller maintains the connection with the GSM module i.e. the GSM module will be the UART terminal to the microcontroller and whenever the GPS data is required, the microcontroller selects the GPS module as the UART terminal through the logic circuit.
Alternatively, the modules like SIM908 have both the GSM and the GPS features. The module has an option to connect a GPS antenna. By using modules of this type, the logic circuit can be eliminated. Both the GSM and GPS data can be processed using the GSM port, even though separate ports are provided.
The Program Code
Vehicle Tracking System Using GPS and GSM – Download Program
The program is developed using C-language using Programmerâ€™s notepad of â€˜Winavrâ€™ software. Here, the microcontroller used is ATMEGA 32 but, it can be easily modified for any other microcontroller having sufficient peripherals.
Initialization of GPS-GSM Modules
The GSM Module has to send and receive SMS and the GPS Module has to provide GPS location information. For this purpose, two start-up functions are used. These functions are called after the Power ON/Reset of the microcontroller. Below is the code for the start-ups along with their operation.
Receiving and Processing the UART Data
The data sent by the modules is received by the UART Port of the microcontroller and the timer/counter is initialized after receiving each byte. When there is a significant time gap after receiving a byte, an interrupt is generated by the Timer/Counter indicating the end of RX Data. Now the received data is processed through a function which is defined as,
This function analyses the received data to perform a specific action. The first few bytes of the received data are verified with some possible options and if a match occurs, then the respective action is performed. Below is the keyword verification part and the complete code is provided at the end of the article.
Verifying the User
The SMS received contains the sender details like the â€˜Contact nameâ€™ and the â€˜Contact numberâ€™. This contact number is compared with the registered users and if a match is found, then the sender is confirmed as a valid user and the message is processed. Otherwise, the system sends a notification about the invalidation. Below is the code to verify the user,
The GPS data is obtained from the GPS module through specific AT commands. For SIM 908 module the GPS location can be obtained using the command:
â€˜2â€™ in the command is to request the GPS Data in the GGA protocol.
The response for this command is as shown below.
If separate GSM and GPS modules are used, after selecting the GPS module, wait for GGA to be received and then get the Latitude and Longitude details. As the aim of the project is to find the GPS location of the system, only Latitude and Longitude details are enquired. However, by selecting different protocols, the various parameters provided by the GPS receiver can be obtained. These commands are available in the datasheets of the respective module you are using.
Tracing & Tracking
In order to trace the system, the user has to send T as a message to the system and the system will reply the GPS location. The GPS location is sent to the requested user as:
Latitude: 1234.123456N Longitude: 12.123456E
In order to track the system, the user has to send T<min> to get the GPS location every specified number of minutes i.e. send T1 to receive the GPS data for every 1 minute. For this purpose, a 16-Bit timer/counter is utilized. The timer set to run in Clear Timer On Compare Match and the Compare Match Registers are loaded with a value equivalent to 1 second time interval. Thus for every second, an interrupt is generated and seconds variable is incremented. When the â€˜secondsâ€™ count equals to 60, the â€˜minuteâ€™ variable is incremented and this value is compared with the update frequency in tracking template sent by the user. If a match is found again GPS data is requested and an SMS is sent to the user.
Remember that, only one user can track the system at a time until tracking is stopped by the requested user or other users. In order to stop tracking, any of the users can send S as a message and the tracking will be stopped. The program code for tracking is shown below,
The link to winavr software is provided below,