Codey OnlineBiblioteca de componentes Arduino y ESP32 › TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
Sensores

TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

El TOF400C-VL53L1X es un módulo sensor de distancia time-of-flight que mide la distancia a un objeto en un rango aproximado de 4 a 400 cm. Se comunica con un microcontrolador mediante una interfaz I2C y suele usarse en robótica y automatización para detección de obstáculos y medición de distancias.

Ancho: 21.5 mm

Pinout — TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

Pin Señal Descripción
VIN power Module supply input for the VL53L1X board, typically 3.3–5 V depending on module regulator.
GND ground Ground reference for power and I2C signals.
SDA SDA I2C serial data line for distance readings and configuration.
SCL SCL I2C serial clock line driven by the host controller.
INT interrupt Interrupt output from the VL53L1X, used to signal measurement/data-ready events.
SHUT reset XSHUT shutdown/reset input; drive low to disable or reset the sensor.

Esquema de cableado de ejemplo — TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

Desde Hasta Cable
board:5V x1:VIN red
board:GND x1:GND black
board:A4 x1:SDA green
board:A5 x1:SCL blue

Código Arduino de ejemplo — TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

Este ejemplo se escribió y verificó por compilación para arduino-uno. Codey Online lo adapta a cualquier otra placa compatible.

#include <Wire.h>

const uint8_t SENSOR_I2C_ADDR = 0x29;
const uint8_t REG_SOFT_RESET = 0x0000;
const uint8_t REG_START = 0x000E;
const uint8_t REG_RANGE_STATUS = 0x0089;
const uint8_t REG_DISTANCE = 0x0096;

void write8(uint16_t reg, uint8_t value) {
  Wire.beginTransmission(SENSOR_I2C_ADDR);
  Wire.write((uint8_t)(reg >> 8));
  Wire.write((uint8_t)(reg & 0xFF));
  Wire.write(value);
  Wire.endTransmission();
}

uint8_t read8(uint16_t reg) {
  Wire.beginTransmission(SENSOR_I2C_ADDR);
  Wire.write((uint8_t)(reg >> 8));
  Wire.write((uint8_t)(reg & 0xFF));
  Wire.endTransmission(false);
  Wire.requestFrom(SENSOR_I2C_ADDR, (uint8_t)1);
  return Wire.available() ? Wire.read() : 0;
}

uint16_t read16(uint16_t reg) {
  Wire.beginTransmission(SENSOR_I2C_ADDR);
  Wire.write((uint8_t)(reg >> 8));
  Wire.write((uint8_t)(reg & 0xFF));
  Wire.endTransmission(false);
  Wire.requestFrom(SENSOR_I2C_ADDR, (uint8_t)2);
  uint16_t value = 0;
  if (Wire.available() >= 2) {
    value = (uint16_t)Wire.read() << 8;
    value |= Wire.read();
  }
  return value;
}

bool sensorPresent() {
  Wire.beginTransmission(SENSOR_I2C_ADDR);
  return Wire.endTransmission() == 0;
}

void setupSensor() {
  // VL53L1X-style boot sequence: soft reset, then start ranging.
  write8(REG_SOFT_RESET, 0x00);
  delay(10);
  write8(REG_SOFT_RESET, 0x01);
  delay(10);
  write8(REG_START, 0x01);
  delay(50);
}

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ;
  }

  Wire.begin();
  Serial.println("TOF400C VL53L1X distance sensor example");

  if (!sensorPresent()) {
    Serial.println("Sensor not found at I2C address 0x29. Check wiring.");
    while (true) {
      delay(1000);
    }
  }

  setupSensor();
  Serial.println("Sensor initialized.");
}

void loop() {
  uint8_t status = read8(REG_RANGE_STATUS);
  uint16_t distanceMm = read16(REG_DISTANCE);

  Serial.print("Range status: ");
  Serial.print(status);
  Serial.print("  Distance: ");
  Serial.print(distanceMm);
  Serial.println(" mm");

  delay(200);
}

Componentes relacionados

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Crea tu proyecto de Arduino o ESP32 con IA

Describe lo que quieres construir. Codey Online escribe el codigo, dibuja el esquema de conexiones, lo compila y graba tu placa directamente desde el navegador.

Empieza gratis