Infrared proximity sensors, such as the Yocto-Proximity, are an effective alternative to pressure switches in order to detect when an object has been placed at a given location. But for reliable and robust use, you must respect a few implementation rules, especially if you put a protective glass in front of the sensor.
The principle
An infrared proximity sensor works by emitting a pulsed infrared light and by detecting its reflection on a potential object in front of the sensor. Using pulsed light enables the sensor to distinguish the reflection from the ambient infrared environment.
Working principle of an IR proximity sensor
By placing the sensor under a transparent window, we can therefore use this type of sensor to detect when an object is placed on a surface, as a replacement for a pressure switch. However, there are a few pitfalls to watch out for, which we summarize below.
Avoiding reflection against the window
A transparent window has a tendency to reflect part of the infrared light. This reflection may let the sensor believe that the object is present when it is not the case. The only reliable way to avoid this issue is to put the sensor right against the window. Don't let even 1mm between the sensor and the window. The geometry of your installation must ensure that there is no space between the window and the sensor if you want to avoid trouble.
Correct placement of the sensor under a window
Transmissivity of infrared light
Although it is transparent to visible light, your window could block a significative part of the infrared light. So take the time to test the transmissivity of your window before it is too late. Generally, the thinner the window, the better your detection. We performed several tests, all conclusive, with a 4mm glass window, a 3mm acrylic glass window, and a 1mm polycarbonate window. But each material is potentially different, so don't trust our tests and perform your own!
Defining an suitable threshold
The Yocto-Proximity returns two results: a detection value between 0 and 1000, and a present/absent binary detection result. The factory-set value for the detection threshold between these two states is in the middle of the detection range, i.e. at value 500. To use the sensor behind a window, because of reduced transmissivity, you must lower the detection threshold, typically to 200. You can configure this threshold with the VirtualHub, or in your own software with our programming library. You should perform your own tests to find the value that is most appropriate given the window that you use.
Surrounding light
Generally speaking, the Yocto-Proximity is quite robust to various ambient lighting conditions. However, don't put it too close to a strong source of infrared radiation such as a plate warmer, because if the infrared sensor is saturated, it won't see anything anymore...