I'm impressed. Cool idea.
So lets talk accuracy. Generally the sensor claims +/- 3%, but below 10 or 15 cm, that breaks down and you get something like +/- 5mm. Do check the datasheet.
But you are seeing something more than that.
So by giving a quick glance at your code I see that you are NOT setting a timing budget or Inter-measurement period.
that means the sensors are emitting continuously, and although the sensors done generally interfere with each other there are limits, and you found them. With 4 sensors emitting inside a box, that box is too full of light.
So this is what I think you can do...
Start one up, take 3 measurements, then shut it down. Evaluate the results. I'm thinking the last range will be best, but an average of the last two might be better. You can either shut it down by dropping the XShut line (which requires a re-init) or you can issue the stop command, which will retain all your setting and just re-issue the start when you want to go again.
then repeat for the other sensors.
By NOT interfering with each other, you will do better.
Consider changing the timing budget to something like 100ms if you can afford the power and time.
That will give you the best shot at a great answer.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
