VL53L1x NON_BLOCKING measurement Python


is it possible to realize the non-blocking method or the physical interrupt driven method for the Raspberry Pi described in the docs from ST? I tried to change the “wait_method” in the api (vl53l1_api_core.c) for measurements to NON_BLOCKING and recompiled/reinstalled the module. But in python I still need about the Intermeasurement_period duration for finishing the “get_distance()” line (from the Python module), which is too time consuming. I simply want to get the last distance measured by the sensor in a given frequency without having to wait for one line of code taking too long.

Any help would be appreciated

Kind regards,


So I tried some stuff on my own, which unfortunately failed. Here is what i tried:
In the “vl53l1x_python.c” file I changed some lines in order to get a non-blocking reading

1.: Introduce new variable/pointer for the GetMeasurementDataReady function
static uint8_t MeasurementDataReady;
static uint8_t *pMeasurementDataReady = &MeasurementDataReady;

2.: change the getDistance() function
int32_t getDistance(VL53L1_Dev_t *dev)
VL53L1_Error Status = VL53L1_ERROR_NONE;
int32_t current_distance = -1;
uint8_t dataready= 0; //new
//Status = VL53L1_WaitMeasurementDataReady(dev); //dont want to wait
Status = VL53L1_GetMeasurementDataReady(dev, pMeasurementDataReady);
dataready = pMeasurementDataReady;//->pready; //is measurement finished //(which parameter is correct here, i dont quite know?)
if (dataready == 1){
Status = VL53L1_GetRangingMeasurementData(dev,
current_distance = pRangingMeasurementData->RangeMilliMeter;
return current_distance;

So in my theory, this should return -1 for most of the time and the actual distance for when the measurement is done. But this doesn`t work like said before. The “if dataready ==1” conditition is probably also never met (do I have the wrong pointer?).

I also played with the original form of the function to determine, which function actually consumes the most time. Turns out that for a setting of 33 ms timing budget and 34 ms intermeasurement time the

VL53L1_WaitMeasurementDataReady() takes 4 ms

while the

VL53L1_GetRangingMeasurementData() function takes most of the time (~ 30 ms). This is quite confusing as I didnt see any waiting commands in the api/core files in this function or in functions used by this function.
I hope that this info can help you understand my situation.