Op werkdagen vóór 14:00 uur besteld = dezelfde dag verzonden en in 98% van de gevallen de volgende dag in huis. Gratis retourneren 30 dagen bedenktijd 1 jaar garantie
← Tillbaka till översikten

Vid uppspelning laddas videon från YouTube.

Kopplingsschema och kodexempel

Så här kopplar du TOF050C-VL6180X Avståndssensor Time-Of-Flight mycket exakt till en Arduino UNO eller ESP32, med ett exempel­sketch som du kan ladda upp direkt.

VL6180X Distance Sensor Measurement

This project measures accurate short-range distance (up to ~200mm) using the VL6180X Time-of-Flight sensor over I2C. Connect the sensor to power and I2C pins, then open the Serial Monitor at 115200 baud to view real-time distance measurements in millimeters.

Kopplingsschema: TOF050C-VL6180X Avståndssensor Time-Of-Flight mycket exakt på en Arduino UNO
Kopplingsschema · Klicka för att förstora
Kopplingstabell: TOF050C-VL6180X Avståndssensor Time-Of-Flight mycket exakt på en Arduino UNO
Kopplingstabell · Klicka för att förstora
VL6180X_Distance_Sensor_Measurement.ino · kompilerad och testad
/*
 * ==================================================================
 *  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);
}

Nödvändiga bibliotek: Adafruit_VL6180X 1.4.4

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

VL6180X Distance & Light Sensor with ESP32

This project measures close-range distance (0–100 mm) and ambient light levels using the TOF050C VL6180X Time-of-Flight sensor over I2C. Connect the sensor directly to the ESP32's 3.3V and default I2C pins (GPIO 21 and 22). Open the Serial Monitor at 115200 baud to view real-time distance and ambient lux measurements.

Kopplingsschema: TOF050C-VL6180X Avståndssensor Time-Of-Flight mycket exakt på en ESP32 DevKit V1
Kopplingsschema · Klicka för att förstora
Kopplingstabell: TOF050C-VL6180X Avståndssensor Time-Of-Flight mycket exakt på en ESP32 DevKit V1
Kopplingstabell · Klicka för att förstora
VL6180X_Distance_Light_Sensor_with_ESP32.ino · kompilerad och testad
/*
 * ==================================================================
 *  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);
}

Nödvändiga bibliotek: Adafruit_VL6180X 1.4.4

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

Tidigare visade

Power Bank DIY 18650 Lithium batteriladdare JX-887Y

Power Bank DIY 18650 Lithium batteriladdare JX-887Y

€ 2,45
Mini OLED-display RGB Full Color 0.95 tum 96x64 pixlar SPI

Mini OLED-display RGB Full Color 0.95 tum 96x64 pixlar SPI

€ 16,30
PNP Transistor A1015 GR331 50V 150mA 80MHz 400mW TO-92

PNP Transistor A1015 GR331 50V 150mA 80MHz 400mW TO-92

€ 0,35
3.7V 4000mAh uppladdningsbart LIPO (Lithium Polymer) platt batteri | 606090

3.7V 4000mAh uppladdningsbart LIPO (Lithium Polymer) platt batteri | 606090

€ 10,95
PNP-transistor BC327-25 45V 800mA 100MHz 625mW TO-92

PNP-transistor BC327-25 45V 800mA 100MHz 625mW TO-92

€ 0,35
NPN Transistor C1815 GR331 50V 150mA 80MHz 400mW TO-92

NPN Transistor C1815 GR331 50V 150mA 80MHz 400mW TO-92

€ 0,35
NPN-transistor BC337-25 45V 800mA 100MHz 625mW TO-92

NPN-transistor BC337-25 45V 800mA 100MHz 625mW TO-92

€ 0,35
Solenoid 12V Duwen en trekken 300mA | JF-0530B

Solenoid 12V Duwen en trekken 300mA | JF-0530B

€ 7,95
10x Kondensator 330uF 16v Elektrolytisk (ELCO) svart

10x Kondensator 330uF 16v Elektrolytisk (ELCO) svart

€ 2,79
10-polig hona 11 mm hög stapelbar headerkontakt

10-polig hona 11 mm hög stapelbar headerkontakt

€ 0,90
9P Dupont Plastkåpa Pin Connector 2.54mm

9P Dupont Plastkåpa Pin Connector 2.54mm

€ 0,25
Vippströmbrytare MTS-203 6-Pin SPDT PÅ-AV-PÅ

Vippströmbrytare MTS-203 6-Pin SPDT PÅ-AV-PÅ

€ 0,85
WCMCU-5102 modul stereo DAC digital till analog omvandlare

WCMCU-5102 modul stereo DAC digital till analog omvandlare

€ 9,95