VL53L1X sensor fail to measure
Hello,
I want to measure distance with VL53L1X connected to ESP32. I can read correctly vl53l1x reference registers and I initialize without problem but i can't read measures.
I want to get readings by polling.
This is my code:
---------------------------------------------------------------------------------------------------------------------------
VL53L1_RdByte(Dev, 0x010F, &byteData);
VL53L1_RdByte(Dev, 0x0110, &byteData);
VL53L1_RdWord(Dev, 0x010F, &wordData);
status = VL53L1_WaitDeviceBooted(Dev);
status = VL53L1_DataInit(Dev);
status = VL53L1_StaticInit(Dev);
status = VL53L1_SetPresetMode(Dev, VL53L1_PRESETMODE_AUTONOMOUS);
status = VL53L1_SetDistanceMode(Dev, VL53L1_DISTANCEMODE_LONG);
status = VL53L1_SetMeasurementTimingBudgetMicroSeconds(Dev, 140000);
status = VL53L1_StartMeasurement(Dev);
do{
status = VL53L1_GetMeasurementDataReady(Dev,&byteData);
if(byteData == 1){
status = VL53L1_GetRangingMeasurementData(Dev,&RangingData);
printf("Ranging data status: %u\n",RangingData.RangeStatus);
printf("Ranging data: %u\n",RangingData.RangeMilliMeter);}
status = VL53L1_ClearInterruptAndStartMeasurement(Dev);
vTaskDelay(140 / portTICK_PERIOD_MS);
}while(1);
---------------------------------------------------------------------------------------------------------------------------
The status of every function is 0 until VL53L1_GetRangingMeasurementData(Dev,&RangingData) function, where the return status is -13, VL53L1_ERROR_CONTROL_INTERFACE.
This is how I show the return stuts of every functions:
---------------------------------------------------------------------------------------------------------------------------VL53L1X Model_ID: EA
VL53L1X Module_Type: CC
VL53L1X: EACC
status boot: 0
status DatInit: 0
status StaticInit: 0
status SetPresetMode: 0
status SetDistanceMode: 0
status SetMeasurementTimingBudgetMicroSeconds: 0
status StartMeasurement: 0
data ready GetMeasurement: 1
status GetMeasurement: -13
Ranging data status: 255
Ranging data: 4294967295
data ready GetMeasurement: 0
status GetMeasurement: 0
---------------------------------------------------------------------------------------------------------------------------
As you can see, in the first polling, the status of GetMeasurement function is -13, the flag os dataready is 1, but the measurement is wrong. After that, in all pollings, GetMeasurement status is 0 but data is never ready.
