π¨ Laser Security Grid Using ESP32 and LDR – DIY Home Intruder Alarm
Laser Security Grid Using ESP32 and LDR – DIY Home Intruder Alarm
Introduction:
Are you tired of boring security systems? Today, let’s build something futuristic, accurate, and completely homemade — a Laser Security System using just an ESP32, an LDR (Light Dependent Resistor), and an OLED display. No Wi-Fi, no apps — the system runs offline and instantly alerts whenever someone crosses the laser beam. This is the exact kind of project that turns heads in exhibitions and can even evolve into a commercial product!
π§ What is a Laser Security System?
A laser security grid uses a laser beam as a tripwire. The LDR continuously senses the laser light. When someone walks in front of the laser, the beam breaks, and the system detects the sudden drop in light — triggering an intruder alert.
It is:
✔ Simple
✔ Accurate
✔ Low-power
✔ Perfect for home doors, cupboards, lockers, labs, etc.
π Components Required
Component Quantity Purpose
ESP32 Board 1 Brain of the system
OLED Display (I2C, 0.96") 1 Shows system messages
LDR Sensor 1 Detects laser light
10K Resistor 1 Forms voltage divider with LDR
Laser Module 1 Provides continuous beam
Jumper Wires — Connections
π Circuit / Wiring
LDR Wiring
LDR ---- A0 (GPIO 34)
Other LDR pin ---- 3.3V
10K resistor between A0 and GND
OLED Wiring
VCC → 3.3V
GND → GND
SDA → GPIO 21
SCL → GPIO 22
Laser Module
VCC → 3.3V or 5V
GND → GND
π§Ύ Final ESP32 Code (Offline System)
Copy & Upload – No WiFi Needed
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define LDR_PIN 34 // Analog input pin for LDR
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("OLED not found");
while(1);
}
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10, 20);
display.println("System ON");
display.display();
delay(2000);
}
void loop() {
int ldrValue = analogRead(LDR_PIN);
Serial.println(ldrValue);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0,0);
display.println("Laser Security Grid:");
display.setTextSize(2);
display.setCursor(0,30);
if (ldrValue > 2000) { // Laser detected – value high
display.println("SAFE");
} else { // Laser interrupted – value drops
display.println("INTRUDER!");
}
display.display();
delay(200);
}
π§ͺ How Does It Work?
π΄ The laser continuously shines at the LDR.
π’ When someone crosses the path, the light is blocked.
⚡ ESP32 detects this instant change and displays:
INTRUDER!
on the OLED screen. No false triggers, no delays.
π― Why This Project Is Special
Feature Reason
Offline Works even without internet
Low Power Uses only ESP32 + LDR
Expandable Add buzzer, WiFi alerts, camera later
Professional Looks like a commercial-grade system
You can upgrade this into:
1) A wireless IoT alarm system
2) A mobile notification system
3) A laser-based tripwire grid
4) A smart home security module
π Conclusion:
With just one evening of work, you've built a real, working laser security system worthy of any tech exhibition or science fair. The ESP32 makes it compact, the OLED display makes it professional, and the LDR makes it accurate.


Comments
Post a Comment