DEV Community

Hedy
Hedy

Posted on

How do motion sensors detect motion?

Here’s the quick, practical rundown—by sensor type—of how motion sensors detect motion and what’s really going on inside.

1) PIR (Passive Infrared) — most common in rooms & lights

  • Principle: A pyroelectric element generates a tiny voltage when the infrared (heat) pattern changes across it. A Fresnel lens splits the view into zones; when a warm body moves between zones, the element sees a rising then falling IR signal.
  • Processing: AC-coupled, band-pass (~0.1–10 Hz) to ignore slow temperature drift and catch human motion; a comparator asserts “motion.”
  • Pros/Cons: Low power, cheap, doesn’t see through glass; line-of-sight only; false triggers from drafts/sunlight if aimed poorly.

2) Microwave radar (Doppler / FMCW, e.g., 5.8 GHz or 60 GHz)

  • Principle: Transmit CW or chirps; measure the frequency shift on the echo (Doppler: Δ𝑓≈2𝑣𝑓0/𝑐). Any moving target changes phase/frequency → motion.
  • Processing: Mix TX and RX to baseband (“I/Q”), filter for human-motion bands; FMCW/mmWave can estimate range and even micro-motions (breathing).
  • Pros/Cons: Works in the dark and through some materials (thin walls/plastic); more sensitive, but can overreach (detect motion outside a room).

3) Ultrasonic (active sonar)

  • Principle: Emit 40 kHz pings; watch echo time or Doppler. If distance or phase changes over time → motion.
  • Processing: Time-of-flight/phase comparison; threshold on change rate.
  • Pros/Cons: Good coverage, not light-dependent; reflections vary with fabrics/angles; drafts/fans can cause noise.

4) Vision (camera, thermal imager)

  • Principle: Frame differencing/optical flow—if enough pixels change between frames, flag motion. Thermal cameras do the same in long-wave IR.
  • Processing: Background modeling, filters, sometimes ML for people/pets.
  • Pros/Cons: Rich info (who/where), but power, privacy, and lighting matter (for visible).

5) Time-of-Flight (ToF) lidar / structured light

  • Principle: Measure distance per pixel; motion = distance map changing over time.
  • Processing: Per-pixel delta + clustering.
  • Pros/Cons: Works in the dark; short-range, costlier than PIR.

6) Magnetic/reed or Hall switches (doors/windows)

  • Principle: Detect magnet presence; “motion” = state change (open/close).
  • Pros/Cons: Binary, robust; only detects that one event.

7) Pressure mats / vibration (piezo, MEMS accelerometers)

  • Principle: Force or vibration change indicates footsteps or object movement.
  • Pros/Cons: Simple, local; prone to environmental vibrations.

Why many sensors combine tech

“Dual-tech” (e.g., PIR + microwave) requires both to trigger → far fewer false alarms (drafts trigger PIR, swaying plants trigger radar, but rarely both).

Output & integration (what you get electrically)

  • Digital: open-collector/relay or logic “motion” pin (PIR modules like HC-SR501; radar RCWL-0516).
  • Analog: some give I/Q or amplitude for custom processing (mmWave, ultrasonic).
  • MCU readout: poll a GPIO or use interrupts; add debounce/hysteresis (e.g., require signal > threshold for 100–300 ms).

Placement tips to reduce false triggers

  • Aim across likely paths (PIR zones are lateral-sensitive).
  • Keep PIR away from direct sun, HVAC vents, and windows.
  • For presence (someone sitting still), prefer mmWave or vision over PIR.
  • Pets: choose pet-immune PIR or set a lower microwave gain.

Quick chooser

  • Room lights, battery devices: PIR (lowest power).
  • Occupancy/presence (even subtle movement): 60 GHz mmWave or ultrasonic.
  • Outdoor or through partitions: Microwave radar.
  • Security video/people detection: Camera/thermal (+ analytics).
  • Doors/windows: Reed/Hall.

Top comments (0)