38 Lab: Light and Proximity Sensors
sensors
sensor
proximity
light
Chapter Roadmap
- First, separate calibrated light readings from analog LDR behavior so threshold choices match the sensor.
- Then, test PIR and ultrasonic proximity as different kinds of presence evidence rather than interchangeable detectors.
- Next, connect I2C bus checks and analog circuits to the wiring faults that make labs unreliable.
- Finally, use the challenges, quizzes, and readout companion to turn working readings into evidence records.
Checkpoint callouts mark places to pause and confirm the story so far; deep-dive and practice sections can be skimmed on a first lab pass and revisited when you need the implementation detail.
38.2 Learning Objectives
By the end of this chapter, you will be able to:
- Interface light sensors: Configure BH1750 digital lux meter and LDR analog sensors
- Build proximity detection: Use PIR motion sensors and HC-SR04 ultrasonic distance sensors
- Compare touch sensing technologies: Differentiate capacitive and skin-inspired tactile sensor architectures
- Diagnose I2C communication: Scan buses, address multiple sensors, and resolve communication issues
- Apply circuit fundamentals: Use voltage dividers and RC filters in sensor circuits
Light and Proximity Sensors
Light sensors measure how bright it is (like the automatic brightness on your phone screen), PIR motion sensors detect when a person walks by (like the sensor that turns on a porch light), and ultrasonic distance sensors measure how far away an object is by bouncing sound waves off it (like a bat navigating in the dark). These are some of the most commonly used sensors in smart home and security projects.
38.3 Prerequisites
Required Knowledge:
- Motion & Environmental Sensors - I2C basics
- Electronics Basics - Circuit fundamentals
- Sensor Circuits - Signal conditioning
Hardware Requirements:
- ESP32 development board
- BH1750 light sensor or LDR (photoresistor)
- PIR motion sensor (HC-SR501)
- HC-SR04 ultrasonic distance sensor
- Resistors (10kOhm for voltage divider, 4.7kOhm for I2C)
- Breadboard and jumper wires
38.4 Light Sensors
38.4.1 BH1750 (Digital Light Intensity)
The BH1750 is a digital ambient light sensor with spectral response close to the human eye, making it ideal for automatic brightness adjustment.
Specifications:
- Range: 1-65535 lux
- Interface: I2C
- Resolution: 1 lux
- I2C Address: 0x23 (ADDR pin LOW/floating) or 0x5C (ADDR pin HIGH)
- Spectral response close to human eye
- Power: 120uA active, 0.01uA power down
What to Observe Before Coding:
| Lux Range | Real-World Meaning | Device Decision Example |
|---|---|---|
| Below 50 lux | Dark or very dim | Turn on night lighting |
| 50-500 lux | Indoor lighting | Keep display brightness moderate |
| Above 2000 lux | Bright daylight | Increase display brightness or ignore PIR shadows |
Optional ESP32 Implementation
#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter;
void setup() {
Serial.begin(115200);
Wire.begin(); // Uses default ESP32 I2C pins: SDA=GPIO21, SCL=GPIO22
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
Serial.println("BH1750 initialized");
} else {
Serial.println("Error initializing BH1750");
}
}
void loop() {
float lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.print(" lux");
// Classify light levels (approximate ranges)
String classification;
if (lux < 1) {
classification = "Darkness (moonlight)";
} else if (lux < 50) {
classification = "Very dim (street lighting)";
} else if (lux < 200) {
classification = "Dim (hallway)";
} else if (lux < 500) {
classification = "Normal (home/office)";
} else if (lux < 2000) {
classification = "Bright (retail/overcast)";
} else if (lux < 25000) {
classification = "Very bright (daylight)";
} else {
classification = "Extremely bright (direct sun)";
}
Serial.print(" - ");
Serial.println(classification);
delay(1000);
}
Learning Points: Light Sensing
Lux Reference Values:
| Condition | Lux Level |
|---|---|
| Full moon | 0.1-1 |
| Street lighting | 10-50 |
| Home lighting | 150-300 |
| Office | 300-500 |
| Overcast sky | 1,000-2,000 |
| Full daylight | 10,000-25,000 |
| Direct sunlight | 100,000+ |
Real-World Applications:
- Smart street lights: Dim when natural light is sufficient
- Display backlighting: Adjust screen brightness based on ambient light
- Greenhouse automation: Supplement natural light with artificial lighting
- Energy efficiency: Reduce power when full brightness isn’t needed
Checkpoint: Light Thresholds
You now know:
- A BH1750 reports calibrated lux over I2C, while an LDR needs a divider and ADC interpretation.
- Thresholds are decisions about scenes: dark, indoor, daylight, and direct sunlight lead to different device actions.
- Hysteresis belongs in the control rule when one threshold would make an output flicker.
The light lab established how illumination becomes a stable decision. The next question is how a device should notice a nearby person or object when brightness is not the signal.
38.5 Proximity & Presence Sensors
38.5.1 PIR Motion Sensor (HC-SR501)
PIR (Passive Infrared) sensors detect motion by measuring changes in infrared radiation from warm bodies (humans, animals).
Specifications:
- Detection Range: 3-7 meters (adjustable)
- Detection Angle: 110 degree cone
- Output: Digital HIGH when motion detected
- Hold Time: ~2.5 to 200 seconds (adjustable via potentiometer)
- Power: 5V, ~65µA quiescent
- Trigger Modes: Single trigger or repeatable trigger
What to Observe Before Coding:
PIR sensors do not identify people. They detect changes in infrared energy across their detection zones. In the simulator below, focus on how distance, angle, and environment affect false triggers.
Optional ESP32 Implementation
#define PIR_PIN 13 // GPIO13 for PIR sensor
bool motionDetected = false;
unsigned long lastMotionTime = 0;
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("PIR Motion Sensor Test");
Serial.println("Warming up sensor (30-60 seconds)...");
delay(60000); // PIR needs 30-60s warm-up time
Serial.println("Ready!");
}
void loop() {
int pirState = digitalRead(PIR_PIN);
if (pirState == HIGH) {
if (!motionDetected) {
motionDetected = true;
lastMotionTime = millis();
Serial.println("MOTION DETECTED!");
Serial.print("Time: ");
Serial.println(millis() / 1000);
// Trigger action (turn on light, send alert, etc.)
digitalWrite(LED_BUILTIN, HIGH);
}
} else {
if (motionDetected) {
unsigned long motionDuration = (millis() - lastMotionTime) / 1000;
Serial.print("Motion ended. Duration: ");
Serial.print(motionDuration);
Serial.println(" seconds");
motionDetected = false;
digitalWrite(LED_BUILTIN, LOW);
}
}
delay(100);
}
Learning Points: PIR Sensors
Key Characteristics:
- PIR sensors need a 30-60 second warm-up period after power-on
- Output is digital (HIGH/LOW), making interfacing very simple
- The sensor stays HIGH as long as motion is detected
- Adjustable potentiometers control sensitivity and hold time
Real-World Applications:
- Smart lighting: Turn on lights when someone enters a room
- Security systems: Send alerts when motion detected while away
- Energy saving: Power down devices when no one is present
- Occupancy counting: Track room usage patterns
Checkpoint: Presence Evidence
You now know:
- PIR output is a digital motion signal, so it is good for presence changes but not for distance.
- Mounting height, hold time, trigger mode, and environment all shape whether a motion event is useful evidence.
- A warm-up period and confirmation delay are part of the lab design, not optional cleanup.
PIR answers whether motion changed in a detection zone. Ultrasonic ranging answers a different question: how far away the reflecting surface is, and whether the timing math still holds under the current air temperature.
38.5.2 Ultrasonic Distance Sensor (HC-SR04)
Ultrasonic sensors measure distance by timing the echo return of a 40kHz sound pulse.
Specifications:
- Range: 2cm to 400cm
- Accuracy: +/-3mm
- Measuring angle: 15 degrees
- Trigger pulse: 10us
- Power: 5V, 15mA
The HC-SR04 operates at 5V logic, but the ESP32 GPIO pins are 3.3V. The ECHO pin outputs a 5V HIGH signal that can damage the ESP32. Use a voltage divider (two resistors, e.g., 1kOhm + 2kOhm) on the ECHO line to reduce it to ~3.3V, or use a 3.3V-compatible variant like the HC-SR04P.
What to Observe Before Coding:
The HC-SR04 measures time, not distance directly. The microcontroller sends a trigger pulse, waits for the echo pulse, then converts travel time into distance using the speed of sound.
Ultrasonic Measurement Flow
- Send a 10 microsecond trigger pulse.
- Measure the echo pulse width.
- Convert round-trip echo time into one-way distance using the speed of sound.
Optional ESP32 Implementation
#define TRIG_PIN 5
#define ECHO_PIN 18
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
}
void loop() {
float distance = measureDistance();
Serial.print("Distance: ");
Serial.print(distance, 1);
Serial.println(" cm");
// Object detection
if (distance > 0 && distance < 50) {
Serial.println("Object detected nearby!");
}
delay(100);
}
float measureDistance() {
// Send 10us pulse
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Measure echo pulse duration
long duration = pulseIn(ECHO_PIN, HIGH, 30000); // 30ms timeout
// Calculate distance (speed of sound = 343 m/s at 20°C)
// distance = (duration * 0.0343) / 2
float distance = duration * 0.0343 / 2.0;
return distance;
}
Putting Numbers to It
Ultrasonic sensors measure distance using the time-of-flight formula where sound travels to the object and back.
$ d = $
where \(d\) is distance, \(t\) is echo pulse duration in microseconds, and \(v_{\text{sound}}\) is 343 m/s (0.0343 cm/µs) at 20°C.
Worked example: The HC-SR04 measures an echo pulse duration of 1,750 µs. Calculate the distance:
$ d = = = 30.01 , $
Temperature compensation: At 0°C, speed of sound is 331.3 m/s (3.5% slower), so the same 1,750 µs pulse would calculate as 29.0 cm instead of 30.0 cm, introducing 1 cm error per 30 cm distance without compensation.
Run it: Before you read echo time as distance, switch the Light and Proximity Sensing Workbench to Proximity mode. Set an object distance and an air temperature and watch the speed of sound (v = 331.3 + 0.606 x T) and the round-trip echo time update together, so a warmer day visibly shortens the echo for the same distance. Then move the detect and release thresholds and toggle hysteresis to see the dead band absorb chatter as an object approaches the stop line.
Try It: Ultrasonic Distance Calculator
Adjust the echo pulse duration and ambient temperature to see how they affect the calculated distance. Notice how temperature changes the speed of sound and therefore the distance measurement.
Learning Points: Ultrasonic Sensors
Key Concepts:
- Time-of-Flight:
distance = (time * speed_of_sound) / 2 - Speed of Sound: 343 m/s at 20°C (0.0343 cm/µs)
- Temperature Compensation: Speed varies ~0.6 m/s per °C
- Blind zone: Cannot measure objects closer than 2cm
Real-World Applications:
- Parking sensors: Alert drivers to obstacles
- Robotics: Obstacle avoidance and navigation
- Liquid level sensing: Measure tank fill levels
- People counting: Detect presence at doorways
Temperature Compensation: Sound travels faster in warmer air. Add about 0.606 m/s to the 331.3 m/s baseline for each degree Celsius, then divide the round-trip echo distance by two.
HC-SR04 Distance Measurement
The HC-SR04 uses time-of-flight measurement with these precise steps:
- Send trigger pulse - 10µs HIGH signal on TRIG pin activates the sensor
- Sensor emits ultrasound - 8 cycles of 40 kHz sound burst (inaudible to humans)
- Wait for echo - ECHO pin goes HIGH when sound is transmitted
- Measure echo duration - ECHO pin goes LOW when reflected sound returns
- Calculate distance -
distance_cm = (echo_duration_µs × 0.0343) / 2
Why divide by 2? The sound travels to the object AND back, so the total time covers twice the distance.
38.6 Touch and Skin Sensing
Beyond light and proximity, touch sensors represent an emerging area of IoT sensing. Skin-inspired (or “e-skin”) sensors mimic the multi-layer structure of human skin, using arrays of capacitive or piezoresistive sensing elements (“taxels”) to detect pressure, texture, and even temperature. These sensors are particularly relevant for robotics, prosthetics, and human-computer interaction.
For IoT applications, simpler capacitive touch sensors (like the ESP32’s built-in touch pins) are commonly used for user interfaces, while advanced e-skin arrays remain primarily a research area.
Checkpoint: Distance and Touch
You now know:
- HC-SR04 distance comes from trigger timing, echo duration, speed of sound, and the round trip divided back to one-way distance.
- Temperature compensation matters because the same echo duration maps to a different distance when the speed of sound changes.
- Touch and skin sensing belong in this lab as interface examples, while ultrasonic and PIR remain the main proximity evidence paths.
After measuring light, motion, distance, and touch, the lab shifts to a shared wiring problem: several sensors may work individually but fail together if the bus is not managed.
38.7 I2C Sensors and Bus Management
I2C Bus Scanner Concept:
An I2C scanner is a diagnostic tool. It tries every possible address and reports which devices acknowledge. Use the interactive explorer below first to predict what a scan should find.
Optional ESP32 Scanner
#include <Wire.h>
#define I2C_SDA 21
#define I2C_SCL 22
void setup() {
Serial.begin(115200);
Wire.begin(I2C_SDA, I2C_SCL);
// Scan I2C bus
scanI2C();
}
void scanI2C() {
Serial.println("Scanning I2C bus...");
int devices = 0;
for(byte address = 1; address < 127; address++) {
Wire.beginTransmission(address);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
devices++;
}
}
Serial.print("Found ");
Serial.print(devices);
Serial.println(" devices");
}
void loop() {
// Empty loop
}38.8 Circuit Fundamentals for Sensors
38.8.1 Voltage Divider with LDR
For analog light sensors (LDR/photoresistor), use a voltage divider circuit:
How it works:
- LDR resistance decreases with more light (~1kOhm bright, ~1MOhm dark)
- Voltage at midpoint varies with light level
- ADC reads this varying voltage
38.8.2 RC Low-Pass Filter
Filter high-frequency noise from sensor readings:
Cutoff Frequency: f_c = 1 / (2 * PI * R * C) = 159 Hz
Run it: The calculator below sets LDR resistance directly. To connect that resistance back to a real scene, open the Light and Proximity Sensing Workbench first: in Light mode, drag the ambient light slider (1 to 100,000 lux) and choose a divider resistor, and watch how R_LDR, the ADC voltage, and the 12-bit ADC count each follow from the divider formula shown beside the circuit. Then step the dark room, office, and daylight presets, and set the night-light thresholds (ON below 50 lux, OFF above 80 lux) and toggle hysteresis to watch the flicker at a single threshold disappear.
Try It: LDR Voltage Divider Calculator
Adjust the LDR resistance (which changes with light level) to see how the voltage at the ADC pin changes. The fixed resistor is 10kOhm and the supply is 3.3V.
Learning Points: Circuit Fundamentals
Voltage Divider: the output is the supply voltage multiplied by the share of resistance below the measurement point. As the LDR resistance changes, the ADC voltage changes with it.
RC Filter Time Constant: the time constant is resistance multiplied by capacitance. A signal usually needs about five time constants to settle near its final value, so larger R or C makes the reading smoother but slower.
Why Use Pull-up Resistors for I2C: I2C uses open-drain outputs that can only pull LOW. Pull-up resistors (4.7k Ohm typical) pull the line HIGH when no device is transmitting.
38.9 Sensor Servo
Try it yourself! See how sensors control actuators for automated systems.
What This Simulates: An LDR light sensor controlling a servo motor to automatically adjust window blinds based on sunlight.
How to Use:
- Open the fresh ESP32 workspace below.
- Add an LDR or potentiometer input and a servo.
- Wire the sensor signal to GPIO34 and the servo signal to GPIO18.
- Run the sketch, vary the sensor input, and watch the servo angle change.
Checkpoint: Wiring to Behavior
You now know:
- I2C scanner output is a diagnostic record: addresses, conflicts, and pull-ups explain whether devices can communicate.
- LDR dividers and RC filters turn raw analog behavior into smoother ADC readings without pretending the signal is digital.
- The servo exercise closes the loop by using sensor evidence to choose an actuator position.
The implementation pieces are now connected: sensor readings, bus checks, filters, and actuator behavior. The remaining work is to test whether you can choose the right explanation when a lab result changes.
38.10 Knowledge Check
Key Takeaway
Light and proximity sensors each serve distinct purposes: BH1750 provides calibrated lux measurements for adaptive lighting, PIR sensors detect human presence via infrared changes (with a 30-60 second warm-up), and ultrasonic sensors measure distance using sound waves (requiring temperature compensation for outdoor use). Understanding voltage dividers and RC filters is essential for interfacing analog sensors reliably.
For Kids: Meet the Sensor Squad!
The Sensor Squad got three new members today!
First up is Lucy the Light Sensor (BH1750). “I can tell you exactly how bright it is,” Lucy said. “Office lighting is about 300-500 lux, but direct sunlight is over 100,000 lux! Smart buildings use me to dim the lights when the sun is shining – saving lots of energy!”
Next is Pete the PIR Sensor. “I detect warm-blooded creatures!” Pete announced. “When a person walks by, the infrared heat pattern changes, and I send a HIGH signal. But you have to wait about a minute after I power on – I need my warm-up time!”
Finally, Ulti the Ultrasonic Sensor (HC-SR04) showed off: “I shout a tiny ‘BEEP’ too high for humans to hear, then listen for the echo bouncing back. The longer it takes, the farther away the object is! I use the speed of sound – 343 meters per second at room temperature.”
Bella the Battery asked, “What happens when it is cold outside?” Ulti admitted: “Sound travels slower in cold air, so I need a thermometer friend to help me calculate distance correctly!”
38.11 PIR Heat False Triggers
The Problem: Your PIR motion sensor triggers constantly even when no one is present, or fails to detect people walking by.
Why It Happens: PIR sensors detect changes in infrared radiation, not absolute levels. Common causes of false triggers:
- Heating/AC vents: Warm or cold air blowing directly on the PIR causes continuous infrared fluctuations
- Sunlight through windows: Moving shadows or direct sunlight changes IR levels dramatically
- Pets: Dogs and cats are warm-blooded and trigger PIR sensors (not a “false” alarm, but unintended)
- Mounting height: PIR pointed at ground level has a small detection zone; mounted at 2-2.5m gives optimal 5-7m range
Real-World Example: A smart lighting system in an office hallway triggers lights every 30 seconds with no one present. Investigation reveals the PIR sensor is mounted directly below an AC vent. Cold air blowing on the sensor creates IR fluctuations that mimic human motion.
The Fix: Confirm that motion remains present for at least 500 ms before triggering the output. This filters quick thermal disturbances from vents, sunlight, and electrical noise.
38.11.1 Optional PIR Filtering Pattern
// Add filtering to reduce false triggers
const int PIR_PIN = 13;
const int MIN_TRIGGER_DURATION = 500; // Milliseconds
unsigned long triggerStartTime = 0;
bool confirmedMotion = false;
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
delay(60000); // Wait for PIR warm-up
}
void loop() {
int pirState = digitalRead(PIR_PIN);
if (pirState == HIGH) {
if (triggerStartTime == 0) {
triggerStartTime = millis(); // Start timing
} else if (millis() - triggerStartTime > MIN_TRIGGER_DURATION) {
// Confirmed motion only if PIR stays HIGH for 500ms
if (!confirmedMotion) {
confirmedMotion = true;
Serial.println("CONFIRMED MOTION");
digitalWrite(LED_BUILTIN, HIGH);
}
}
} else {
// PIR went LOW - reset
triggerStartTime = 0;
confirmedMotion = false;
digitalWrite(LED_BUILTIN, LOW);
}
delay(50);
}Prevention Checklist:
Key Insight: PIR sensors are binary (motion / no motion) and don’t provide distance or identity. For more sophisticated detection, combine PIR with ultrasonic (distance) or camera (identity).
38.12 Hands-On Challenges
Read One Light Sensor
Goal: Read the BH1750 light sensor and display lux values.
Steps:
- Connect BH1750: VCC→3.3V, GND→GND, SDA→GPIO21, SCL→GPIO22
- Add 4.7kΩ pull-up resistors on SDA and SCL (or use module with built-in resistors)
- Install library:
#include <BH1750.h> - Initialize in setup:
lightMeter.begin() - Read in loop:
float lux = lightMeter.readLightLevel()
Expected result: 300-500 lux in office, 10,000+ lux outdoors
Automatic Night Light Build
Goal: Turn on LED when ambient light drops below 50 lux.
Components: BH1750 + LED + 220Ω resistor + ESP32
Challenge:
- Read light every second
- Use hysteresis (turn on at 50 lux, turn off at 80 lux) to prevent flickering
- Add fade-in/fade-out using PWM
Code skeleton:
float lux = lightMeter.readLightLevel();
if (lux < 50 && !ledOn) {
fadeIn(LED_PIN);
ledOn = true;
} else if (lux > 80 && ledOn) {
fadeOut(LED_PIN);
ledOn = false;
}
Multi-Zone Motion Lighting
Goal: Use 3 PIR sensors to detect which zone has motion, light only that zone’s LEDs.
Challenge:
- Wire 3 PIR sensors (front, middle, back)
- Control 3 LED strips independently
- Implement timeout (lights off 30s after last motion)
- Add ambient light override (don’t activate if already bright)
Bonus: Log motion patterns to SD card for occupancy analysis
38.13 Concept Relationships
| Core Concept | Related Concepts | Why It Matters |
|---|---|---|
| Lux Measurement | Human Vision Response, Lighting Standards | BH1750 spectral response matches human eye |
| PIR Motion Detection | Infrared Changes, Warm-Up Period, False Triggers | Detects heat signature changes, not absolute values |
| Ultrasonic ToF | Speed of Sound, Temperature Compensation | Accuracy depends on knowing sound velocity |
| I2C Pull-ups | Open-Drain Logic, Signal Integrity | Required for reliable I2C communication |
38.14 Label the Diagram
38.15 Code Challenge
38.16 Light/Proximity Readout
The lab above wires and exercises BH1750, LDR, PIR, ultrasonic, touch, and I2C sensing tasks. The companion page explains the measurement physics behind those labs: photodiode current, LDR divider orientation, transimpedance readout, ultrasonic time-of-flight, reflectance ambiguity, ambient-light rejection, and temperature effects.
Next Readout Practice
Continue with Light and Proximity Readout Physics to verify that each light or proximity reading is interpreted with the right physical model before thresholds are chosen.
38.17 Summary
This chapter covered light and proximity sensor implementation:
- BH1750 provides calibrated lux measurements with spectral response matching human vision
- PIR sensors detect motion via infrared radiation changes with simple digital output
- Ultrasonic HC-SR04 measures distance using time-of-flight with temperature compensation needed
- I2C bus scanning identifies connected sensors and verifies communication
- Voltage dividers convert variable resistance (LDR) to measurable voltage
- RC filters reduce high-frequency noise from analog sensor readings
38.18 See Also
- Temperature Sensor Labs - Temperature sensing fundamentals
- Motion & Environmental Sensors - IMU and barometric sensing
- Sensor Calibration Lab - Hands-on calibration techniques
Common Pitfalls
Ambient Light vs IR Proximity
IR proximity sensors (VCNL4040, APDS-9960) can be overwhelmed by strong sunlight or incandescent lamps. In high-ambient-light environments, shield the sensor from direct light or use ultrasonic ranging instead.
HC-SR04 Echo Timeout
If nothing is within the sensor’s 4 m range, the echo pulse may never return. Without a timeout, pulseIn() blocks for up to 1 second. Always use pulseIn(ECHO, HIGH, 30000) with a 30 ms timeout to prevent main loop blocking.
LDR Divider Resistor Mismatch
A light-dependent resistor requires a fixed reference resistor. If the reference is mismatched to the LDR’s operating range, the voltage swing across the full light range is compressed. Choose the fixed resistor near the geometric mean of the LDR’s bright and dark resistance values.
4. Ultrasonic Sensor Crosstalk in Arrays
When two HC-SR04 sensors cover overlapping areas, sensor A’s transmitted pulse can trigger sensor B’s echo detection, causing false distance readings. Trigger sensors sequentially with 50 ms gaps between triggers.