Back to All Blog Posts
Tutorial •EltroNerd Engineering

Smart Backpack with GPS Tracking using ESP32

Smart Backpack with GPS Tracking using ESP32

šŸŽ’ Smart Backpack with GPS Tracking (ESP32 + GPS + IoT)


šŸ“Œ 1. Introduction

A Smart Backpack is an innovative wearable IoT device that provides real-time location tracking for safety and security.
By integrating an ESP32 microcontroller with a GPS module, the backpack can send live location updates to a smartphone or cloud server, ensuring the user can be tracked in case of theft or emergency.


šŸŽÆ 2. Objectives

  • To design a portable tracking system embedded inside a backpack.
  • To use GPS for live location monitoring.
  • To transmit location via Wi-Fi or GSM (optional) for remote monitoring.
  • To create a low-power, student-friendly IoT project.

āš™ļø 3. Hardware Requirements

  • ESP32 Development Board (Wi-Fi + Bluetooth enabled)
  • GPS Module (Neo-6M or Ublox series)
  • OLED Display (optional, for local feedback)
  • Li-Po battery + Charging Module (TP4056)
  • GSM/GPRS Module (SIM800L) (optional, for SMS-based tracking)
  • Backpack for housing the electronics

šŸ”Œ 4. Circuit Connections

ESP32 → GPS Module (Neo-6M)

  • GPS TX → ESP32 GPIO16 (RX)
  • GPS RX → ESP32 GPIO17 (TX)
  • VCC → 3.3V or 5V
  • GND → GND

Optional (ESP32 → OLED Display)

  • SDA → GPIO21
  • SCL → GPIO22
  • VCC → 3.3V
  • GND → GND

šŸ“œ 5. Arduino Code (ESP32 + GPS + Serial Monitor)

c
#include <TinyGPS++.h>
#include <HardwareSerial.h>

TinyGPSPlus gps;
HardwareSerial SerialGPS(1);

void setup() {
  Serial.begin(115200);
  SerialGPS.begin(9600, SERIAL_8N1, 16, 17); // RX = 16, TX = 17
  Serial.println("Smart Backpack GPS Tracking Started...");
}

void loop() {
  while (SerialGPS.available() > 0) {
    gps.encode(SerialGPS.read());

    if (gps.location.isUpdated()) {
      Serial.print("Latitude: ");
      Serial.println(gps.location.lat(), 6);
      Serial.print("Longitude: ");
      Serial.println(gps.location.lng(), 6);
      Serial.print("Speed (km/h): ");
      Serial.println(gps.speed.kmph());
      Serial.print("Satellites: ");
      Serial.println(gps.satellites.value());
      Serial.println("----------------------");

      // Example: Send location to a web server (future extension)
      // WiFiClient client;
      // client.print("http://server.com/update?lat=" + String(gps.location.lat(), 6) +
      //              "&lng=" + String(gps.location.lng(), 6));
    }
  }
}

ESP32 → OLED (SSD1306, I²C)

  • SDA → GPIO21
  • SCL → GPIO22
  • VCC → 3.3V
  • GND → GND

šŸ“œ 4. Arduino Code (ESP32 + GPS + OLED)

c

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <TinyGPS++.h>
#include <HardwareSerial.h>

// OLED setup
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

// GPS setup
TinyGPSPlus gps;
HardwareSerial SerialGPS(1);

void setup() {
  Serial.begin(115200);

  // Initialize OLED
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
    for (;;);
  }
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);

  // Initialize GPS
  SerialGPS.begin(9600, SERIAL_8N1, 16, 17); // RX=16, TX=17

  display.setCursor(0, 0);
  display.setTextSize(1);
  display.println("Smart Backpack GPS");
  display.display();
  delay(2000);
}

void loop() {
  while (SerialGPS.available() > 0) {
    gps.encode(SerialGPS.read());

    if (gps.location.isUpdated()) {
      double lat = gps.location.lat();
      double lng = gps.location.lng();
      double speed = gps.speed.kmph();
      int sats = gps.satellites.value();

      // Print to Serial Monitor
      Serial.print("Lat: "); Serial.println(lat, 6);
      Serial.print("Lng: "); Serial.println(lng, 6);
      Serial.print("Speed: "); Serial.println(speed);
      Serial.print("Satellites: "); Serial.println(sats);
      Serial.println("------------------");

      // Show on OLED
      display.clearDisplay();
      display.setTextSize(1);
      display.setCursor(0, 0);
      display.println("GPS Tracking");

      display.setCursor(0, 15);
      display.printf("Lat: %.6f", lat);

      display.setCursor(0, 30);
      display.printf("Lng: %.6f", lng);

      display.setCursor(0, 45);
      display.printf("Spd: %.2f km/h", speed);

      display.setCursor(0, 55);
      display.printf("Sats: %d", sats);

      display.display();
    }
  }
}

šŸ”Ž Working Principle

The Smart Backpack works on the following principle:

  1. GPS Signal Acquisition

    • The GPS module (Neo-6M) receives signals from multiple satellites.
    • Using trilateration, it calculates the exact latitude, longitude, speed, and satellite count.
  2. Data Processing (ESP32)

    • The ESP32 reads raw GPS data via UART and processes it using the TinyGPS++ library.
    • The extracted information includes location coordinates, speed, and satellite strength.
  3. Display Handling

    • The processed GPS data is displayed on the OLED screen in real time.
    • Users can instantly view their live location without needing external devices.
  4. IoT Extension (Optional)

    • The ESP32 can send location data over Wi-Fi to a cloud server, or via GSM module (SIM800L) using SMS/GPRS.
    • This enables remote tracking of the backpack through a smartphone or web dashboard.

šŸ Conclusion

The Smart Backpack with GPS and OLED display demonstrates a low-cost, real-time tracking system that enhances safety, security, and portability.

Key outcomes:

  • Successfully integrates ESP32, GPS, and OLED for live location tracking.
  • Provides a user-friendly display of coordinates, speed, and satellite info.
  • Can be extended with IoT features (Wi-Fi/GSM) for cloud or SMS-based tracking.

This project serves as a practical prototype for personal safety systems, anti-theft tracking, and smart luggage.
It lays the foundation for future advancements such as geofencing alerts, mobile app integration, and battery-powered wearable IoT devices.

Try this project in your browser

Compile code and simulate hardware output with EltroNerd Cloud IDE.

Launch Cloud IDE