Pedido antes de las 14:00 en día laborable = enviado el mismo día 30 días de desistimiento 1 año de garantía
← Volver al resumen

Al reproducirlo, se carga el vídeo de YouTube.

Esquema de conexión y ejemplo de código

Así conectas el TOF050C-VL6180X Sensor de distancia Time-Of-Flight de alta precisión a un Arduino UNO o ESP32, con un sketch de ejemplo que puedes subir directamente.

Medición del sensor de distancia VL6180X

Este proyecto mide con precisión distancias de corto alcance (hasta ~200mm) usando el sensor Time-of-Flight VL6180X mediante I2C. Conecta el sensor a la alimentación y a los pines I2C, luego abre el Monitor Serie a 115200 baud para ver las mediciones de distancia en milímetros en tiempo real.

Esquema de conexión: TOF050C-VL6180X Sensor de distancia Time-Of-Flight de alta precisión en un Arduino UNO
Esquema de conexión · Haz clic para ampliar
Tabla de conexión: TOF050C-VL6180X Sensor de distancia Time-Of-Flight de alta precisión en un Arduino UNO
Tabla de conexión · Haz clic para ampliar
VL6180X_Distance_Sensor_Measurement.ino · compilado y probado
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : VL6180X Distance Sensor Measurement
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : TOF050C-VL6180X Distance Sensor Time-Of-Flight high precision
 *  Libraries : Adafruit_VL6180X 1.4.4
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <Adafruit_VL6180X.h>

Adafruit_VL6180X vl = Adafruit_VL6180X();

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

  Serial.println(F("Initializing VL6180X sensor..."));
  if (!vl.begin()) {
    Serial.println(F("Failed to find VL6180X sensor! Check wiring."));
    while (1);
  }
  Serial.println(F("VL6180X sensor ready!"));
}

void loop() {
  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  if (status == VL6180X_ERROR_NONE) {
    Serial.print(F("Distance: "));
    Serial.print(range);
    Serial.println(F(" mm"));
  } else {
    if (status >= VL6180X_ERROR_SYSERR_1 && status <= VL6180X_ERROR_SYSERR_5) {
      Serial.println(F("System error"));
    } else if (status == VL6180X_ERROR_ECEFAIL) {
      Serial.println(F("ECE failure"));
    } else if (status == VL6180X_ERROR_NOCONVERGE) {
      Serial.println(F("No convergence"));
    } else if (status == VL6180X_ERROR_RANGEIGNORE) {
      Serial.println(F("Ignoring range"));
    } else if (status == VL6180X_ERROR_SNR) {
      Serial.println(F("Signal-to-Noise Ratio error"));
    } else if (status == VL6180X_ERROR_RAWUFLOW) {
      Serial.println(F("Raw reading underflow"));
    } else if (status == VL6180X_ERROR_RAWOFLOW) {
      Serial.println(F("Raw reading overflow"));
    } else if (status == VL6180X_ERROR_RANGEUFLOW) {
      Serial.println(F("Range reading underflow"));
    } else if (status == VL6180X_ERROR_RANGEOFLOW) {
      Serial.println(F("Out of range (>200mm)"));
    }
  }

  delay(200);
}

Bibliotecas necesarias: Adafruit_VL6180X 1.4.4

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Sensor de distancia y luz VL6180X con ESP32

Este proyecto mide la distancia de corto alcance (0–100 mm) y los niveles de luz ambiental usando el sensor Time-of-Flight TOF050C VL6180X por I2C. Conecta el sensor directamente al 3.3V del ESP32 y a los pines I2C predeterminados (GPIO 21 y 22). Abre el Serial Monitor a 115200 baud para ver en tiempo real las mediciones de distancia y lux ambiental.

Esquema de conexión: TOF050C-VL6180X Sensor de distancia Time-Of-Flight de alta precisión en un ESP32 DevKit V1
Esquema de conexión · Haz clic para ampliar
Tabla de conexión: TOF050C-VL6180X Sensor de distancia Time-Of-Flight de alta precisión en un ESP32 DevKit V1
Tabla de conexión · Haz clic para ampliar
VL6180X_Distance_Light_Sensor_with_ESP32.ino · compilado y probado
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : VL6180X Distance & Light Sensor with ESP32
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : TOF050C-VL6180X Distance Sensor Time-Of-Flight high precision
 *  Libraries : Adafruit_VL6180X 1.4.4
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Wire.h>
#include <Adafruit_VL6180X.h>

Adafruit_VL6180X vl = Adafruit_VL6180X();

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

  Serial.println("VL6180X Distance & Light Sensor Demo");

  Wire.begin(21, 22);

  if (!vl.begin()) {
    Serial.println("Failed to find VL6180X sensor! Check wiring.");
    while (1) delay(100);
  }

  Serial.println("VL6180X found and initialized!");
}

void loop() {
  float lux = vl.readLux(VL6180X_ALS_GAIN_5);
  uint8_t range = vl.readRange();
  uint8_t status = vl.readRangeStatus();

  Serial.print("Ambient Light: ");
  Serial.print(lux);
  Serial.print(" Lux | ");

  if (status == VL6180X_ERROR_NONE) {
    Serial.print("Distance: ");
    Serial.print(range);
    Serial.println(" mm");
  } else {
    Serial.print("Range Status Error (Code: ");
    Serial.print(status);
    Serial.println(")");
  }

  delay(200);
}

Bibliotecas necesarias: Adafruit_VL6180X 1.4.4

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Vistos recientemente

Cargador de batería de litio 18650 con Micro USB 5V 1A TP4056

Cargador de batería de litio 18650 con Micro USB 5V 1A TP4056

€ 2,25
Portapilas para pila botón CR2032 y CR2025

Portapilas para pila botón CR2032 y CR2025

€ 0,65