ESP ZeroCode AI · Community

Wiring diagram for Real Time Person Detection

Real Time Person Detection

Detect and notify if there is a person in front of the camera

ESP32-S3 ml
Download the firmware Open-source licences Fork it in the studio

What it does

Manual

Device Type
Standalone person detection camera with local ML inference and LED notification

Problem Solved
Provide real-time, always-on person detection in a room without requiring cloud connectivity or external services

Hardware
chip: ESP32-S3 — board: ESP32-S3-EYE — camera: OV2640 2MP camera (onboard) — led: Built-in status LED for person detection notification — power: USB or DC adapter (mains powered, no battery) — gpios: LED on GPIO 3 (onboard status LED) — usb: USB-to-Serial for console logging (development/diagnostics)

Inputs
kind: Camera — label: OV2640 camera sensor — hardware: Onboard camera on ESP32-S3-EYE — behavior: Continuous video feed (max 320x240 or 640x480, auto-selected) captured and processed by ML inference pipeline for person detection at ~3 FPS. No external control needed.

Outputs
kind: LED — label: Person detection indicator — hardware: GPIO 3 (built-in status LED) — behavior: State-dependent LED behavior: (1) STARTUP: 3 blinks at 200ms on/off; (2) DETECTING: LED off (no person); (3) PERSON_DETECTED: LED blinks at 1 Hz (500ms on/off); (4) COOLDOWN: LED off (3 seconds after person leaves) · kind: USB Console — label: Debug output — hardware: USB serial interface (via onboard USB-to-serial) — behavior: Logs detection events (timestamp, confidence, state transitions) and diagnostic info. Output for development and troubleshooting only; not required for operation.

Commissioning
method: None — standalone device (no pairing, no network configuration) — instructions: 1. Power on via USB/DC adapter. Device shows 3 LED blinks (startup acknowledgment). 2. Device enters DETECTING state and begins continuous person monitoring. 3. LED will blink at 1 Hz whenever a person is detected in frame with >60% confidence. 4. After person leaves, device waits 3 seconds (COOLDOWN) before re-arming. 5. To view diagnostics, connect USB cable and monitor serial console (USB CDC or UART).

Business Logic
stateMachine: STARTUP: description: Device initialization and warmup — ledBehavior: Blink 3 times (200ms on, 200ms off per blink) — duration: ~1.4 seconds (3 × (200ms on + 200ms off) + gaps) — cameraInit: Camera ISP initializes, first frames may be discarded — nextState: DETECTING — DETECTING: description: Continuous monitoring for person — ledBehavior: LED off — inference: Run Plumerai model @3 FPS on camera frame — confidenceThreshold: 60% minimum for person classification — transitionToPERSON_DETECTED: When confidence > 60% — staysInState: While no person detected or confidence stays below 60% — PERSON_DETECTED: description: Person in frame above threshold — visual notification active — ledBehavior: Blink at 1 Hz (500ms on, 500ms off) — inference: Continue Plumerai model @3 FPS — logging: Log detection event with confidence score (optional, via USB console) — transitionToCOOLDOWN: When confidence drops below 60% — COOLDOWN: description: Post-detection quiet period — prevents rapid on/off flickering — ledBehavior: LED off — duration: 3 seconds fixed — ignoresDetections: true — inference: Continue Plumerai model @3 FPS (results ignored during cooldown) — nextState: DETECTING (after 3s timer expires) — powerOnBehavior: Power applied → STARTUP (3 LED blinks, ~1.4s) → DETECTING (continuous inference) — dayToDayOperation: Camera continuously monitors scene. When person detected (>60% confidence), LED blinks to provide immediate visual feedback. After person leaves, device waits 3 seconds before re-arming, preventing rapid on/off flickering and false triggers from transient movement. — detectionThreshold: 60% confidence minimum for person classification (using Plumerai model); tunable via firmware recompile if needed — cooldownPeriod: 3 seconds after person leaves before device can trigger next detection event — inferenceRate: ~3 FPS (333ms per frame); provides responsive detection while maintaining moderate CPU load — mlModel: Plumerai people-detection model (166 kB RAM, ~3 FPS inference speed, trained on 30 million images, detects up to 20 people, works indoors/outdoors in low light)

Diagnostics
loggingMethod: USB serial console (115200 baud default) — loggedEvents: Power-on and STARTUP sequence · State transitions (DETECTING → PERSON_DETECTED → COOLDOWN → DETECTING) · Detection events with timestamp, confidence score, number of people detected · Inference performance metrics (frame time, model latency) · Camera ISP and sensor diagnostics — purpose: Development, troubleshooting, and performance analysis. No production logging to persistent storage (SD card logging deferred).

Failure Modes
scenario: Power loss — behavior: Device stops immediately; LED turns off. Upon power restoration, restarts from STARTUP state with 3-blink pattern. · scenario: Camera malfunction or misalignment — behavior: LED remains off; no detection occurs. Model receives corrupted/dark frames but continues running (no crash). User should check camera ribbon cable connection or remove physical obstruction. · scenario: No person in frame — behavior: Device remains in DETECTING state, LED off, continuously monitoring. No false positives due to 60% confidence threshold. · scenario: Multiple people — behavior: Plumerai model detects up to 20 people simultaneously. Single person or crowd triggers same LED blink response (no differentiation). · scenario: Extreme lighting conditions (very dark or glare) — behavior: Model may fail to detect person or report low confidence; LED remains off. Normal operation resumes when lighting improves. · scenario: Thermal throttling (sustained high load) — behavior: Device continues running; no automatic shutdown. Inference latency may increase slightly. No active thermal management beyond normal ESP32-S3 operation.

Custom Behavior
ML inference runs locally on-device using Plumerai model via ESP-IDF ML framework. No cloud connectivity, no external API calls, full privacy guarantee. Inference rate ~3 FPS (333ms per frame) provides responsive detection while balancing power and CPU load. LED blink patterns use direct GPIO control via timer/PWM (minimal overhead). Model is optimized for ESP32-S3 Xtensa vector instruction extensions (VSX/SIMD). Camera ISP and model inference share MCU resources in a cooperative task loop; no separate OS threads required for baseline operation. Thermal and power dissipation are inherent to mains-powered design (passive cooling sufficient for continuous operation).

Future Refinements
SD card logging option (for long-term event recording) · Adjustable confidence threshold via firmware update · Night mode or low-light optimization · Multi-person tracking or counting · Mounting guidelines and FOV documentation

Published 27 Oct 2026
Firmware and source licensed Apache-2.0; photos and text CC-BY-4.0.
The firmware includes open-source software — open-source licences and notices; some components may be used only with Espressif chips.
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy