HC-SR501 PIR Motion Sensor

Trigger a light, a camera, or an alarm whenever a warm body moves nearby — pyroelectric sensors detect the heat signature, not visible motion.

Difficulty: Breadboard. Estimated build time: about 20 minutes. Estimated parts cost: about US$2.80. 5-line bill of materials. Compare supplier offers when available. A motion-activated trigger that fires a digital HIGH whenever a warm body crosses the sensor's field of view.

Power up and let it settle

The HC-SR501 takes a wide 4.5 to 20 V input on its VCC pin (an on-board regulator drops it to 3.3 V internally). Connect VCC to 5 V, GND to ground, and OUT to a free MCU GPIO. The very first time you power it up, the sensor needs about 60 seconds to thermally stabilise — you'll see the OUT line flicker high and low during this time as the pyroelectric element warms up. Don't wave your hand at it during this window; just leave it still.

Test with an LED before adding code

Wire OUT to an LED through a 220 ohm series resistor (cathode to ground) so you can see the output directly. Once the sensor has settled, walk past it; the LED should snap on for about 3 seconds (the factory time-delay setting) and then turn off. Adjust the two trim pots on the back of the module: the LEFT pot (Sx) raises sensitivity — turn fully clockwise for maximum range. The RIGHT pot (Tx) raises hold time — turn fully clockwise for several minutes of latched output, fully counter-clockwise for the shortest 3-second pulse.

Set the trigger mode and integrate it

Find the 3-pin jumper at the edge of the module. Slide it to the H position (repeatable trigger) for a constant-on output while motion is detected, or to the L position (single trigger) for one-shot pulses with a blocking dead time. From your MCU, read OUT with digitalRead and act on the rising edge: print a serial message, turn on a relay, snap an HC-SR04 photo, push an MQTT message, fire a webhook. For a small porch-light project, drive an IRLZ44N MOSFET that switches a 12 V LED strip — instant low-power smart light with no wireless, no app, and no subscription.