Showing results for 
Search instead for 
Did you mean: 

Vl53L4CX giving status 255 in alternate cycles above 7cm



I am working on a project where I am using an array of 16 VL53L4CX to measure both the X and Y coordinate of any object in front of my sensor array. I want my loop time to be less than 50ms, so I am using 1MHz I2c clock. Currently I'm able to read from all sensors in 33ms on average. Even though I'm using the blocking function which is VL53L4CX_WaitMeasurementDataReady(), I'm seeing a pattern of no values at times.

Initially when I was not waiting for measurement I was getting around 12 proper readings and 12 no object detections. This behaviour was happening all the time so I decided to use the blocking function. This eventually helped me to correct that behaviour, but now when I read from more than one sensor, 90% of the time I get no object detection or some random reading in alternate loops. I tested the same by placing an object only in the line of sight of one sensor in my array and it works perfectly. In this case all the other sensors were detecting my roof which is around 1.7m. But the moment I place an object in 5cm to 60cm range(I haven't tested above that as my area of interest is 60cm * 60cm) It gives me either no object detection(Range status = 255 ) or some value around 160cm in alternate cycles. I tried waiting until a sensor gives any other Range status but in that case my loop time went to 60 - 70ms and I stopped getting Range status 255, with the reading equal to 170cm when the object is placed somewhere around 15cm.


I have tried the same code with and without cover glass. My circuit uses 2.2k pull up resistor, I tried different pull up values as mentioned in the data sheet but it didn't had any effect. I am changing address of all the sensors on start up and it works fine. I'm using teensy 4.0 and have incremented the i2c buffer length to 255 in wire library, so that blocking function works properly. Any help would be appreciated. Thank you very much.
This is my code.
void init(){
for (unsigned int i = 0; i < 16; i++)
mcp.digitalWrite(i, HIGH);
address = address + 2;
void readDistance(bool instrument, int modSensorsPos, int modSensorsNum)
VL53L4CX_MultiRangingData_t MultiRangingData;
VL53L4CX_MultiRangingData_t *pMultiRangingData = &MultiRangingData;

for (int i = 0; i < 16; i++)
status = sensors[i].VL53L4CX_WaitMeasurementDataReady();
status = sensors[i].VL53L4CX_GetMultiRangingData(pMultiRangingData);
distI[i] = pMultiRangingData->RangeData[0].RangeMinMilliMeter / 10.0; // mm to cm
status = sensors[i].VL53L4CX_ClearInterruptAndStartMeasurement();
ST Employee



This is same issue with below one? let's use below one to track all the information. 


VL53L4CX - Connecting Multiple Sensors - STMicroelectronics Community





In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.