An active sensor generates its own probing energy—acoustic, optical, or electromagnetic—and measures the reflection, phase shift, or time-of-flight to determine a physical property. Common examples in embedded systems include the HC-SR04 ultrasonic rangefinder, TF-Luna LiDAR, and RCWL-0516 microwave radar modules. A passive sensor, conversely, does not emit energy; it relies on ambient environmental energy or changes its intrinsic electrical properties (resistance, capacitance, or voltage) in response to a stimulus. Examples include NTC thermistors, light-dependent resistors (LDRs), photovoltaic cells, and pyroelectric infrared (PIR) modules like the HC-SR501.
For an Arduino or ESP32 designer, this distinction dictates your front-end circuit topology. Active sensors typically output a timed digital pulse, a PWM signal, or a calibrated serial stream (UART/I2C), meaning the microcontroller's digital GPIO or hardware timers do the heavy lifting. Passive sensors act as variable resistors or current sources, requiring you to build a voltage divider, a Wheatstone bridge, or a transimpedance amplifier to convert their physical state into an analog voltage that the MCU's ADC (Analog-to-Digital Converter) can sample.
Wiring Topologies and Supply Requirements
Interfacing these two sensor classes requires different power and signal conditioning strategies. Below is a benchmark comparison using the most common hobbyist and prototyping modules: the HC-SR04 (active ultrasonic) and a standard 10k NTC thermistor (passive temperature).
| Parameter | HC-SR04 (Active) | 10k NTC Thermistor (Passive) |
|---|---|---|
| Sensor Type | Active (Acoustic emission) | Passive (Resistive change) |
| Supply Range | 4.8V – 5.5V (5V nominal) | 3.3V or 5V (via divider) |
| Output Signal | Digital Pulse (5V TTL) | Analog Voltage (0 – Vcc) |
| MCU Pin Required | 2x Digital GPIO (Trig/Echo) | 1x ADC Pin |
| Signal Conditioning | Voltage divider on Echo pin for 3.3V MCUs | Series resistor to form voltage divider |
| Quiescent Current | ~15 mA (spikes to 20mA on ping) | ~165 µA (with 10k series at 3.3V) |
Output Signal Math: Raw Reading to Physical Units
The fundamental difference in firmware implementation lies in how we decode the output. Active sensors usually hand you a time-domain value, while passive sensors hand you an amplitude-domain value.
Active Sensor Math (Digital Pulse Width)
The HC-SR04 outputs a HIGH pulse on the Echo pin whose duration corresponds to the time-of-flight of the acoustic wave. The microcontroller's pulseIn() function captures this in microseconds (µs). Because the sound wave travels to the target and back, we must divide the time by two.
At 20°C, the speed of sound in dry air is approximately 343 meters per second, or 0.0343 centimeters per microsecond. The raw-to-unit math is:
// distance_cm = (pulse_duration_us / 2) * 0.0343
float distance_cm = (pulseIn(ECHO_PIN, HIGH) / 2.0) * 0.0343;
Passive Sensor Math (Analog Voltage to Resistance)
A passive NTC thermistor requires a voltage divider. Assuming a 3.3V supply, a 10kΩ series resistor (R_series), and the NTC connected to ground, the MCU's ADC reads a voltage proportional to the NTC's current resistance. First, convert the raw ADC reading (0-4095 on a 12-bit ESP32) to resistance:
// R_ntc = R_series * ((ADC_max / ADC_raw) - 1)
float R_ntc = 10000.0 * ((4095.0 / analogRead(ADC_PIN)) - 1.0);
Next, convert resistance to temperature using the Beta parameter equation (a simplified Steinhart-Hart equation). Assuming a nominal 10kΩ at 25°C (298.15K) and a Beta (B) value of 3950:
float T0 = 298.15; // 25°C in Kelvin
float B = 3950.0;
float temp_kelvin = 1.0 / ((1.0 / T0) + (1.0 / B) * log(R_ntc / 10000.0));
float temp_celsius = temp_kelvin - 273.15;
Calibration, Scaling, and Interference Sources
Getting a raw number is easy; getting an accurate, stable reading requires managing the physical realities of both sensor types.
Calibration and Scaling Needs
Active Sensors: The primary scaling error in ultrasonic and LiDAR sensors is environmental. The speed of sound changes with temperature (increasing by ~0.6 m/s for every 1°C rise). For precision active ranging, you must pair the HC-SR04 with a passive temperature sensor to dynamically adjust the 0.0343 constant in your math. Furthermore, active sensors require a "dead time" (blanking interval) where the receiver is deafened while the transmitter fires; failing to respect the module's minimum range (usually 2cm for HC-SR04) yields garbage data.
Passive Sensors: Passive resistive sensors suffer from manufacturing tolerances. A standard 10k NTC might have a ±1% to ±5% tolerance at 25°C, which translates to a ±0.5°C to ±2.5°C baseline error. High-precision applications require a two-point calibration (e.g., ice bath and boiling water) to derive custom Steinhart-Hart coefficients. Additionally, if you are using an ESP32 SAR ADC, you must account for its notorious non-linearity. The ESP32 ADC is highly inaccurate below 0.15V and above 2.6V. Design your passive voltage divider so the expected operating range falls squarely in the 0.5V to 2.2V sweet spot.
Common Interference Sources
Active Interference: Active sensors are prone to multipath echoes and cross-talk. If you mount two HC-SR04 modules facing each other or in a corner, the acoustic waves bounce unpredictably, causing phantom "short" readings. In multi-sensor arrays, you must fire them sequentially with a 50ms delay to prevent acoustic cross-talk. Optical active sensors (like IR obstacle avoiders) are easily blinded by ambient sunlight, which saturates the photodiode receiver.
Passive Interference: Because passive sensors rely on high-impedance analog voltage dividers, they act as antennas for electromagnetic interference (EMI). 50/60Hz mains hum from nearby AC wiring will induce noise on long, unshielded analog traces. Always place a 100nF ceramic bypass capacitor directly across the ADC input and GND at the microcontroller pin to filter high-frequency noise. Another insidious passive error is self-heating: if your series resistor is too small, the current flowing through the thermistor will heat it from the inside, skewing the reading high. Keeping the divider current under 500µA (as in our 10k/10k example) safely avoids this.
Frequently Asked Questions
Is a PIR motion detector considered an active sensor and passive sensor hybrid?
No, a standard PIR (Passive Infrared) module like the HC-SR501 is strictly a passive sensor. The term "passive" means the sensor itself does not emit any energy. A PIR module contains a pyroelectric crystal that generates a small voltage when it absorbs ambient infrared radiation (heat) emitted by a moving human body. It relies entirely on the target emitting the energy. An active motion sensor, by contrast, would be an active infrared break-beam or a microwave Doppler radar (like the RCWL-0516) that emits its own field and detects the reflection.
Why does my passive sensor ADC read fluctuate while my active sensor stays stable?
This comes down to signal domain and impedance. Active sensors output a digital square wave; the microcontroller's digital input buffer has a strict voltage threshold (e.g., anything above 2.0V is read as a clean HIGH). Minor noise on the line is ignored. Passive sensors output an analog voltage through a high-impedance resistive divider. The MCU's ADC samples this voltage by briefly connecting an internal sampling capacitor to the pin. If the source impedance is too high, or if there is no local bypass capacitor, the ADC will sample ambient electrical noise, resulting in jittery raw values. Adding a 100nF capacitor at the ADC pin and using a software moving-average filter will stabilize passive readings.
Can I wire an active sensor and passive sensor to the same ESP32 3.3V power rail?
You can, but you must manage the noise floor. Active sensors like ultrasonic transducers draw sudden, high-current spikes (up to 20mA for a few milliseconds) when they fire a ping. If both sensors share a thin, high-resistance 3.3V trace, this sudden current draw will cause a momentary voltage droop (brownout) on the rail. Because the passive sensor's voltage divider is referenced to that same 3.3V rail, the droop will instantly register as a false temperature or light spike on the ADC. To fix this, run separate 3.3V star-ground traces from the ESP32's voltage regulator to each sensor, and place a 10µF bulk decoupling capacitor near the active sensor's VCC pin to absorb the transient current spike.






