A Dual-Board Smart Security + Camera System with PIR, Thermal Imaging, ToF, Web UI & FreeRTOS
Home security systems are getting smarter every year — but building one yourself teaches you more than any commercial device ever could.
In this post, I’m excited to share a project I built using STM32 + ESP32 that acts as a dual-board burglar alarm system capable of detecting motion, confirming intruders via thermal imaging, capturing photos, logging alerts, and triggering a web-based alarm dashboard.
This is not just a buzzer-when-someone-walks-in system — it uses multiple sensors + confirmation logic so that every alarm is meaningful, not just a false trigger.
System Summary
- STM32 handles motion detection using a PIR sensor
- ESP32 receives motion events → confirms using AMG8833 thermal camera
- VL53L1X monitors distance to detect tampering
- ESP32-CAM module captures images & stores them
- Real-time web dashboard shows alarm status + last captured image
- OLED display shows ARM/DISARM mode
- Buzzer alerts for intrusion/tamper events
- FreeRTOS for smooth multitasking & event handling
Architecture Overview
PIR (STM32) → Digital Pulse → ESP32
↓
AMG8833 Thermal Camera confirms intrusion
↓
Camera Capture + Buzzer Alert + Web Log Entry
↓
VL53L1X monitors distance to detect tampering
↓
OLED displays system status in real-time
Features
Feature Description
STM32 PIR Motion Detection Sends HIGH pulse → PB4 to ESP32 GPIO
Thermal Intrusion Confirmation AMG8833 ensures valid intruder heat signature
Tamper Detection VL53L1X ToF sensor monitors distance changes
Camera Snapshots Saved to SPIFFS on intrusion/tamper
Buzzer Alerts Different patterns for each event
OLED Display ARMED / DISARMED system status
Web Interface Alerts, logs, photos, status
FreeRTOS Multitasking Stable, non-blocking sensor + camera operation
Hardware Required
STM32F4 board (PIR Motion → PA8, Output → PB4)
ESP32 Development Board
AMG8833 Thermal IR Camera
VL53L1X Time of Flight Sensor
OV3660 / ESP32-CAM
SSD1306 OLED Display
Buzzer + Breadboard + Wires + Power Supply
Pin Configuration
Board Component Pin
STM32 PIR Input PA8
STM32 Motion Signal Output PB4 → ESP32 GPIO 13
ESP32 PIR Input from STM32 GPIO 13
ESP32 Buzzer GPIO 12
ESP32 AMG8833 SDA / SCL 14 / 15
ESP32 VL53L1X Shared I2C
ESP32 OLED Shared I2C
ESP32-CAM Camera OV3660 Mapping (see code)
Setup Instructions
Clone the repo:
git clone https://github.com/yourusername/Burglar-Alarm-System.git
cd Burglar-Alarm-System/Final_System_Prototype/RTOS_Buglar_Alarm_System
open RTOS_Buglar_Alarm_System.ino in Arduino IDE → Compile
For STM32 code:
cd ..
open communication directory in STM32CubeIDE → Compile
Flash .bin file to STM32 board
Connect STM32 PB4 → ESP32 GPIO13
Power both boards & open ESP32 Serial Monitor
Access the web dashboard using ESP32 IP address
System Workflow
- PIR detects motion ⟶ STM32 sends HIGH pulse (PB4)
- ESP32 reads pulse ⟶ Thermal camera validates intruder
- If confirmed: → Camera capture → Log event + photo to web dashboard → Buzzer alarm triggered
- VL53L1X monitors for device tampering
- OLED always displays ARMED / DISARMED state
FreeRTOS Task Breakdown (ESP32)
Task Function
Task_PIR_AMG Reads STM32 PIR → validates with AMG8833
Task_TOF Detects tampering via VL53L1X
Task_Camera Handles image capture & storage
Task_Buzzer Alarm patterns (intrusion/tamper)
Task_OLED Real-time screen updates
Important Notes
STM32 PB4 → ESP32 GPIO13 must be 3.3V compatible
ESP32 checks PB4 every 100ms
NTP time sync gives accurate event timestamps
Reduce false positives using AMG thermal validation
Top comments (0)