SparkFun Forums 

Where electronics enthusiasts find answers.

Questions &/or issues related to products in the Distance & Infrared category should be posted in this forum.
By steevie
#202082
Hi,
I´m trying to use the ROI funktion of the VL53L1X Sensor on ardiuno.
Im using the SparkFun VL53L1X 4m Laser Distance Sensor Library V1.1.4

I used the setROI(x, y) function to change the ROI.

1. If I change the first value in the function
distanceSensor.setROI(4, 16);
the sensor stops working at all.

2. If I change the second value nothing changes.

I build the following code in the loop to check the functionality with the serial plotter:
Code: Select all
  distanceSensor.setROI(16, 16);
  delay(100);

  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.stopRanging();

  //Serial.print("Distance(mm): ");
  Serial.print(distance);
  Serial.print("     ");



  distanceSensor.setROI(4, 4);
  delay(100);

  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.stopRanging();

  Serial.print(distance);
  Serial.println();
can you please help me to change the ROI?
thank you :)
User avatar
By TS-John
#202389
Hi. Thanks for posting on the SparkFun forums.

Is the issue that your product does not work at all, or is the issue that the modifications to the code you are making are not working?

Could you provide a screenshot of the output of output from this device on a serial terminal using the default code provided on the hook-up guide?

Thanks.
By LMario
#202800
I have a similar problem with the VL53L1X sensor:

If I change the ROI with:

distanceSensor.setROI(14,14); // Works well

distanceSensor.setROI(12,12); // Works well

distanceSensor.setROI(10,10); // Doesn't work. Only send a good a good measure and the next not.

171.80 cm
6553.50 cm
6553.50 cm
6553.50 cm
6553.50 cm
6553.50 cm
6553.50 cm
6553.50 cm

How you can see only the first value is OK.

I attach the code I use.
Code: Select all
#include <Wire.h>
#include "SparkFun_VL53L1X.h"
SFEVL53L1X distanceSensor(Wire);

void setup() {
  Serial.begin(9600);

  // INITIALICE DISTANCE SENSOR
  Wire.begin();
  Serial.println("VL53L1X Qwiic Test");
  if (distanceSensor.init() == false)
    Serial.println("Sensor online!");
  distanceSensor.setROI(10,10);
}

void loop() {
  // GET THE DISTANCE
  distanceSensor.startRanging();                                                // Write configuration bytes to initiate measurement
  distance = float(distanceSensor.getDistance()) / 10;                          // Get the result of the measurement from the sensor
  distanceSensor.stopRanging();
  Serial.println(String(distance)+" cm ");
  delay(1000);
}