If you are building an automated lighting node, a security trigger, or a smart home occupancy sensor in 2026, the days of blindly slapping a $2 PIR module onto a breadboard are over. Modern microcontrollers like the ESP32 demand precise logic levels, and user expectations for "presence detection" have moved beyond simple movement triggers. Designing a robust motion detector sensor circuit requires matching the right sensing physics to your specific power budget and environment.

The Sensing Principle: Pyroelectric vs. mmWave Radar

Passive Infrared (PIR) sensors rely on a pyroelectric crystal that generates a temporary voltage when exposed to changing thermal radiation. When a warm human body moves across the sensor's segmented Fresnel lens, it creates a rapid delta in infrared flux, triggering the internal comparator. PIR circuits are entirely passive, drawing microamps in standby, but they are fundamentally blind to static targets; if you sit perfectly still reading a book, the lights will turn off.

Millimeter-wave (mmWave) radar sensors, operating at 24GHz or 60GHz, emit Frequency-Modulated Continuous Wave (FMCW) RF pulses and measure the phase shift of the reflected signal. This Doppler effect detects micro-movements down to the millimeter scale—including the rise and fall of a human chest during breathing. Unlike PIR, mmWave provides continuous presence detection and actual spatial distance data, making it the definitive standard for modern indoor occupancy circuits.

Output Signals: What You Actually Get

A common failure point in embedded projects is conflating digital triggers with analog waveforms. You must design your ESP32 input stage around the specific output type of your sensor:

  • Digital (Binary): Modules like the HC-SR501 or Panasonic EKMB output a simple logic HIGH (VCC) or LOW (GND). There is no scaling; the internal comparator handles the threshold. You read this with digitalRead() or an interrupt.
  • Analog (Voltage Waveform): Raw pyroelectric elements (like the Murata IRA series) or analog-out PIR modules output a fluctuating DC-biased voltage (e.g., 0.5V to 2.8V) representing the raw IR flux. This requires an ADC pin and software-based thresholding.
  • UART (Serial Data Frames): Advanced mmWave sensors (like the HLK-LD2410) stream hex-encoded data frames over TX/RX lines at 256kbps, containing target state, distance in centimeters, and gate energy percentages.

Wiring and Pinout Table (ESP32 Target)

The most frequent bench mistake is frying an ESP32 GPIO by feeding it 5V from a legacy PIR module. The ESP32 is strictly a 3.3V logic device. Furthermore, if you are reading an analog PIR signal, you must use an ADC1 channel (GPIO 32-39); ADC2 channels are disabled when the WiFi radio is active.

Sensor ModuleVCC (Supply Range)GNDSignal / DataESP32 Pin TargetLogic Level Note
HC-SR501 (Standard PIR)4.5V - 20VGNDOUT (Digital)GPIO 4 (via Logic Level Shifter)Outputs 5V HIGH. Requires voltage divider or optocoupler.
SR602 (Mini PIR)2.7V - 3.6VGNDOUT (Digital)GPIO 4 (Direct)Native 3.3V logic. Safe for direct connection.
HLK-LD2410 (mmWave)5V (via USB/VIN) or 3.3VGNDTX / RX (UART)GPIO 16 (RX) / GPIO 17 (TX)3.3V UART. Cross TX to RX.
Murata IRA + LM358 (Raw Analog)3.3VGNDOUT (Analog)GPIO 34 (ADC1_CH6)0-3.3V analog. Input only, no pull-up.
Callout Tip: Never power an HC-SR501 from the ESP32's 3V3 pin. The SR501's internal linear regulator requires a minimum of 4.5V to function. Power it from the 5V VIN pin, but use a bidirectional logic level shifter (like a BSS138 MOSFET circuit) on the OUT line before it hits the ESP32 GPIO.

Raw Reading to Physical Unit Math (Analog PIR)

If you are building a custom analog motion detector sensor circuit using a raw pyroelectric sensor and an op-amp (like the LM358), you aren't just looking for a HIGH/LOW trigger—you are measuring actual infrared flux changes. Here is the exact math to convert the ESP32's 12-bit ADC raw reading into a physical unit (Voltage, and subsequently estimated IR Power).

The ESP32 ADC maps 0-3.3V to a raw integer range of 0-4095. However, the ESP32 ADC is notoriously non-linear at the extremes. For precision, restrict your sensing window to the 0.1V - 3.1V range.

// Analog PIR Raw-to-Unit Conversion
const float V_REF = 3.3;       // ESP32 reference voltage
const int ADC_MAX = 4095;      // 12-bit resolution
const float RESPONSIVITY = 3500.0; // Sensor datasheet value (Volts per Watt)

void readAnalogPIR() {
  int raw_adc = analogRead(34); // GPIO 34 (ADC1)
  
  // Step 1: Convert Raw ADC to Voltage
  float v_out = ((float)raw_adc / ADC_MAX) * V_REF;
  
  // Step 2: Convert Voltage to Incident IR Power (Watts)
  // V_out = P_ir * Responsivity
  float p_ir = v_out / RESPONSIVITY;
  
  Serial.printf("Raw: %d | Voltage: %.3f V | IR Flux: %.6f W\n", raw_adc, v_out, p_ir);
  
  // Step 3: Software Thresholding for Motion Trigger
  // A typical human walking at 2m generates a delta of ~0.0005W
  if (abs(v_out - baseline_voltage) > 0.15) {
    Serial.println("MOTION DETECTED");
  }
}

Calibration, Scaling, and Interference

Every motion detector sensor circuit requires environmental tuning. A sensor that works perfectly on a quiet workbench will fail in a real room without addressing interference.

Calibration and Scaling

  • PIR Modules: Calibration is hardware-based. The two potentiometers on an HC-SR501 adjust the time delay (how long the OUT pin stays HIGH after motion stops) and sensitivity (the comparator threshold voltage). For software scaling, you must establish a "baseline voltage" on boot and measure the delta.
  • mmWave Radar: Calibration is done via UART commands or the manufacturer's BLE app. You must configure the "Max Detection Gate" (e.g., setting it to 4.5 meters so it ignores the hallway outside the room) and the "Trigger Threshold" per gate. (See the ncmreynolds LD2410 library for ESPHome/Arduino configuration payloads).

Common Interference Sources

  • For PIR: Direct sunlight hitting the lens, HVAC supply vents blowing hot air across the field of view, and small pets. Fix: Apply opaque electrical tape to the lower segments of the Fresnel lens to create a "pet alley" that ignores the floor.
  • For mmWave: Ceiling fans, vibrating HVAC pipes inside walls, and curtains moving in the breeze. Because 24GHz radar penetrates drywall, it will also detect people walking in the adjacent room. Fix: Use the radar's range-gate mapping to explicitly zero out the sensitivity at the distance where the drywall sits.

Decision Path: Which Sensor Circuit to Build?

Do not default to the cheapest module on Amazon. Use this decision matrix to select the exact hardware for your embedded project.

Project ConstraintIf your project requires...Then choose this technologySpecific Part Number
Battery / Solar PowerMicroamp standby current, wake-from-sleep interruptUltra-Low Power Digital PIRPanasonic EKMB1201112 (170° lens)
Through-Wall / ConcealedSensor hidden behind plastic enclosure or drywallMicrowave Doppler RadarRCWL-0516 (Analog/Digital out)
Basic Security TriggerSimple HIGH/LOW for a hallway alarm, mains poweredStandard 3.3V PIRSR602 (Mini PIR, 3.3V native)
Smart Home OccupancyStatic presence (sleeping/reading), distance data, HVAC automation24GHz mmWave FMCW RadarHi-Link HLK-LD2410
The Default Recommendation: If you are building a mains-powered ESP32 smart home node in 2026 and want to know which motion detector sensor circuit to standardize on, buy the HLK-LD2410. At roughly $6 USD, it completely eliminates the "lights turning off while I'm sitting still" problem that plagues PIR circuits. Wire its TX pin to ESP32 GPIO 16, use the ld2410 Arduino library to parse the UART frames, and configure the max gate distance to match your room dimensions. For battery-powered edge nodes where the LD2410's 70mA operating current is too high, fall back to the Panasonic EKMB series.