Codey OnlineArduino- & ESP32-componentenbibliotheek › 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

De TOF400C-VL53L1X is een time-of-flight afstandssensormodule die de afstand tot een object meet over ongeveer 4–400 cm. Hij communiceert met een microcontroller via een I2C-interface en wordt meestal gebruikt in robotica en automatisering voor obstakeldetectie en afstandsmetingen.

Breedte: 21.5 mm

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

Pin Signaal Beschrijving
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.

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

Van Naar Draad
board:5V x1:VIN red
board:GND x1:GND black
board:A4 x1:SDA green
board:A5 x1:SCL blue

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

Dit voorbeeld is geschreven en compile-gecheckt voor de arduino-uno. Codey Online past het voor je aan naar elk ander ondersteund board.

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

Vergelijkbare componenten

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

Bouw je Arduino- of ESP32-project met AI

Beschrijf wat je wilt bouwen. Codey Online schrijft de code, tekent het aansluitschema, compileert het en flasht je board rechtstreeks vanuit de browser.

Gratis starten