Function: what the HC-SR501 does in a circuit
Senses a warm body moving in front of it and sets its OUT pin HIGH (3.3 V).
- Detects a warm body that moves
- Gives a HIGH signal while it senses motion
- Switches lights and alarms on when someone enters
HC-SR501 key facts
| Type | HC-SR501 passive infrared sensor |
|---|---|
| Supply | 4.5 V to 20 V |
| Output | 3.3 V HIGH when it sees motion, 0 V otherwise |
| Range | up to about 7 m across about 110° |
| Hold time | about 3 s to 5 min (adjustable) |
| Warm-up | about 1 minute after power-on |
HC-SR501 pinout
The legs from left to right, as the part is drawn in the simulator:
| No. | Name |
|---|---|
| 1 | VCC |
| 2 | OUT |
| 3 | GND |
How to connect the HC-SR501 to an Arduino
Connect VCC to 5V, GND to GND and OUT to a digital pin.
Example sketch:
void setup() {
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, digitalRead(2)); // LED on while motion is seen
}Run this in the free simulator
How it works
Warm objects give off infrared light. Behind the white dome is a pyroelectric crystal with two halves. When a person walks past, one half sees them slightly before the other, the difference makes a small voltage, and the module turns it into a clean HIGH on OUT. The faceted dome (a Fresnel lens) gathers infrared from a wide area. Wire VCC to 5V, GND to GND and OUT to a pin, then digitalRead it.
What it is made of
- Sensor: Pyroelectric crystal such as lithium tantalate in a metal can LiO
- Dome: Polyethylene Fresnel lens, see-through for infrared CH
- Board: Glass-fibre and epoxy with copper tracks CuSn
Where the materials come from: Lithium from brine lakes in South America and rock in Australia; tantalum from the mineral coltan (Central Africa, Australia, Brazil).
The chemistry
A pyroelectric crystal changes how its charges line up when its temperature changes, so heating it a tiny amount makes a voltage across its faces.
Biology connection
Some snakes (pit vipers, pythons) have pit organs that sense infrared from warm prey in the dark, a natural PIR sensor. Nerve impulses →
Safety and the environment
A real HC-SR501 needs about a minute to settle after power on, keeps OUT HIGH for a few seconds after movement (set by its orange knobs) and can be fooled by heaters or sunlight.
Did you know? PIR stands for Passive InfraRed: it sends nothing out, it only listens for the infrared that warm things already give off.
Electromagnetic spectrumStar colours and temperatures Elements inside: LiOCHCuSn
Try it in the simulator
Add it in Free build: VCC to 5V, GND to GND, OUT to pin 2. Light an LED when digitalRead(2) is HIGH, then tap the sensor while the simulation runs to make someone walk past.
Questions students ask
What does the HC-SR501 do?
Senses a warm body moving in front of it and sets its OUT pin HIGH (3.3 V). Main functions: detects a warm body that moves; gives a HIGH signal while it senses motion; switches lights and alarms on when someone enters.
Why does my PIR sensor stay HIGH for several seconds?
That is its hold time. After it sees motion the HC-SR501 keeps its output HIGH for a few seconds to several minutes, set by one of the two orange trimmers. It also needs about a minute after power-on before its readings are reliable.
What are the connections of the HC-SR501?
In order: VCC, OUT, GND.
How do I connect the HC-SR501 to an Arduino?
Connect VCC to 5V, GND to GND and OUT to a digital pin.
How does the HC-SR501 work?
Warm objects give off infrared light. Behind the white dome is a pyroelectric crystal with two halves. When a person walks past, one half sees them slightly before the other, the difference makes a small voltage, and the module turns it into a clean HIGH on OUT. The faceted dome (a Fresnel lens) gathers infrared from a wide area. Wire VCC to 5V, GND to GND and OUT to a pin, then digitalRead it.
What is the HC-SR501 made of?
Sensor: Pyroelectric crystal such as lithium tantalate in a metal can. Dome: Polyethylene Fresnel lens, see-through for infrared. Board: Glass-fibre and epoxy with copper tracks.
Is the HC-SR501 safe? How should it be recycled?
A real HC-SR501 needs about a minute to settle after power on, keeps OUT HIGH for a few seconds after movement (set by its orange knobs) and can be fooled by heaters or sunlight.
More sensors
Connected tools
The same idea from another angle, across the site.