How Can I get 8000mm ranging on the using the stmduino VL53L1 library?
I'm using the library here: https://github.com/stm32duino/VL53L1, and it seems to stop measuring around 3.2-3.5 meters. I may be wrong, but think that means that it is not using the histogram? I set it to long distance ranging mode.
Here is my code:
bool Sensor::ConfigureSensor(TOF &tofSensor)
{
Log.noticeln("Configuring [%s]", tofSensor.name);
if (tofSensor.sensor_object == nullptr)
{
Log.fatal("No TOF sensor object initialized.");
return false;
}
VL53L1_Error status;
status = tofSensor.sensor_object->InitSensor(tofSensor.address);
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.fatal("Failed to initialize %s. Status: %d. Halting.", tofSensor.name, status);
while (1){;}
return false;
}
Log.noticeln("%s address set to 0x%x", tofSensor.name, tofSensor.address);
status = tofSensor.sensor_object->VL53L1_SetPresetMode(VL53L1_PRESETMODE_RANGING);
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.errorln("Failed to set preset mode for %s", tofSensor.name);
return false;
}
status = tofSensor.sensor_object->VL53L1_SetDistanceMode(VL53L1_DISTANCEMODE_LONG);
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.errorln("Failed to set distance mode for %s", tofSensor.name);
return false;
}
status = tofSensor.sensor_object->VL53L1_SetMeasurementTimingBudgetMicroSeconds(200000);
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.errorln("Failed to set timing budget for %s", tofSensor.name);
return false;
}
VL53L1_RoiConfig_t roiConfig;
roiConfig.NumberOfRoi = 1;
roiConfig.UserRois[0].TopLeftX = TL_X;
roiConfig.UserRois[0].TopLeftY = TL_Y;
roiConfig.UserRois[0].BotRightX = BR_X;
roiConfig.UserRois[0].BotRightY = BR_Y;
status = tofSensor.sensor_object->VL53L1_SetROI(&roiConfig);
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.errorln("Failed to set ROI for %s. Status: [%d]", tofSensor.name, status);
return false;
}
status = tofSensor.sensor_object->VL53L1_StartMeasurement();
delay(10);
if (status != VL53L1_ERROR_NONE)
{
Log.errorln("Failed to start measurement for %s. Status: [%d]", tofSensor.name, status);
return false;
}
return true;
}