Codey OnlineBibliothèque de composants Arduino & ESP32 › TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
Capteurs

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

Le TOF400C-VL53L1X est un module capteur de distance à temps de vol qui mesure la distance à un objet sur environ 4 à 400 cm. Il communique avec un microcontrôleur via une interface I2C et est généralement utilisé en robotique et en automatisation pour la détection d’obstacles et la mesure de distance.

Largeur: 21.5 mm

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

Broche Signal Description
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.

Exemple de schéma de câblage — TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

De Vers Fil
board:5V x1:VIN red
board:GND x1:GND black
board:A4 x1:SDA green
board:A5 x1:SCL blue

Exemple de code Arduino — TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm

Cet exemple a été écrit et vérifié à la compilation pour le arduino-uno. Codey Online l'adapte pour vous à toute autre carte prise en charge.

#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);
}

Composants similaires

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

Construisez votre projet Arduino ou ESP32 avec l'IA

Décrivez ce que vous voulez créer. Codey Online écrit le code, dessine le schéma de câblage, le compile et flashe votre carte directement depuis le navigateur.

Commencez gratuitement