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.
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.
Arduino and ESP8266 based IoT Vehicle Tracking Device Circuit
Components Required -
Block Diagram -
Arduino and ESP8266 based IoT Vehicle Tracking Device Block Diagram
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.
Arduino and ESP8266 based IoT Vehicle Tracking Device Circuit Connections
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 -
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 –
The ESP-01 model is used in the project. The ESP-01 model has the following pin configuration –
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.
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 -
The GPS module is connected with the Arduino UNO according to the following table -
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 -
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.
Initialization in Arduino Sketch for IoT Vehicle Tracking System
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.
Setup Function in Arduino Sketch for IoT Vehicle Tracking System
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.
Loop Function in Arduino Sketch for IoT Vehicle Tracking System
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.