Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

VL53L1X and arduino

When I use VL53L1X controlled by arduino ,it often wrong and shows TIMEOUT. Can you help me find the reason?


Here is my code:

/*
This example shows how to take simple range measurements with the VL53L1X. The
range readings are in units of mm.
*/

#include <Wire.h>
#include <VL53L1X.h>

VL53L1X sensor;
 
void setup()
{
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C
  
  sensor.setTimeout(500);
  
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");

  }
  
  // Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
  // You can change these settings to adjust the performance of the sensor, but
  // the minimum timing budget is 20 ms for short distance mode and 33 ms for
  // medium and long distance modes. See the VL53L1X datasheet for more
  // information on range and timing limits.
  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  // Start continuous readings at a rate of one measurement every 50 ms (the
  // inter-measurement period). This period should be at least as long as the
  // timing budget.
  sensor.startContinuous(50);
}

void loop()
{
  
  Serial.print(sensor.read());
  if (sensor.timeoutOccurred())
  { 
    Serial.print(" TIMEOUT");
  }
   

  Serial.println();
}

Hello, Knight.

I suspect you might have an intermittent connection. Can you post some close-up pictures of both sides of your VL53L1X carrier as well as some pictures of your setup that show all of your connections?

Brandon


Sorry, * I was studying for the exam the other day. This was the picture .

If the connection is disconnected, will the data not be read again after reconnection?Why my sensors always show TIMEOUT?

Hello.

It looks like you are not using our VL53L1X time-of-flight sensor carrier; since it might differ from ours, I cannot give you any more specific advice about it. However, I did notice from your pictures that the soldering on the board looks suspect. There are several joints that are not properly wetting to the pad on the board. You might try reworking those solder joints and trying again. Adafruit’s Guide To Excellent Soldering has some good references for how solder joints should look and how to repair common problems.

Brandon