LCENJ PIR / HC-SR501 examples - 2026-09-09
Original example code: CC0-1.0. No third-party library required.
Put each .ino in a SEPARATE folder with the SAME basename.
Targets: classic ESP32 (PIR GPIO27, external LED GPIO26) and Arduino Uno (PIR D2, external LED D8).
Check the pinout on your actual board. These ESP32 pins are not universal across ESP32-C3/S3 variants.
PIR VCC: regulated 5V for a compatible HC-SR501 module. Common GND.
OUT must be 3.3V-compatible for ESP32; never connect an unverified 5V signal directly.
Suggested external LED circuit: GPIO -> 1k resistor -> LED anode; cathode -> GND.
Add external 100k pulldown from PIR input to GND. Do not enable a 5V pullup.
Use only low-voltage DC for this educational test. No mains, motor, relay coil or lamp directly on GPIO/OUT.
Serial: 115200 baud. Main sketch ignores first 60s, then requires 1s LOW to arm.
50ms stable-input filter and 5s LED hold are application settings, not sensor specifications.
H/L jumper controls hardware retriggering. Set hardware hold to a short value for testing.
PIR_LOW is not proof of an empty room; events are not a people count.
Raw diagnostic prints uptime_ms,signal every 100ms including startup.
Software compile checks do not replace physical hardware testing. No physical test performed.
