Skip to menu

Robotics with Object Pascal

ESP32-S3 super mini experience

Laser distance sensor VL53L0X

2025.04.27 21:29

me Views:219

#include <Wire.h>
#include "Adafruit_VL53L0X.h"

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

void setup() {
  Wire.begin(4,5);
  Serial.begin(115200);

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }
 
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power
  Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;
    
  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }
    
  delay(100);
}

 

Laser_Distance_Sensor.png

 

 

No. Subject Author Date Views
Notice For the first time user of ESP32-S3 super mini users. me 2025.04.25 238
11 Object Pascal App getting data from ESP32-S3 (Parsing) file me 2025.04.29 223
10 Sound Sensor Test file me 2025.04.27 218
» Laser distance sensor VL53L0X file me 2025.04.27 219
8 9DOF : Getting Pitch & Roll with ICM20948 v2 file me 2025.04.27 222
7 Formating output file me 2025.04.27 220
6 Blinking Built-in RGB without delay() me 2025.04.25 876
5 Built-in RGB led Demo me 2025.04.25 211
4 Servo Demo me 2025.04.25 212
3 HMC5883L Compass demo file me 2025.04.25 227
2 I2C Address Search file me 2025.04.25 225
1 Serial Sample (ASCII Table) me 2025.04.25 213