Codey OnlineArduino- & ESP32-Komponentenbibliothek › TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
TOF400C-VL53L1X Distance sensor Time-Of-Flight very accurate 4-400cm
Sensoren

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

Der TOF400C-VL53L1X ist ein Time-of-Flight-Abstandssensormodul, das die Entfernung zu einem Objekt über etwa 4–400 cm misst. Er kommuniziert mit einem Mikrocontroller über eine I2C-Schnittstelle und wird typischerweise in Robotik und Automatisierung für Hinderniserkennung und Distanzmessungen eingesetzt.

Breite: 21.5 mm

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

Pin Signal Beschreibung
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.

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

Von Nach Kabel
board:5V x1:VIN red
board:GND x1:GND black
board:A4 x1:SDA green
board:A5 x1:SCL blue

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

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

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

Ähnliche Komponenten

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

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten