ESP32 GPS Tracker With SIM800L and NEO-6M

by ElectroScope Archive in Circuits > Microcontrollers

261 Views, 1 Favorites, 0 Comments

ESP32 GPS Tracker With SIM800L and NEO-6M

Demo-Setup-of-Hardware-ESP32-with-GSM-and-GPS.jpg

So I needed a GPS tracker that would work in areas without Wi-Fi. The ESP32 with SIM800L GSM module and NEO-6M GPS seemed like the right combination, and cellular connectivity means it works anywhere with 2G coverage.

We're using GeoLinker for the cloud platform, which handles the data visualisation without needing to set up your own server infrastructure.

Supplies

  1. ESP32 Development Board
  2. SIM800L GSM Module
  3. NEO-6M GPS Module
  4. 2x 5mm LEDs (yellow and green)
  5. 2x 470Ω Resistors
  6. Breadboard
  7. Jumper wires
  8. SIM card with a 2G data plan

Get Your API Key From GeoLinker

GeoLinker-Login-UI.png
Generating-API-Key-Geolinker.png

Before wiring anything, you need an API key from Circuit Digest Cloud.

  1. Go to the Circuit Digest Cloud homepage and create an account if you don't have one.
  2. After logging in, click "My Account" in the top right corner. Enter the captcha and click "Generate API Key."
  3. Save this key - you'll need it in your code. Each key gives you 10,000 GPS data points. When you reach the limit, generate a new key.

Wire the Circuit

Circuit-Diagram-esp32-gps-navigation.png
Parts-Marking-ESP32-GPS-Tracker.png

ESP32 to SIM800L:

  1. GPIO18 → SIM800L TX
  2. GPIO19 → SIM800L RX
  3. VCC: The SIM800L needs 3.7-4.2V. I used a diode to drop 5V down to about 4.3V, which works. For a cleaner solution, use a buck converter or dedicated LiPo battery.

ESP32 to NEO-6M:

  1. GPIO16 → GPS TX
  2. GPIO17 → GPS RX
  3. VCC from ESP32 3.3V pin (if this doesn't work for your module, use 5V with level shifters on TX/RX)

Status LEDs:

  1. GPIO23 → 470Ω resistor → Yellow LED → GND (GPS status)
  2. GPIO32 → 470Ω resistor → Green LED → GND (transmission status)

Check your connections carefully. Loose wires cause most issues.

Install the GeoLinker Library

Open Arduino IDE and install the GeoLinker library through the Library Manager, or download it from GitHub.

This library handles GPS parsing, GSM communication, cloud uploads, and offline data buffering automatically.

Upload the Code

Here's the complete code:

#include <GeoLinker.h>

// GPS Configuration
HardwareSerial gpsSerial(1);
#define GPS_RX 16
#define GPS_TX 17
#define GPS_BAUD 9600

// GSM Configuration
HardwareSerial gsmSerial(2);
#define GSM_RX 18
#define GSM_TX 19
#define GSM_BAUD 9600
#define GSM_PWR_PIN -1
#define GSM_RST_PIN -1

// Network credentials
const char* apn = "yourAPN"; // Replace with your carrier's APN
const char* gsmUser = nullptr;
const char* gsmPass = nullptr;

// GeoLinker settings
const char* apiKey = "xxxxxxxxxxxx"; // Replace with your API key
const char* deviceID = "ESP32_Sim800l";

const uint16_t updateInterval = 30;
const bool enableOfflineStorage = true;
const uint8_t offlineBufferLimit = 20;

const bool enableAutoReconnect = true;
const int8_t timeOffsetHours = 5;
const int8_t timeOffsetMinutes = 30;

// LED pins
const int DataSent_LED = 32;
const int GPSFix_LED = 23;

GeoLinker geo;

void setup() {
Serial.begin(115200);
gpsSerial.begin(GPS_BAUD, SERIAL_8N1, GPS_RX, GPS_TX);
gsmSerial.begin(GSM_BAUD, SERIAL_8N1, GSM_RX, GSM_TX);
pinMode(DataSent_LED, OUTPUT);
pinMode(GPSFix_LED, OUTPUT);
geo.begin(gpsSerial);
geo.setApiKey(apiKey);
geo.setDeviceID(deviceID);
geo.setUpdateInterval_seconds(updateInterval);
geo.setDebugLevel(DEBUG_BASIC);
geo.enableOfflineStorage(enableOfflineStorage);
geo.enableAutoReconnect(enableAutoReconnect);
geo.setOfflineBufferLimit(offlineBufferLimit);
geo.setTimeOffset(timeOffsetHours, timeOffsetMinutes);
geo.setNetworkMode(GEOLINKER_CELLULAR);
geo.setModemCredentials(apn, gsmUser, gsmPass);
geo.beginModem(gsmSerial, GSM_PWR_PIN, GSM_RST_PIN, true);
geo.setModemTimeouts(5000, 15000);
}

void loop() {
uint8_t status = geo.loop();
switch (status) {
case STATUS_SENT:
Serial.println("Data sent successfully!");
break;
case STATUS_GPS_ERROR:
Serial.println("GPS connection error!");
break;
case STATUS_NETWORK_ERROR:
Serial.println("Network error (buffered).");
break;
case STATUS_BAD_REQUEST_ERROR:
Serial.println("Bad request error!");
break;
case STATUS_PARSE_ERROR:
Serial.println("GPS data format error!");
break;
case STATUS_CELLULAR_NOT_REGISTERED:
Serial.println("GSM: Not registered to network!");
break;
}
if ((status != STATUS_GPS_ERROR) && (status != STATUS_PARSE_ERROR)) {
digitalWrite(GPSFix_LED, HIGH);
} else {
digitalWrite(GPSFix_LED, LOW);
}
if (status == STATUS_SENT) {
digitalWrite(DataSent_LED, HIGH);
delay(1000);
digitalWrite(DataSent_LED, LOW);
}
}

Update the apiKey and apn values with your credentials before uploading.

Test the Hardware

After uploading, check these status indicators:

SIM800L NETLIGHT LED patterns:

  1. Blinks every 1 second: Module running, not connected to network
  2. Blinks every 2 seconds: GPRS data connection active
  3. Blinks every 3 seconds: Connected to cellular network
  4. Fast blinking: Data transmission in progress

NEO-6M LED:

  1. Stays off until GPS achieves satellite lock
  2. Starts blinking once position is fixed

For outdoor testing, I used a power bank secured to the breadboard with zip ties.

View Your Tracking Data

GPS-Tracker-ESP32-Geolinker-UI.png
GPS-Tracker-ESP32-GeoLinker-Map-UI.png
esp32-sim800l-gps-tracker.gif

Open GeoLinker to see your location data in real-time.

The map updates as the device moves, showing the complete path.

Troubleshooting Common Issues

GPS not getting a fix:

  1. Move outdoors with clear sky visibility
  2. Wait 2-15 minutes for cold start
  3. Check antenna connection
  4. Verify power supply voltage

SIM800L not registering:

  1. Test SIM card in a phone first
  2. Confirm adequate power supply (minimum 2A peak current)
  3. Verify 2G network availability in your area
  4. Check for LED blinking at 3-second intervals

Upload failures:

  1. Verify correct board selection in Arduino IDE
  2. Try a different USB cable
  3. Check COM port settings

Additional Resources

This guide is entirely based on: ESP32 GPS Tracker with SIM800L

The system now provides reliable GPS tracking over cellular networks. Data transmission uses approximately 10-20MB monthly with 30-second update intervals.