Introduction: In this tutorial, we will demonstrate how to build a GPS tracker using an Arduino Nano, ESP32, and a LORA module. This tracker collects real-time latitude and longitude data and displays it via a basic webserver hosted on the ESP32. The location data can also be accessed through Google Maps.
Components and Supplies:
- 1 x ESP32
- 1 x Arduino Nano
- 2 x 1kΩ Resistors
- 2 x LED Diodes
- GT-7U GPS Module
- Female Pins
Project Description:
The GPS module captures location data such as UTC time, latitude, and longitude. This data is processed using the Arduino Nano and transmitted through the LORA module. The ESP32 then acts as a webserver, providing a Google Maps URL for real-time tracking.
Key Features of GT-U7 GPS Module:
- High Sensitivity: Accurate tracking even in challenging environments.
- Interfaces: IPEX antenna interface, UART, USB, and SPI.
- Power Management Modes: Eco, Maximum Performance, and Power-Saving Modes.
- Assisted GPS (A-GPS): Faster acquisition time using pre-stored satellite data.
Specifications:
- Operating Voltage: 3.6V – 5V
- Communication Protocols: NMEA, UBX
- Compatible Applications: Vehicle tracking, mobile location systems, bicycle sharing, and more.
Connection Overview:
The project integrates the following:
- GT-7U GPS Module: Captures location data.
- Arduino Nano: Processes the data.
- LORA Module: Transmits data wirelessly.
- ESP32: Hosts a webserver to display location data via Google Maps.
Code Implementation
1. GPS Tracker Code Using TinyGPS Library (Arduino Nano):
include
include
TinyGPS gps;
SoftwareSerial ss(4, 3);
void setup() {
Serial.begin(9600);
ss.begin(9600);
Serial.println(“Starting GPS Tracker with TinyGPS…”);
}
void loop() {
bool newData = false;
unsigned long start = millis();
while (millis() – start < 5000) {
while (ss.available()) {
char c = ss.read();
if (gps.encode(c)) newData = true;
}
}
if (newData) {
float latitude, longitude;
gps.f_get_position(&latitude, &longitude);
Serial.print(“https://maps.google.com/maps?q=”);
Serial.print(latitude, 6);
Serial.print(“,”);
Serial.println(longitude, 6);
} else {
Serial.println(“No GPS data received. Check the wiring.”);
}
}
2. ESP32 Webserver Code:
include
define RXD2 16
define TXD2 17
const char* ssid = “Your_WiFi_SSID”;
const char* password = “Your_WiFi_Password”;
WiFiServer server(80);
String locationData;
void setup() {
Serial.begin(9600);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.print(“Connecting to WiFi…”);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“Connected! IP Address: “);
Serial.println(WiFi.localIP());
server.begin();
}
void loop() {
if (Serial2.available()) {
locationData = “”;
while (Serial2.available()) {
locationData += char(Serial2.read());
delay(1);
}
}
WiFiClient client = server.available();
if (client) {
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-type:text/html”);
client.println(“Connection: close”);
client.println(“Refresh: 5”);
client.println();
client.println(“”); client.println(“
GPS Tracker
“); client.println(“Location: ” + locationData + “
“); client.println(“”);
client.stop();
}
}