A real-time, low-latency intrusion detection system using Fog/Edge computing principles on an ESP32. This project avoids the latency and reliability issues of cloud-only systems by processing sensor data locally.
Traditional smart security systems rely on sending all sensor data to the cloud for processing. This approach has critical flaws:
- High Latency: The round-trip (Sensor -> Cloud -> User Alert) can take several seconds, which is too long for a security event.
- Poor Reliability: If your internet connection fails, the entire security system is blind.
- Bandwidth Waste: Constantly streaming data 24/7 (even "no motion detected") wastes bandwidth and energy.
This system moves the "intelligence" to the edge (the "Fog"), right where the sensors are.
- The Fog Node (ESP32): The ESP32 processes data from the PIR and LDR sensors instantly. It makes decisions locally, in milliseconds.
- The Cloud (Blynk): The cloud is only used for what it's best at: receiving critical alerts (e.g., "Intrusion Detected!") and displaying the system status on a global dashboard.
This hybrid model gives you the best of both worlds: the instant response of a local system and the global accessibility of a cloud app.
- Low-Latency Alerts: Local processing provides near-instantaneous alerts (~5-10ms) vs. seconds for cloud-only systems.
- High Efficiency: Reduces network traffic by over 99% by only sending critical alerts, not constant data streams.
- Sensor Fusion: Combines a PIR (motion) and LDR (light) sensor. An alert is only triggered if motion is detected and it's dark, reducing false positives.
- Offline Functionality: The core security logic works even if the internet is down.
- Global Dashboard: Uses the Blynk platform to send mobile notifications and display real-time sensor status from anywhere.
- ESP32 Microcontroller
- HC-SR501 PIR Motion Sensor
- LDR (Light Dependent Resistor)
- 10kΩ Resistor
- Breadboard and Jumper Wires
-
Clone this Repository:
git clone [https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git](https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git)
-
Set up Hardware:
- Wire the components according to the circuit diagram (see
diagram.jsonor the project report). - PIR Sensor:
VCC->3V3,GND->GND,OUT->GPIO 27 - LDR Sensor:
VCC->3V3,GND->GND,AO(with 10k pulldown) ->GPIO 34
- Wire the components according to the circuit diagram (see
-
Configure Software:
- Open
sketch.inoin the Arduino IDE. - Install the ESP32 board definitions and the
BlynkSimpleEsp32library. - Set up a new project in the Blynk app to get your Auth Token.
- Update the
sketch.inofile with your credentials:#define BLYNK_AUTH_TOKEN "YOUR_BLYNK_TOKEN" char ssid[] = "YOUR_WIFI_SSID"; char pass[] = "YOUR_WIFI_PASSWORD";
- Open
-
Deploy:
- Connect your ESP32 to your computer.
- Select the correct board and port in the Arduino IDE.
- Click Upload.
- Open the Serial Monitor to watch it connect, and use the Blynk app to monitor the system.
/sketch.ino: The main Arduino code for the ESP32./diagram.json: The circuit diagram for the Wokwi simulator./project_report.pdf: The full academic report for this project./README.md: This file.
- Integrate a camera (like an ESP32-CAM) for local image verification.
- Implement a TinyML model to distinguish between a person and a pet.
- Add a deep-sleep mode to optimize for battery power.