Skip to main content
Associate III
September 16, 2024
Question

VL53L1X reading returns 0 with error code 31

  • September 16, 2024
  • 2 replies
  • 1186 views

I am getting occasional readings from this sensor of zero(0) reading result with the error code 31.  According to the header file this error corresponds to:

#define VL53L1X_WARNING_OFFSET_CAL_MISSING_SAMPLES ((VL53L1X_Error) - 31)
/*!< Thrown if there is less than the requested number of
* valid samples. */

This is not during Calibration offset process,  which we do use,  but at run time after SetOffset using the stored offset value.  

Very confused why I would get this error,  occasionally,  at run time?

Thanks,

Will

 

 

 

2 replies

John E KVAM
ST Employee
September 16, 2024

That is strange indeed. Something is happening somewhere as that bit combination is not in the hardware of the device. I found nothing in all the documentation I have that shows you can get a 31. 

So if the hardware is not throwing a 31, then you have to dig through the code to see what is going on. 

Sorry to leave you with homework, but I have no clues as to what could be going on. 

Perhaps you could add a check right after the range status is being read to see if you could trap something. 

-john

will3Author
Associate III
September 16, 2024

The #define I show is taken from the vl53l1x.h file.  How is that not in the hardware at all? The header file is from ST. 

will3Author
Associate III
September 17, 2024

Hi John,

One change to my original posting,  I miswrote what the sensor reading.  It is in fact 32256 not Zero. 

Does this tell you anything more? 

Thanks,

Will