Skip to main content

vl53l1x

Long-range Time-of-Flight laser distance sensor with up to 4m range.

Overview

The vl53l1x node measures distance using the STMicroelectronics VL53L1X long-range Time-of-Flight laser ranging sensor via I2C. It offers up to 4 meters of range with configurable Region of Interest (ROI), timing budgets, and distance modes. The sensor uses a 940nm VCSEL (eye-safe class 1 laser) for fast, accurate measurements unaffected by target color or reflectivity.

4m
Max Range (Long)
1.3m
Max Range (Short)
I2C
Interface
940nm
Laser (eye-safe)

Properties

Property Type Default Description
i2cBus select /dev/i2c-1 I2C bus device. Options: /dev/i2c-0, /dev/i2c-1
address string 0x29 I2C address of the sensor
distanceMode select long Distance mode. Short: up to 1.3m (better ambient immunity). Long: up to 4m
timingBudget select 100 Timing budget in ms. Options: 15, 20, 33, 50, 100, 200, 500. Higher = better accuracy
roi string 16x16 Region of Interest size WxH (4x4 to 16x16). Smaller ROI narrows field of view

Output

{
  "distance_mm": 1542,
  "status": "valid",
  "signalRate": 6.24,
  "ambientRate": 0.15,
  "roi": "16x16",
  "mode": "long",
  "timestamp": 1640000000000
}

Wiring (I2C)

Connection

VIN → 3.3V (or 5V with onboard regulator)

GND → GND

SDA → GPIO 2 (Pin 3)

SCL → GPIO 3 (Pin 5)

XSHUT → GPIO (optional, for multi-sensor)

GPIO1 → GPIO (optional, interrupt)

Default address: 0x29 (configurable via XSHUT pin for multi-sensor setups)

ASCII Wiring Diagram

  VL53L1X          Raspberry Pi
  --------          ------------
  VIN  ──────────── 3.3V (Pin 1)
  GND  ──────────── GND  (Pin 6)
  SDA  ──────────── SDA  (Pin 3)
  SCL  ──────────── SCL  (Pin 5)
  XSHUT ─────────── GPIO (optional)
  GPIO1 ─────────── GPIO (optional)

Example: Multi-Zone Proximity Detection

Use the ROI feature to create proximity zones for interactive displays or smart doorways.

vl53l1x function dashboard
// Function node: Classify distance into zones
var distance = msg.distance_mm;
var zone = "unknown";

if (distance < 500) {
    zone = "immediate";    // 0-50cm
} else if (distance < 1500) {
    zone = "near";         // 50-150cm
} else if (distance < 3000) {
    zone = "mid";          // 150-300cm
} else {
    zone = "far";          // 300cm+
}

msg.payload = {
    distance_mm: distance,
    distance_cm: (distance / 10).toFixed(1),
    zone: zone,
    signal: msg.signalRate,
    timestamp: msg.timestamp
};

return msg;

Example: Doorway People Counter

Mount the sensor above a doorway to count people passing through using distance threshold detection.

// Function node: People counter with direction
var distance = msg.distance_mm;
var doorHeight = 2100;       // mm from sensor to floor
var personThreshold = 1800;  // mm - detect heads below this
var prevState = flow.get('personPresent') || false;
var count = flow.get('peopleCount') || 0;

var personPresent = distance < personThreshold;

// Rising edge: person enters detection zone
if (personPresent && !prevState) {
    count++;
    flow.set('peopleCount', count);
}

flow.set('personPresent', personPresent);

msg.payload = {
    distance_mm: distance,
    headHeight: doorHeight - distance,
    personPresent: personPresent,
    totalCount: count,
    mode: msg.mode
};

return msg;

Example: Precision Liquid Level Monitoring

Use the long-range mode for large tank level monitoring with millimeter precision.

// Function node: Tank level with filtering
var distance = msg.distance_mm;
var tankDepth = 3500;  // mm total depth
var readings = flow.get('readings') || [];

// Rolling average filter (5 samples)
readings.push(distance);
if (readings.length > 5) readings.shift();
flow.set('readings', readings);

var avgDistance = readings.reduce(function(a, b) {
    return a + b;
}, 0) / readings.length;

var level = tankDepth - avgDistance;
level = Math.max(0, Math.min(tankDepth, level));
var percent = (level / tankDepth) * 100;

msg.payload = {
    raw_mm: distance,
    filtered_mm: avgDistance.toFixed(0),
    level_mm: level.toFixed(0),
    percent: percent.toFixed(1),
    liters: (level * 0.785).toFixed(1),
    status: msg.status
};

return msg;

Common Use Cases

People Counting

Overhead mounting for accurate foot traffic counting in doorways and corridors

Tank Level Monitoring

Non-contact liquid level measurement in tanks up to 4 meters deep

Robotics Navigation

Long-range obstacle detection and distance measurement for autonomous robots

Gesture Recognition

Narrow ROI settings for precise hand gesture and proximity detection

Related Nodes