LEGO SPIKE distance sensor behaves inconsistently — detects object sometimes but not always
I am working with the LEGO SPIKE ultrasonic distance sensor and I am running into an issue. The sensor behaves inconsistently depending on the lighting conditions — sometimes it detects an object at a certain distance, and sometimes it completely misses it, even though the object and the distance stay the same. More over sometimes one sensor detects the object while the other misses it. On the next attempt, the first sensor detects the object while the other misses it.
I have read through the technical specifications from LEGO, but I still do not fully understand what the sensor is actually measuring and why lighting would affect it. As far as I know, ultrasonic sensors should not be affected by light at all.
Has anyone experienced this before? What could cause this behaviour, and how can I make the detection more reliable?