IoTAdvancedPRJ-157

IoT Smart Vehicle Theft Detection Using ESP32

Detects tampering, locks the engine and texts you the vehicle’s location.

Built and tested by Drisya K S · Industrial Robotics Institute

ESP32

Arduino IDE, Blynk IoT app, TinyGPSPlus library

LevelAdvanced
Build time4–6 hours
BoardESP32
Parts9 components

What is the IoT Smart Vehicle Theft Detection?

An anti-theft system for cars and bikes. A vibration sensor detects tampering; the ESP32 then sounds a buzzer, cuts the engine through a relay, reads the GPS location and sends an SMS with a Google Maps link via a SIM800L GSM module. The alert and link also appear in the Blynk app, and the owner can unlock with a button.

How it works

  1. The SW-420 vibration sensor detects movement or tampering.
  2. The ESP32 sounds the buzzer and switches the engine-lock relay.
  3. It reads the GPS position and builds a Google Maps link.
  4. The SIM800L sends an SMS "Theft Detected! Location: …" to the owner, and Blynk shows the alert.
  5. The owner presses the button to unlock and silence it.

Parts list

ComponentQty
ESP32 Dev Board1
GPS Module (NEO-6M)1
GSM Module (SIM800L) with SIM card1
Relay Module (engine lock)1
Vibration Sensor (SW-420)1
Push Button1
Buzzer1
LED1
Power Supply (4V for SIM800L)1

Software

  • Arduino IDE
  • Blynk IoT app
  • TinyGPSPlus library

Wiring and connections

FromConnect to
GPS TXGPIO 16
GPS RXGPIO 17
GPS VCC / GND3.3V / GND
SIM800L TXGPIO 27
SIM800L RXGPIO 26
SIM800L VCCExternal 4V (2A peak)
Vibration DOGPIO 13
Relay INGPIO 25
Buzzer +GPIO 14
LED + (via resistor)GPIO 12
ButtonGPIO 33 and GND
All GNDCommon ground

How to build the IoT Smart Vehicle Theft Detection

  1. Wire the GPS to GPIO 16/17 and the SIM800L to GPIO 27/26; power the SIM800L from a 4V supply that can give 2A.
  2. Connect the vibration sensor to GPIO 13, the relay to GPIO 25, the buzzer to GPIO 14 and the button to GPIO 33.
  3. Insert an active SIM card and put the owner’s number in the code (with country code).
  4. In Blynk, create datastreams V1 (status) and V2 (location link).
  5. Add your Blynk details and Wi-Fi and upload.
  6. Test indoors with the relay connected to an LED before wiring to a real ignition (get an auto electrician for that).

IoT Smart Vehicle Theft Detection code

Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.

#define BLYNK_TEMPLATE_ID "YourTemplateID"
#define BLYNK_TEMPLATE_NAME "Vehicle Security"
#define BLYNK_AUTH_TOKEN "YourAuthToken"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <TinyGPS++.h>
#include <HardwareSerial.h>

char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";
const char* ownerNumber = "+91XXXXXXXXXX";   // owner's phone number

TinyGPSPlus gps;
HardwareSerial gpsSerial(1);
HardwareSerial gsmSerial(2);

int vibrationPin = 13;
int relay = 25;
int buzzer = 14;
int button = 33;

bool alertSent = false;

void sendSMS(String text) {
  gsmSerial.println("AT+CMGF=1");
  delay(1000);
  gsmSerial.print("AT+CMGS=\"");
  gsmSerial.print(ownerNumber);
  gsmSerial.println("\"");
  delay(1000);
  gsmSerial.print(text);
  gsmSerial.write(26);   // Ctrl+Z to send
}

void setup() {
  Serial.begin(115200);
  pinMode(vibrationPin, INPUT);
  pinMode(relay, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(button, INPUT_PULLUP);

  gpsSerial.begin(9600, SERIAL_8N1, 16, 17);
  gsmSerial.begin(9600, SERIAL_8N1, 27, 26);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}

void loop() {
  while (gpsSerial.available()) gps.encode(gpsSerial.read());

  if (digitalRead(vibrationPin) == HIGH && !alertSent) {
    digitalWrite(buzzer, HIGH);
    digitalWrite(relay, HIGH);        // engine lock

    String link = "https://maps.google.com/?q=" +
                  String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6);

    sendSMS("Theft Detected! Location: " + link);
    Blynk.virtualWrite(V1, "Theft Detected!");
    Blynk.virtualWrite(V2, link);
    alertSent = true;
  }

  // Manual unlock
  if (digitalRead(button) == LOW) {
    digitalWrite(relay, LOW);
    digitalWrite(buzzer, LOW);
    Blynk.virtualWrite(V1, "Vehicle Unlocked");
    alertSent = false;
  }

  Blynk.run();
  delay(500);
}

Real-world uses

  • Cars and two-wheelers
  • Fleet and rental vehicles
  • Delivery bikes
  • Learning GSM + GPS

Frequently asked questions

What is a IoT Smart Vehicle Theft Detection?

An anti-theft system for cars and bikes. A vibration sensor detects tampering; the ESP32 then sounds a buzzer, cuts the engine through a relay, reads the GPS location and sends an SMS with a Google Maps link via a SIM800L GSM module.

What components are needed for the IoT Smart Vehicle Theft Detection?

You need: ESP32 Dev Board (1), GPS Module (NEO-6M) (1), GSM Module (SIM800L) with SIM card (1), Relay Module (engine lock) (1), Vibration Sensor (SW-420) (1), Push Button (1), Buzzer (1), LED (1), Power Supply (4V for SIM800L) (1). Software: Arduino IDE, Blynk IoT app, TinyGPSPlus library.

Is the IoT Smart Vehicle Theft Detection project good for beginners?

It is rated advanced and takes about 4–6 hours to build, using the ESP32. The guide on this page explains every connection and step.

Where can I get the code for the IoT Smart Vehicle Theft Detection?

The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.

Can I buy a kit for the IoT Smart Vehicle Theft Detection?

Yes. IRI sells a kit with the parts for this project (PRJ-157). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.

Industrial Robotics Institute
Logo