Sceadwian said:
It should be relativly resistance to ambient light, but direct sunlight is not to be triffled with, it can so overpower even a modulated signal that the receiver can't detect it. IR outdoor on a sunny day is a bad idea at best.
I agree that operating an IR detector in sunlight presents certain challenges, and some may not consider it a "good" idea. That is not to say it will not work. It may be the only option, and can work quite well.
As an example, I have attached two photos of a latch/cam that is open and closed. The problem was to detect the state of the latch. The distance from the metal frame (yellow) to the object was about 1 to 2 cm. Various options were tried. A wiper wire worked, except in the outdoors, rust on the surfaces made it tempermental. Inductance was tried, but the distance was just a little too great, and the steel frame created its own set of problems. Common ultrasonic was not sensitive at that distance. High-frequency (e.g, 500 KHz) ultrasonic had too narrow a detection window. Capacitance was too sensitive to other happenings in the environment.
Thus, I went to IR. The IRED emitter is seen on the surface of the plastic cover as the round object with the lens. The detector is under the filter, which is just smoked plastic. The following link gives the reference to where I got the idea, program, and schematic.
https://www.electro-tech-online.com...etection-using-tsop1738-with-pic16f628.30480/
In short, the device has worked outdoors for over a year in various lighting conditions from cloudy and rainy to bright sunshine. It has never failed to detect the state of the latch, nor am I aware of any false signals it has given.
John
Edit: The short piece of blue tape makes the approximate location of the IR detector.