Most DIY security systems either generate false alarms or depend heavily on cloud processing. This project builds a privacy-first, offline intrusion detection system using Edge AI.
It combines:
- PIR motion sensing (cheap + fast trigger)
- Computer vision (AI) for verification
π Result: Accurate + fast + no internet required
π― Features- Real-time human detection (<200 ms inference)
- No cloud / no data leakage
- Snapshot capture on detection
- Audible alert system
- Expandable (Telegram, email alerts, etc.)
- VCC β 5V
- GND β GND
- OUT β GPIO17
- β GPIO27
- β GPIO27
- β β GND
- Connect via CSI ribbon cable
- Plug into USB 3.0 port
[PIR Trigger]
β
[Capture Image]
β
[AI Model (Edge TPU)]
β
[Person Detected?]
β YES β NO
[Alert] [IgnoβοΈ Software Setup1. Install OS- Flash Raspberry Pi OS (64-bit)
sudo apt update
sudo apt install python3-pip
pip3 install opencv-python numpy pillow
3. Install Coral TPU Runtimeecho "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
sudo apt update
sudo apt install libedgetpu1-stdπ¦ Download ModelUse precompiled model:
mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite
import cv2
import time
import RPi.GPIO as GPIO
from pycoral.adapters import common
from pycoral.adapters import detect
from pycoral.utils.edgetpu import make_interpreter
# GPIO setup
PIR_PIN = 17
BUZZER_PIN = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR_PIN, GPIO.IN)
GPIO.setup(BUZZER_PIN, GPIO.OUT)
# Load model
interpreter = make_interpreter('model.tflite')
interpreter.allocate_tensors()
cap = cv2.VideoCapture(0)
def alert():
GPIO.output(BUZZER_PIN, True)
time.sleep(1)
GPIO.output(BUZZER_PIN, False)
while True:
if GPIO.input(PIR_PIN):
print("Motion detected!")
ret, frame = cap.read()
if not ret:
continue
_, scale = common.set_resized_input(
interpreter, (frame.shape[1], frame.shape[0]), lambda size: cv2.resize(frame, size)
)
interpreter.invoke()
objs = detect.get_objects(interpreter, 0.5, scale)
for obj in objs:
if obj.id == 0: # person class
print("Human detected!")
cv2.imwrite("intruder.jpg", frame)
alert()
break
time.sleep(0.5)π Future Improvements- Telegram alerts
- Face recognition
- Night vision optimization
- Battery backup
- Web dashboard
11 projects β’ 5 followers
Firmware Engineer specializing in embedded systems, MCU programming, and hardware-software integration.












Comments