Look at the RangeStatus - this is not the status from the function call, but the status the sensor returns. It tells you what might have gone wrong.
When you get the distance, you also get a signal return, along with the status and a Sigma.
Did your signal strength change a lot?
If your sensor partially rebooted (which can happen) the distance and signal strength stay exactly the same.
If you see this, then check that you are not starving the sensor of power. It uses quite a bit in very small bursts, so you might look there. Also check there is no noise on the XShut line. That can also cause a partial reboot.
2M is a strange number. Generally, when something goes completely wrong, you get an 8192 minus the error.
So typically, 8191 or 8190.
The VL53L1X averages all the photon times it gets back. So, if you have a target at 100mm and another at 3M, and both are in the field of view, you can get an average of 2M.
There is a Sigma return, that give you the standard deviation of your result. It should be small, but with two widely different targets it could be large indeed.
What about ambient light? Sunlight really screws up the sensor. But if you were getting ambient issues, a reboot would not fix it. The amount of ambient is also returned.
- john