The Smart Motion Detection System is an advanced IoT solution that leverages YOLO11n pose estimation to detect and analyze human movement patterns in real-time. Unlike traditional motion detectors that rely on simple pixel changes, this system performs sophisticated skeletal analysis (17 keypoints) to distinguish between meaningful human activity and environmental noise. Integrated with EMQX Cloud via secure MQTT, it enables precise automated control of smart home devices like lamps and fans with sub-second latency.
Tech Stack
Python
YOLO11-Pose
OpenCV
MQTT
Raspberry Pi
EMQX Cloud
Tools Used
VS Code
Raspberry Pi 5
Mosquitto
Git LFS
Key Features
Intelligent Motion Analysis
▸Advanced Pose Detection: YOLO11n-based skeleton tracking with 17 keypoint analysis for human activity recognition.
▸Smart Movement Filtering: Intelligent algorithms to distinguish between meaningful motion and environmental noise (pets, shadows).
▸Stability Analysis: Multi-frame pose stability verification using normalized motion calculation independent of frame position.
Smart Device Integration
▸Multi-Device Control: Automated GPIO-level control for lamps, fans, and relays with precise state management.
▸Operation Modes: Support for Automatic (motion-based), Manual (remote override), and Scheduled control modes.
▸Intelligent Auto-Off: Highly configurable delay logic that turns off devices only when sustained inactivity is verified.
IoT Connectivity
▸Secure MQTT Communication: SSL/TLS encrypted messaging via EMQX Cloud for cross-network device orchestration.
▸Remote Command API: Standardized JSON topic structure for status updates, sensor events, and remote configuration.
▸Dynamic Updates: Remote parameter tuning for thresholds and cooldowns without requiring system restarts.
Performance Monitoring
▸Real-time Analytics: On-screen FPS counters and movement pattern visualizations for system health monitoring.
▸Edge Optimization: Tailored for Raspberry Pi 5 with buffer management and efficient deque structures for history data.
▸Error Handling: Comprehensive logging system and automatic MQTT reconnection logic for 24/7 uptime.
Highlights
Skeletal 17-Keypoint Tracking
Secure SSL/TLS MQTT
Raspberry Pi 5 Optimization
Installation
Hardware Setup
Raspberry Pi 5 (4GB recommended)
USB Camera (640x480+)
Relay Modules for GPIO Pin 26 (Lamp) and 19 (Fan)
# Edit MQTTConfig in AIoT-dmouv2025.py
BROKER = "your-emqx-node.emqxsl.com"
PORT = 8883 # Use SSL
Challenges & Solutions
Challenge
Environmental Pixel Flutter
Solution
Moved away from frame-differencing to skeletal pose estimation, ensuring that only validated human keypoint movements trigger device actions.
Challenge
IoT Latency in Unstable Networks
Solution
Implemented an asynchronous Paho-MQTT client with local state caching, allowing the system to continue local processing during brief connectivity drops.
Challenge
Hardware Resource Constraints
Solution
Optimized model inference using the YOLO11n-pose variant and limited frame resolution to 640x480, achieving stable 30+ FPS on Raspberry Pi gear.