Customer asks, "I am using VL53L1X , code works fine when there is obstacle in the range of 0 to 4 meter ,if no obstacle above 4 meter sensor is giving random values , how we can fix this issue?"
..
..
There is a Range Status that you can read from the sensor. It will tell you what happened. But basically if you don't get a '0' status, something went wrong and you cannot use the result.
This 'Range Status' is not the result of your function. Your 'read_result' function worked just fine. This is a register returned by the sensor giving you the hardware status.
With no object, no photons will be returned, and your Range Status will return a 'no signal' status.
but there are other conditions you should look for.
(Generally the Range Result will be 8192 minus the status, but don't count on it. Check the Range Status.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.