Vehicle Location Tracker with ESP32 and GPS with Arduino

ESP32 GPS Vehicle Tracker

ESP32 GPS Tracker- IoT based Vehicle Tracking System, GPS stands for Global Positioning System, which is a worldwide radio-navigation system.

To track the location of the device, the GPS tracking system uses the Global Navigation Satellite System (GNSS) Network.

This network consists of a range of satellites that uses microwave signals to transmit the data which will be received by the GPS receiver module.

Previously we used GPS with NodeMCU ESP8266 to build a Vehicle Tracking System and Accident alert system.

In this project, we are going to build an IoT based GPS Vehicle Tracking System using ESP32 where we will display the latitude and longitude values on OLED Display as well as on Blynk App so that it can be monitored from anywhere in the world.

Components Required

1. ESP32
2. GPS Module
3. OLED Display Module

OLED Display

The OLED displays are one of the most common and easily available displays for a microcontroller.

This display can easily be interfaced with microcontroller using IIC or using SPI communication and has a good view angle and pixel density which makes it reliable for displaying small level graphics.

It is compatible with any 3.3V-5V microcontroller, such as Arduino.

The OLED display comes with a powerful single-chip CMOS OLED driver controller – SSD1306 that handles the entire RAM buffering.

The SSD1306 driver has a built-in 1KB Graphic Display Data RAM (GDDRAM).

Specifications

1. OLED Driver IC: SSD1306
2. Resolution: 128 x 64
3. Visual Angle: >160°
4. Input Voltage: 3.3V ~ 6V
5. Pixel Colour: Blue

Neo 6M GPS Module

The NEO-6M module comes with a dimension of 16 x 12.2 x 2.4 mm package. It has 6 Ublox positioning engines offering unmatched performance.

It is a good performance GPS receiver with a compact architecture, low power consumption, and reliable memory options. It is ideal for battery-operated mobile devices considering its architecture and power demands.

The Time-to-First-Fix is less than 1 second and it enables it to find the satellites almost instantly. The output is in the format of NMEA standards, which can be decoded to find the coordinates and Time of the location.

1. Power supply: 2.8V to 5V
2. nterface: RS232 TTL
3. Built-in EEPROM and external antenna
4. Default baud rate: 9600 bps

We previously used GPS module Neo 6M with NodeMCU and displayed the location coordinates on a web-page, check all the GPS based IoT projects here.

Circuit Diagram

Circuit Diagram for ESP32 GPS NEO 6M is given below.

Here we are interfacing the ESP32 with GPS Module and OLED Display. Vcc and GND pin of GPS Module is connected to 3.3V and GND of ESP32 while the RX and TX pins are connected to TX2 and RX2 pins of ESP32.

I2C mode is used to connect the OLED display Module (SSD1306) with ESP32. Connections between ESP32 and OLED Display are given as:

1 OLED Pin ESP32 Pin
2 Vcc 3.3v
3 GND GND
4 SCL D22
5 SDA D21

 

Configuring Blynk App for ESP32 GPS Tracker

Download the Blynk app from the Google Play Store and create a new account or Login into your existing account.
Now click on ‘New Project’ to start a new project.

Now give a name for your project. Select ‘ESP32 Dev Board’ in the CHOOSE DEVICE option and ‘Wi-Fi’ in CONNECTION TYPE. Then click on ‘Create.’
After this, Blynk will send an Authorization to the registered Email id. Note down the Auth Token Code. It will be used in the Program.

Now in the next window, click on the “+” sign to add a widget. Inside the Widget box, select the ‘Map’ widget.

After this, click on the MAP widget and select virtual pin ‘V0’ as INPUT.

With this final step, you are ready to use your app. By pressing the ‘Play’ button, you can switch your app from EDIT mode to PLAY mode where you can interact with the hardware.

Code Explanation

The complete code for ESP32 GPS Tracking System is given at the end of the page. Here we are explaining some important parts of code.

In this program, we are going to use the Wire.h, TinyGPS++.h, SH1106.h and BlynkSimpleEsp32.h libraries. These libraries can be downloaded from below links:

1. Wire.hTinyGPS++.h
2. SH1106.h
3. BlynkSimpleEsp32.h

So as usual, start the code by including all the required libraries. SH1106.h is especially created for ESP modules.
Working of ESP32 GPS Tracking System

Once the hardware and the program are ready, upload the GPS tracking program into your ESP32 Board. Here Arduino IDE is used to upload the ESP32 GPS NEO 6M code to ESP32 board, so connect the ESP32 to your laptop with a Micro USB Cable and hit the upload button.

Once the code is uploaded, the OLED will display the Latitude and Longitude values. It will also show the location in the Blynk app on Map like this

COMPLETE CODE

#include <TinyGPS++.h>
#include <HardwareSerial.h>
#include <WiFi.h>
#include <Wire.h>               // Only needed for Arduino 1.6.5 and earlier
#include<SH1106.h>
#include <BlynkSimpleEsp32.h>
float latitude , longitude;
String  lat_str , lng_str;
const char *ssid =  “Galaxy-M20”;     // Enter your WiFi Name
const char *pass =  “ac312129”; // Enter your WiFi Password
char auth[] = “loPrSaL0eQFY9clcQ518R1SmYsRVC0eV”;
WidgetMap myMap(V0);
SH1106 display(0x3c, 21, 22);
WiFiClient client;
TinyGPSPlus gps;
HardwareSerial SerialGPS(1);
void setup()
{
Serial.begin(115200);
Serial.println(“Connecting to “);
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(“.”);              // print … till not connected
}
Serial.println(“”);
Serial.println(“WiFi connected”);
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
SerialGPS.begin(9600, SERIAL_8N1, 16, 17);
Blynk.begin(auth, ssid, pass);
Blynk.virtualWrite(V0, “clr”);
}
void loop()
{
while (SerialGPS.available() > 0) {
if (gps.encode(SerialGPS.read()))
{
if (gps.location.isValid())
{
latitude = gps.location.lat();
lat_str = String(latitude , 6);
longitude = gps.location.lng();
lng_str = String(longitude , 6);
Serial.print(“Latitude = “);
Serial.println(lat_str);
Serial.print(“Longitude = “);
Serial.println(lng_str);
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_16);
display.drawString(0, 23, “Lat:”);
display.drawString(45, 23, lat_str);
display.drawString(0, 38, “Lng:”);
display.drawString(45, 38, lng_str);
Blynk.virtualWrite(V0, 1, latitude, longitude, “Location”);
display.display();
}
delay(1000);
Serial.println();
}
}
Blynk.run();
}

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 510

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×