How to Use a PIR Motion Sensor (AM312 and HC-SR501)
Share
A PIR (passive infrared) sensor works by watching a pyroelectric element for changes in the infrared radiation crossing its field of view, not by measuring heat directly. A Fresnel lens splits that field into multiple zones, so a warm body moving through the room shifts from one zone to the next and produces a rising and falling IR signal; a person or object that stays still radiates heat too, but that signal is flat, so the sensor's comparator ignores it. This is why the sensor is called passive — it emits nothing and only reacts to change — and it is also why a person sitting motionless at a desk can eventually stop triggering the output even though they are still warm and still in the room.
AM312 vs HC-SR501: what's actually different?
Both parts do the same job with the same three pins — power, ground, and a digital output that goes HIGH on motion — so the electrical interface is identical. The differences are in size, adjustability, and power budget. The AM312 is a tiny mini-PIR module, often barely larger than its own lens, with a fixed detection range around 5-6 meters and a fixed pulse/delay time baked into the board; there are no potentiometers to turn. That fixed behavior comes with a real advantage: very low standby current, which is why the AM312 class of sensor shows up in battery-powered and wearable projects. The HC-SR501 is the larger, classic PIR module everyone has seen in tutorials: a domed lens on a board with two trimmer potentiometers (one for sensitivity/range, one for how long the output holds HIGH after a detection) and a retrigger jumper that chooses between a single pulse per detection and continuous HIGH for as long as motion persists. Its range is longer, typically up to about 7 meters, and it draws more standby current than the AM312 because of that extra circuitry.
Which one should you pick for your project?
Pick the AM312 (or a mini-PIR in its class) when the project is compact, battery-powered, or wearable — a coin-cell night light, a PIR that needs to sip current for months, or a build where board space is tight and you don't want to tune anything. Pick the HC-SR501 when you actually need the tuning: a room light that should stay on for a specific number of seconds, a security build where you want to dial in sensitivity to avoid false triggers near a window, or any project you're documenting for someone else, since it's the most commonly referenced PIR module and easiest to find wiring examples for. Neither part is weatherproof; both are indoor modules unless housed separately.
How do you wire either one to an Arduino Uno?
Both sensors use the same three-pin layout — VCC, GND, and a digital OUT pin — so the wiring is identical regardless of which one you use: OUT to any Arduino digital pin, VCC to a supply pin, GND to ground, then a single digitalRead() in firmware. The one thing worth checking before you power either one up is supply voltage: AM312-class mini modules typically run on 3.3-6V, while the HC-SR501 accepts a much wider 4.5-20V range. Confirm the voltage printed on the specific module you have rather than assuming, since mini-PIR breakouts vary by manufacturer. On both, the OUT pin's logic-high level reads correctly on the Uno's 5V-logic digital inputs without a level shifter in practice.
Why do PIR sensors need a warm-up period?
Right after power-on, a PIR sensor's pyroelectric element needs roughly 30-60 seconds to stabilize against the room's ambient infrared baseline. During that window it is common to see false triggers or an output stuck HIGH, which is often mistaken for a faulty sensor. This applies to both the AM312 and the HC-SR501 — give either one the full warm-up window, away from moving curtains, direct sunlight, or HVAC vents (all of which shift infrared levels without any person moving), before judging whether it's working correctly.
Watch it built live
We typed one real comparison question into Compoden's AI build assistant on the storefront and let it answer unscripted:
"I want to compare the AM312 mini PIR sensor and the HC-SR501 PIR sensor for a motion-detecting project with an Arduino Uno"

The assistant gave a straight electrical comparison first: "Both are the same thing electrically — passive infrared with a 3-pin digital output — so your Uno build sees them identically: power, ground, one digital pin, digitalRead. The real differences are range, adjustability, and power draw." On the HC-SR501, which Compoden stocks directly, it noted: "Detection range 3-7m with an onboard sensitivity pot, plus a second pot for hold time (seconds to minutes). Wide supply range (4.5-20V), quiescent draw under 50µA."
On the AM312 specifically, it was upfront about a real catalog gap rather than inventing stock that doesn't exist: "AM312 — not in the catalog yet; the closest thing we carry in that niche is the HC-SR505 Mini PIR. That's the 'tiny, set-and-forget' class: ~3m range, 100° cone, fixed 8-second pulse with no pots to fiddle with, runs on 3-15V, and standby current is negligible — the right pick for a battery-powered night light or a compact alarm." Its recommendation for a first build matched the guidance above: "For a first motion project on the Uno, I'd take the HC-SR501: the adjustable delay is the feature you'll actually use... Go the mini route only if the build is battery-powered, space-constrained, or you want zero calibration."
Watch the firmware get generated
Separately, we asked Compoden's build companion, Soldr, to generate the actual sketch for reading a PIR sensor's digital output on an Arduino Uno:

Soldr picked a full parts tray for the build — an Arduino Uno, the HC-SR501 (the one of the two we stock), a mini breadboard, jumper wires, and a power adapter — and generated firmware defining PIR_SENSOR_PIN on digital pin 2, with pinMode(PIR_SENSOR_PIN, INPUT) in setup and a serial print firing when the pin reads HIGH, matching the sensor's simple digital-output behavior described above. No sensor-specific library is used, since a plain digital read is all either the AM312 or the HC-SR501 needs.
Get everything in this build
The five parts Soldr picked for the HC-SR501 build above, at today's live Compoden price — each links straight to checkout, or add the whole tray in one click. Compoden does not currently stock the AM312 itself; if your project calls for that compact, low-power class of PIR instead, the HC-SR505 Mini PIR Module (₹75) is the closest in-stock equivalent.
| Part | Price | |
|---|---|---|
| Arduino Uno R3 CH340G ATmega328P Board | ₹230 | Add to cart → |
| HC-SR501 PIR Motion Sensor Module | ₹70 | Add to cart → |
| 170-Point Mini Breadboard SYB-170 White | ₹20 | Add to cart → |
| Breadboard Jumper Wires – 65pcs Male-to-Male 20cm | ₹110 | Add to cart → |
| 5V 2A Adapter (Barrel Connector), 10W | ₹170 | Add to cart → |
| Total | ₹600 | Add all 5 to cart → |
Prices and stock verified live at the time this was written; Compoden's storefront always reflects the current price at checkout.
Built and Backed by Compoden
Every part above ships from Compoden's own India stock, checked for compatibility as a set rather than sourced piecemeal. Delivery in 3-7 days across India, with COD and UPI available at checkout. If a part in this build doesn't perform as described, Compoden's support team will help you troubleshoot or replace it.
FAQ
Does Compoden sell the AM312?
Not currently. Compoden stocks the HC-SR501 directly; for the compact, fixed-timing, low-power class of PIR that the AM312 represents, the closest in-stock module is the HC-SR505 Mini PIR.
Is the AM312 a drop-in replacement for the HC-SR501?
Electrically yes — both give a 3-pin digital HIGH/LOW output that reads the same way in firmware. Functionally no: you lose the sensitivity and delay adjustment and get a shorter range in exchange for a much smaller footprint and lower standby current.
Can I power an AM312-class sensor directly from an Arduino Uno?
Usually yes, but check the module's printed voltage rating first. Mini-PIR modules in the AM312 class commonly run on 3.3-6V, which the Uno's 5V pin can supply, but this varies by manufacturer, so confirm rather than assume.
Why does a stationary person eventually stop triggering a PIR sensor?
Because the sensor detects change in infrared radiation, not the presence of heat itself. A body that stops moving still radiates heat, but that heat signature becomes flat rather than crossing the sensor's zoned field of view, so the output can drop back to LOW even though someone is still in the room.