VL53L0X Sensor Overview
The VL53L0X is a time-of-flight (ToF) laser ranging sensor that measures distances by calculating the time light takes to bounce back from objects.Key Characteristics
- Measurement Range: 30mm to 2000mm (approximately 3cm to 2 meters)
- Accuracy: ±3% at typical distances
- Field of View: 25° cone
- Measurement Time: ~30ms per reading
- Interface: I2C (default address 0x29)
Distance Thresholds
The firmware uses a fixed threshold to determine occupancy fromS-Parking.ino:78-82:
Distance threshold for occupancy detection
- Less than 400mm → Space is occupied (status = 0)
- Greater than 400mm → Space is available (status = 1)
- RangeStatus = 4 → Out of range or no valid measurement
Why 400mm?
The 400mm (40cm) threshold is chosen because:- Car undercarriage height: Most vehicles have ground clearance of 150-250mm
- Sensor mounting height: Typically 2-3 meters above ground
- Safety margin: 400mm provides buffer against false positives from debris or puddles
- Reliable detection: Large difference between “car present” and “empty space”
Calibration Process
Measure Installation Height
Determine the actual mounting height of your sensor:
- Ceiling mount: 2.5 - 3.0 meters typical
- Pole mount: 2.0 - 2.5 meters typical
- Ground mount: Not recommended (sensor will see car undercarriage)
Test Empty Space Reading
With the parking space empty, check the sensor reading:
- Open Serial Monitor at 115200 baud
- Add temporary debug code to print raw values:
- Note the typical empty space reading (should be close to installation height)
Test Occupied Space Reading
Park a vehicle in the space and observe the readings:
- Most vehicles will show 1500-2000mm (sensor sees car roof, not ground)
- Some low-profile vehicles may show 1200-1500mm
- SUVs/trucks may show 1800-2200mm
Calculate Threshold
Choose a threshold value between empty and occupied readings:Example calculation:
- Empty space: 2500mm
- With car: 1800mm
- Threshold: (2500 + 1800) / 2 = 2150mm
Physical Installation Guidelines
Optimal Mounting Height
The sensor should be mounted directly above the center of the parking space:Mounting Recommendations
Ceiling Mount (Recommended)
Ceiling Mount (Recommended)
Best for: Indoor garages, covered parking structures
- Mount sensor 2.5-3.0 meters above ground
- Point directly downward (perpendicular to ground)
- Use weatherproof enclosure if needed
- Ensure stable mounting (no vibration)
- Most reliable readings
- Protected from weather
- Wide detection area
Pole Mount
Pole Mount
Best for: Open parking lots, temporary installations
- Mount sensor 2.0-2.5 meters high on pole
- Position at edge of parking space, angled toward center
- Account for angle in threshold calculations
- Use sturdy pole to prevent swaying
- Requires trigonometry for threshold adjustment
- More susceptible to weather
- May need recalibration after wind/vibration
Wall Mount
Wall Mount
Best for: Perpendicular parking against walls
- Mount on wall at front of space
- Sensor points horizontally toward parking space
- Threshold measures distance to car front
- Height: 0.8-1.2 meters (bumper to mid-door level)
- Different threshold range (detect car presence, not distance to ground)
- Use shorter threshold (e.g., 1500mm for detection)
- May miss motorcycles or compact vehicles
Installation Checklist
- Sensor is securely mounted (no movement or vibration)
- Field of view covers entire parking space
- No obstructions between sensor and ground (pipes, lights, etc.)
- Sensor lens is clean and free of debris
- Weatherproofing applied if outdoors
- Cable routing is secure and protected
- Power supply is stable (no voltage drops)
- Tested with multiple vehicle types
Handling Edge Cases
RangeStatus Error Codes
The VL53L0X returns aRangeStatus value indicating measurement quality:
| Status | Meaning | Firmware Handling |
|---|---|---|
| 0 | Valid measurement | Use reading |
| 1 | Sigma fail (low signal) | May be valid |
| 2 | Signal fail (no return) | Treat as out of range |
| 4 | Out of range | Treat as available |
S-Parking.ino:78, status 4 is explicitly checked:
Common Calibration Issues
Sensor always shows occupied
Sensor always shows occupied
Symptoms: LED always red, even when space is emptyPossible causes:
- Threshold too high (detects ground as occupied)
- Sensor pointed at angle (sees nearby wall/object)
- Obstruction in field of view
- Lower threshold value
- Adjust sensor angle to point straight down
- Remove obstructions
- Check for debris on sensor lens
Sensor always shows available
Sensor always shows available
Symptoms: LED stays green even with car presentPossible causes:
- Threshold too low (doesn’t detect cars)
- Mounting too high (out of sensor range)
- Sensor not pointed at parking space
- Increase threshold value
- Lower mounting height
- Adjust sensor aim
- Test with serial monitor debug output
Intermittent false positives
Intermittent false positives
Symptoms: LED flickers between red and green randomlyPossible causes:
- Threshold too close to typical readings (no margin)
- Vibration causing measurement noise
- Objects passing through field of view (people, carts)
- Add hysteresis (require 2-3 consistent readings before state change)
- Stabilize mounting
- Adjust threshold with larger safety margin
- Implement software filtering (moving average)
Advanced: Implementing Hysteresis
To reduce false triggering, you can add hysteresis with two thresholds:Testing & Validation
After calibration, perform comprehensive testing:Basic Functionality
- Empty space → Green LED
- Car parks → Red LED within 2 seconds
- Car leaves → Green LED within 2 seconds
Vehicle Variety
Test with different vehicle types:
- Sedans
- SUVs/Trucks
- Motorcycles (may need different threshold)
- Compact cars
Environmental Conditions
- Test in rain/snow (if outdoor)
- Test with shadows and sunlight changes
- Test with people walking near sensor
Next Steps
LED Indicators
Configure RGB LED wiring and behavior
Hardware Overview
Review complete hardware architecture