stabilize the reading of an optical sensor under varying environmental lighting

hi
i am using FC-51 IR module to detect an item falling into a basket. the sensor readings are varying based on the ambient light. i.e under dim and bright light conditions. how to nullify these external lighting effects and stabilize the sensor readings.
thanks in advance

With that module you have no other chance than to shield the ambient light from the sensor (using a kind of mask). It's a rather bad choice for the task you're describing.

Those modules indeed read any incoming IR light. Doesn't matter if it's the reflection of their own LED or ambient IR.

Use modulated IR instead. Most break beam sensors work that way.

You might be able to get away with comparing the current reading to a low-pass-filtered reading (for example, a moving average of the last 10 readings).

The filter will adjust for the change in ambient light, but large changes can in principle still be detected. This won't work if ambient light saturates the detector.

thank you. i will try your suggestions

jremington:
You might be able to get away with comparing the current reading to a low-pass-filtered reading (for example, a moving average of the last 10 readings).

I thought that particular sensor only has a digital output: obstacle or not. Not much filtering there.

I thought that particular sensor only has a digital output

You are right and filtering won't work. I didn't look closely.

Some sensors like that have an analog output as well, which is more useful in such cases.