Vehicle Tracking Systems are a necessity of today’s commuters. Such systems are essential to keep personal vehicles safe from theft and robberies. The Vehicle Tracking Systems are possible to design only by empowering them with internet. In this project, a simple vehicle tracking system is designed which will keep updating the current location of the vehicle to a custom designed webpage.
The vehicle tracking systems are designed for tracking the movement of a vehicle from a location at any time. Such system is equipped with a GPS receiver which maintains the GPS location of the device. The GPS location of the device traced by the GPS sensor is sent to a cloud server or cloud service with the help of a controller. This project is a simple implementation of such system on one of the most popular prototyping boards – Arduino UNO.
It is assumed that the reader has gone through the project how to get started with the arduino and Interface LCD with arduino.The vehicle tracking device designed here is an IoT device. It has Arduino interfaced with Neo-6M GPS module, a character LCD and ESP8266 Wi-Fi Modem. The Arduino receives the location of the device from the GPS receiver and display it on the character LCD. As the device finds a data connection through Wi-Fi like Wi-Fi hotspot of a smart phone, it sends the current GPS location to a custom designed webpage. The webpage shows the location of the device with the help of Google Maps.
This simple vehicle tracking device is easy to design, implement and can be installed in any vehicle. It keeps track of the vehicle at which it is installed in real time. The GPS data which this device displays and send to the remote webpage are the geographic coordinates (latitude and longitude) of the device.
The Arduino Sketch manages the functionalities of the device like getting GPS location, displaying it on LCD module, connecting to a Wi-Fi access point and sending the GPS data to a real time generated webpage. The Arduino sketch is written, compiled and loaded with the help of Arduino IDE.
Fig. 1: Prototype of Arduino and ESP8266 based IoT Vehicle Tracking Device
Components Required –
Fig. 2: List of Components used in designing Arduino and ESP8266 based IoT Vehicle Tracking Device
Block Diagram –
Fig. 3: Block Diagram of Arduino and ESP8266 based IoT Vehicle Tracking Device
Circuit Connections –
The Arduino based Vehicle Tracking System designed here is an IoT device. It is designed by interfacing GPS module, character LCD and ESP8266 Wi-Fi modem to the Arduino UNO. The NEO-6M GPS module is used to get the geographical co-ordinates of the location. The ESP module is used to update the location of the vehicle to the web server which can be tracked through Google Maps, where the exact moving position of the vehicle can be tracked.
Fig. 4: Image showing circuit connections of Arduino and ESP8266 based IoT Vehicle Tracking Device
The Arduino based Vehicle Tracking IoT device has the following components and circuit connections –
Power Supply – The Arduino UNO can be powered from a USB socket. There are USB supplies available in most cars. Even bikes can be modified to have USB power supply from the vehicle battery. The GPS module and character LCD in the circuit draw power from the 5V DC supply of the Arduino while ESP8266 Wi-Fi modem draws power from the 3.3 V DC supply of the Arduino.
Arduino UNO – The Arduino UNO is ATmega328 based microcontroller board. The board comes with built-in arduino boot loader. It has 14 GPIO pins, 6 PWM pins, 6 Analog inputs and on board UART, SPI and TWI interfaces, an on-board resonator, a reset button, and holes for mounting pin headers. While programming the board, it can be connected to the PC using USB port and the board can runs on USB power. The Arduino UNO has 32 Kb Flash memory, 1 Kb EEPROM and 2 Kb SRAM. The board can be connected to different Arduino Shields for connectivity with Ethernet, Bluetooth, Wi-Fi, Zigbee or Cellular network and it can be connected to most of the IoT platforms. The ATmega328 controller has the following pin configuration –
Fig. 5: Table listing pin configuration of Arduino Uno
Fig. 6: Table listing pin configuration of Arduino Uno
In this project, 6 GPIO pins of the Arduino are used to interface the character LCD, 2 GPIO pins are used to provide serial communication with the ESP8266 modem using software serial and two GPIO pins are used for serial communication with the GPS module.
ESP8266 Wi-Fi Modem – The ESP8266 Wi-Fi Module is used to connect the Arduino board with a Wi-Fi access point, so that it can access the cloud server and update GPS data to the server. It is a self contained SOC with integrated TCP/IP protocol stack that can access to a Wi-Fi network. The ESP8266 is capable of either hosting an application or off loading all Wi-Fi networking functions from another application processor. Each ESP8266 module comes pre-programmed with an AT command set firmware. The module comes available in two models – ESP-01 and ESP-12. ESP-12 has 16 pins available for interfacing while ESP-01 has only 8 pins available for use. The ESP-12 has the following pin configuration –
Fig. 7: Table listing pin configuration of ESP8266 ESP-12 Wi-Fi Modem
The ESP-01 model is used in the project. The ESP-01 model has the following pin configuration –
Fig. 8: Table listing pin configuration of ESP8266 ESP-01 Wi-Fi Modem
The RESET and VCC pins of the module are connected to the 3.3 V DC from Arduino while Ground pin is connected to the common ground. The Tx and Rx pins of the module are connected to the 10 and 11 pins of the Arduino UNO respectively where the Arduino pins are configured as serial receiver and transmitter respectively using software serial library.
16X2 LCD – The 16X2 LCD display is connected to the Arduino board by connecting its data pins DB4 to DB7 with pins 8 to 5 of the Arduino board. The RS and E pins of the LCD are connected to pins 13 and 12 of the Arduino board respectively. The RW pin of the LCD is grounded.
Fig. 9: Table listing circuit connections between LCD and Arduino Uno
The standard open-source library for interfacing LCD with Arduino board is used in the project. The library works as expected and needs no changes or modifications.
GPS Module – The GPS module used in this project is Neo 6M. It is a standalone GPS module with 50-channel u-blox 6 positioning engine that boasts a Time-To-First-Fix (TTFF) of less than 1 second. The dedicated acquisition engine, with 2 million correlates, is capable of massive parallel time/frequency space searches, enabling it to find satellites instantly. Innovative design and technology suppresses jamming sources and mitigates multipath effects, giving NEO-6 GPS receivers excellent navigation performance even in the most challenging environments. It has UART port for the transfer of data. The SOC on module is 24-pin chip having the following pin configuration –
Fig. 10: Table listing pin configuration of Neo 6M GPS Chip
Fig. 11: Table listing pin configuration of Neo 6M GPS Chip
The GPS module is connected with the Arduino UNO according to the following table –
Fig. 12: Table listing circuit connections between GPS Module and Arduino Uno
The Arduino pins 2 and 3 are configured as software serial receiver and transmitter respectively using software serial library.
How the circuit works –
When the Arduino based IoT device is powered on, some initial messages are displayed on the character LCD and it starts reading the GPS data from the Neo-6M module. At first the local server IP should be loaded in the web page which will displayed initially in Serial monitor of arduino or in the LCD display. The GPS starts getting the geographic coordinates of the location, where the GPS module gets the location update every 27 seconds and update to the web server with help of the ESP Wi-Fi module. The device starts searching for a Wi-Fi Access Point. If a Wi-Fi access point is available, the Arduino obtains the IP address if required and connect with the Wi-Fi point. The name and password of the Wi-Fi access point are hard-coded in the Arduino sketch. The initialization of the Wi-Fi connection is done within the setup() function of the Arduino Sketch which runs once the board is powered on.
The setup of Wi-Fi connection is run by passing AT commands to the ESP8266 Wi-Fi modem. The modem is connected to GPIO pins of the Arduino which are configured as UART transmitter and receiver pins by using software serial library. The Wi-Fi is initialized by passing the following AT commands to ESP module –
AT : This command is passed to check if modem is functioning properly.
AT+CWMODE=3 : This command is passed to set the Wi-Fi mode to both AP as well as Station mode.
AT+CWQAP: This command is passed to disconnect from any AP (Access Point) if the modem is connected to.
AT+RST: This command is passed to reset the modem.
After reset, the modem check IP addresses of the available access points. The ESP modem can connect with the access point whose SSID and Password are hard-coded in the Arduino Sketch. The following AT command is passed to connect with the Access Point –
AT+CWJAP
Once the modem is connected to an access point, it obtains IP address by executing the following command –
AT+CIFSR: This command is used to obtain IP address of ESP module as an client.
The IP address is stored in a string and acknowledged to the Arduino board. Now the following AT commands are passed to the ESP module – AT+CIPMUX=1: This command is passed to enable multiple connections.
AT+CIPSERVER=1,80: This command is passed to create a server at port 80.
The Arduino reads the latitude and longitude from the GPS module. The GPS data is wrapped into proper formatted strings and stored in variables. It is displayed on the character LCD and sent to the remote server (local server in this case) when the Wi-Fi connection is available. The data is updated in every 27 seconds and the current stored data to updated to the local server as Wi-Fi connection is setup. The local server is a PC or laptop connected to the same Wi-Fi access point and running local host. A webpage is created by the Arduino Sketch and sent with the updated GPS data to the local server. At the web server the location of the vehicle moving can be viewed through Google Maps. The device here connects to local host. In order to connect with a hosted website or webpage, port forwarding must be done on the ESP8266 modem.
Programming Guide –
The Arduino sketch begins with importing the standard libraries like SoftwareSerial.h and LiquidCrystal.h. The LiquidCrystal.h is used to manage data communication between LCD module and the Arduino. The SoftwareSerial.h is used to configure Arduino pins as serial transmitter and receiver to perform serial communication with the GPS module and the ESP8266 modem. Some variables are declared to hold GPS data and messages, IP address of Wi-Fi Access Point and HTML content for the webpage.
.
Fig. 13: Screenshot of Arduino code used for initialization of IoT Vehicle Tracking Device
The setup() function is called in which baud rate for the serial communication with the Wi-Fi modem is set. The Wi-Fi mode and network connectivity is established using the AT commands with some delays. The delay should be given according to time it takes to connect with the network by calling the wifi_init() function. The GPS module is initialized and the coordinates are read using get_gps() function.
Fig. 14: Screenshot of Setup Function from Arduino code used in IoT Vehicle Tracking Device
The loop() function is called which runs infinitely. In this function, the get_gps() function is called to read the geographical coordinates of location. The functions to create HTML content for the webpage with updated GPS location and to send the webpage to the local web server are called.
Fig. 15: Screenshot of Mani Loop from Arduino code used in IoT Vehicle Tracking Device
Check out the Arduino Sketch from the code section to try it out. This is a simple GPS device for vehicle tracking. The Arduino code can be modified to connect with any webpage or website. It is a low-cost do it yourself IoT project which is easy to implement.
Project Source Code
### //Program to #include
#include SoftwareSerial Serial1(2,3); //make RX arduino line is pin 2, make TX arduino line is pin 3. SoftwareSerial gps(10,11); LiquidCrystal lcd(13,12,9,8,7,6); boolean No_IP=false; String IP=""; String webpage=""; int i=0,k=0; int gps_status=0; String place=" 1. Name: [ENTER UR NAME]
"; String num = "2. Vehicle No: IND001
"; String cordinat="Coordinates:
"; String latitude=""; String logitude=""; String gpsString=""; char *test="$GPGGA"; void setup() { Serial1.begin(9600); Serial.begin(9600); lcd.begin(16,2); lcd.print("Vehicle Monitoring"); lcd.setCursor(0,1); lcd.print(" System "); delay(2000); lcd.clear(); lcd.print("Connecting...."); delay(1000); connect_wifi("AT",1000); connect_wifi("AT+CWMODE=3",1000); connect_wifi("AT+CWQAP",1000); connect_wifi("AT+RST",5000); FindIP(5000); if(!No_IP) { Serial.println("Connecting Wifi...."); connect_wifi("AT+CWJAP="[ENTER UR SSID NAME] ","[ENTER THE PASSWORD]"",7000); //AT+CWJAP=”wifi_username”,”wifi_password” } else { } Serial.println("Wifi Connected"); lcd.clear(); lcd.print("WIFI Connected"); delay(2000); lcd.clear(); lcd.setCursor(5,0); lcd.print("IP"); lcd.setCursor(3,1); lcd.print("ADDRESS"); ip_add(); delay(2000); connect_wifi("AT+CIPMUX=1",100); connect_wifi("AT+CIPSERVER=1,80",100); Serial1.end(); lcd.clear(); lcd.print(" GPS DATA"); delay(2000); gps.begin(9600); get_gps(); coordinate_display(); gps.end(); Serial1.begin(9600); } void loop() { k=0; Serial.println("Please Refresh Ur Page"); while(k<1000) { k++; while(Serial1.available()) { if(Serial1.find("0,CONNECT")) { Serial1.end(); gps.begin(9600); get_gps(); gps.end(); Serial1.begin(9600); Serial1.flush(); Serial.println("Start Printing"); Send(); coordinate_display(); Serial.println("Done Printing"); delay(5000); lcd.clear(); lcd.print("System Ready"); delay(1000); k=1200; break; } } delay(1); } } void FindIP(int t1) { int t2=millis(); while(t2+t1>millis()) { while(Serial1.available()>0) { if(Serial1.find("WIFI GOT IP")) { No_IP=true; } } } } void ip_add() { IP=""; char ch=0; while(1) { Serial1.println("AT+CIFSR"); while(Serial1.available()>0) { if(Serial1.find("STAIP,")) { delay(1000); Serial.print("IP Address:"); while(Serial1.available()>0) { ch=Serial1.read(); if(ch=='+') break; IP+=ch; } } if(ch=='+') break; } if(ch=='+') break; delay(1000); } lcd.clear(); lcd.print(IP); lcd.setCursor(0,1); lcd.print("Port: 80"); Serial.print(IP); Serial.print("Port:"); Serial.println(80); delay(1000); } void connect_wifi(String cmd, int t) { int temp=0,i=0; while(1) { Serial.println(cmd); Serial1.println(cmd); while(Serial1.available()>0) { if(Serial1.find("OK")) { i=8; } } delay(t); if(i>5) break; i++; } if(i==8) { Serial.println("OK"); } else { Serial.println("Error"); } delay(1000); } void gps_Function() { gpsString=""; while(1) { while (gps.available()>0) //Serial incoming data from GPS { char inChar = (char)gps.read(); gpsString+= inChar; //store incoming data from GPS to temporary string str[] i++; if (i < 7) { if(gpsString[i-1] != test[i-1]) //check for right string { i=0; gpsString=""; } } if(inChar=='r') { if(i>65) { gps_status=1; break; } else { i=0; } } } if(gps_status) break; } } void get_gps() { gps_status=0; int x=0; while(gps_status==0) { gps_Function(); int str_lenth=i; latitude=""; logitude=""; coordinate2dec(); i=0;x=0; str_lenth=0; } } void coordinate_display() { lcd.clear(); lcd.print("LATITUTE:"); lcd.print(latitude); lcd.setCursor(0,1); lcd.print("LONGITUTE:"); lcd.print(logitude); Serial.print("Latitude:"); Serial.println(latitude); Serial.print("Longitude:"); Serial.println(logitude); } void coordinate2dec() { String lat_degree=""; for(i=18;i<20;i++) //extract latitude from string lat_degree+=gpsString[i]; String lat_minut=""; for(i=20;i<28;i++) lat_minut+=gpsString[i]; String long_degree=""; for(i=30;i<33;i++) //extract longitude from string long_degree+=gpsString[i]; String long_minut=""; for(i=33;i<41;i++) long_minut+=gpsString[i]; float minut= lat_minut.toFloat(); minut=minut/60; float degree=lat_degree.toFloat(); latitude=degree+minut; minut= long_minut.toFloat(); minut=minut/60; degree=long_degree.toFloat(); logitude=degree+minut; } void Send() { webpage = "Welcome to Engineers Garage
"; webpage+=place; webpage+=num; webpage+=cordinat; webpage+="Latitude:"; webpage+=latitude; webpage+="
"; webpage+="Longitude:"; webpage+=logitude; webpage+="
"; webpage+= "Click Here for google map"; webdata(); webpage=""; while(1) { Serial.println("AT+CIPCLOSE=0"); Serial1.println("AT+CIPCLOSE=0"); while(Serial1.available()) { if(Serial1.find("0,CLOSE")) { return; } } delay(500); i++; if(i>5) { i=0; } if(i==0) break; } } void webdata() { i=0; while(1) { unsigned int l=webpage.length(); Serial1.print("AT+CIPSEND=0,"); Serial1.println(l+2); Serial.println(l+2); Serial.println(webpage); Serial1.println(webpage); while(Serial1.available()) { if(Serial1.find("OK")) { return; } } i++; if(i>5) i=0; if(i==0) break; delay(200); } } ###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects, ESP8266, IoT, Raspberry pi
Filed Under: Electronic Projects, ESP8266, IoT, Raspberry pi
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.