RisalDash RisalDash

Project · ESP32-CAM · Wildlife

A camera trap that shoots on motion

Commercial trail cameras start at $60. An ESP32-CAM plus a PIR sensor is under $10 and does the same core job: something warm moves, the camera wakes, a JPEG lands on the MicroSD — and unlike the commercial box, yours serves a live status dashboard you can check from a phone without opening the case.

ProjectESP32-CAMPIRWildlife
ESP32-CAM wildlife camera trap project: PIR motion trigger, MicroSD storage and live status

The trigger — PIR with a cool-down

An HC-SR501 sees a warm body and pulls its output high; the sketch fires one capture on the rising edge and then ignores the sensor for 5 seconds — otherwise one browsing deer becomes forty identical photos. The PIR's own sensitivity and hold-time pots do the coarse tuning:

#define MODE_TIMELAPSE 0        // 0 = PIR-triggered camera trap
#define PIR_PIN 13              // HC-SR501 OUT -> GPIO13

// loop(): shoot on motion, with a 5 s cool-down so one animal isn't 40 photos
bool pir = digitalRead(PIR_PIN);
if (pir && !motion && millis() - lastShot > 5000) {
  lastShot = millis();
  capture("Motion");            // JPEG -> /0042.jpg on the SD card
}
motion = pir;

The dashboard — check the trap without touching it

The whole point of a trap is leaving it alone. Walk within Wi-Fi range and the ESP's own access point tells you everything — shots taken, SD fill, whether the PIR is alive, and a capture log with one line per animal:

dash.layout("Trap", RICON_MOTION);
dash.stat("Photos", &shots, "");
dash.gauge("SD used", &sdUsedPct, 0, 100, "%").variant("bar");
dash.led("Motion", &motion);            // watch the PIR fire, live
dash.led("SD ready", &sdOk);
dash.button("Shoot", "Capture now", []() { capture("Manual"); });
evlog = &dash.log("Captures", 6);       // "Motion -> /0042.jpg"
dash.beginAP("RisalDash-CamTrap", "12345678");

The shipped sketch is examples/06_Projects/CamTrap with MODE_TIMELAPSE 0; the same build is the time-lapse camera with one define. Camera config follows the image-settings guide — SVGA at quality 10.

Field notes

ProblemFix
False triggers from sun-warmed leavesaim north, lower PIR sensitivity, longer cool-down
Night shots are blackthe OV2640 has no IR cut/illumination — add an IR LED board, or accept dawn/dusk only
Battery dies in daysdeep sleep + PIR on the wake pin; a 18650 or LiFePO4 pack
Wildlife chews the wiresa ziplock + junction box works; silica gel against fog

Same board, same sketch — flip one define for scheduled time-lapse instead.