I'm making a sensor that will be triggered when there is an object between sender and receiver. At the moment I'm using laser on one side and photo-diode on another. But its quite difficult to align laser to hit exactly 5mm photo-diode from 4-5m distance and sometimes a sun can cause errors. So I'm thinking about making something more reliable. The idea is to use IR detector like TSOP38238 as described in adafruit and IR led blinking at 38kHz (maybe even 0.5W led, for better distance between receiver and transceiver). The question is are those IR detectors reliable in outside conditions: direct sunlight, rain, snow, low temperatures (-15C) etc.? Well, temperature I think will be OK (it is written in datasheet), but what scares me the most is a sunlight.
To overpower the sun, you probably should consider going back to IR LEDs. get very narrow-range ones and use several of them in a tight cluster. This gives you several degrees of allowable mis-alignment and still being within the 50% cone of visibility.. The idea being to overpower the sun with the focused energy. Modulating the signal helps, but make sure you use something that can capture and read the signal (usually at 4x faster sample rate from the signal) to help while filtering out the background noise. The other thing that helps is installing a shield to block out light that is coming in off-angle from your sensors. a good shield could be as simple as a narrow tube painted flat black inside, with the receiving sensor in the back of the tube. The length and diameter of the tube can be adjusted to allow for mis-alignment, but the sensor needs to be far back enough to reduce outside light being allowed to reflect in and drown out your signal
You can put the detector at the bottom of a long thin tube painted flat black inside. It will be very hard to aim at but you can use the detector itself to help with that. Use a fatter tube to hold the laser or just shade it well. Light through air is straight line for your purposes, you just need to make sure not enough sunlight reflects straight into the tube with the detector to overpower the laser intensity.
If you can't aim well enough with a laser then try a bright red or IR led. Red leds put out enough IR to blind CCD cameras with IR filter in place (shine one on a webcam, what color is the dot on your screen?) and have loads more dispersal than your laser (read: a hell of a lot easier to aim, like a shotgun as opposed to a rifle). Set your detector deep to cut the angle of light coming to it and shade the led so it has a dark background and see if you don't detect it. What's it gonna cost to try?
You can test the principle easily enough. Look through a thin tube with dark inside at a dark spot across 10 meters out in bright sunshine and if the dark spot looks dark then you ain't getting much sunlight. I can curl my hand and look through it to do that to a good degree.
Find a laser module with a focusing element and "unfocus" it. You can get a pretty large spot.
How many milliwatts is your laser? For that matter, how many is a regular 5mm led?
This is very easy to do with IR, much easier than everyone is suggesting.
My lap timer project uses a single IR Emitter LED driven by 555 Timers at 38Khz this single LED is enough to trigger the lap timer wen it is installed in an RC Car travelling at 60Km/h.
As goforsmoke has suggested the detector needs to be shaded in an enclosure of some sort, I used a small project box and spray painted the insides with non reflective/ultra flat camo paint. The detected is mounted about 20mm back from the enclosure opening.
Lap timer in action and the transponder build - http://rcarduino.blogspot.com/2012/09/lap-timer-build-along-part-3-timer.html
As for sunlight, Dubai has more of that than just about anywhere else in the world and the simple system works very well here.
Thank for replies! Now I'm trying to make it with IR, something similar to DuaneB solutin, but I'm generating signal not with 555's but with attiny25 on external oscillator. I'll write when everything will be made, working and tested :)
I have made an ir sensor which works perfectly in the presence of sunlight, I have uploaded a video on it in youtube In that video you can see it works in sunlight https://youtu.be/2FrFF1TFNIM Thank me later
This is completely sunlight proof ir sensor Time delay can be adjusted Sensing range can be adjusted Only need to connect motor to the circuit To see the working video click this link https://youtu.be/zTQXZB94lB8