IR Beam Based Object Crossing Detector

Hi, I am trying to make an IR beam that when crossed/broken triggers something to happen. I was thinking of using IR LED's and IR photodiodes like this.

I am struggling on how this gets wired to an arduino and what else I need such as resistors, etc. The thought is the IR LED could be on all the time and the sketch would poll the photodiode and determine when the beam was broken.

I am a bit of a noob so not sure the direction to go. I see a bunch of photodiode stuff out there but it seems more about proximity / distance and everyone seems to take a different approach. Some thoughts or guidance would be appreciated!

heatvent:
Hi, I am trying to make an IR beam that when crossed/broken triggers something to happen. I was thinking of using IR LED's and IR photodiodes like this.

I am struggling on how this gets wired to an arduino and what else I need such as resistors, etc. The thought is the IR LED could be on all the time and the sketch would poll the photodiode and determine when the beam was broken.

I am a bit of a noob so not sure the direction to go. I see a bunch of photodiode stuff out there but it seems more about proximity / distance and everyone seems to take a different approach. Some thoughts or guidance would be appreciated!

I just Googled "ir led circuit" and found a bunch of images that show schematics. Looks like the second one will certainly do what you want.

Paul

That is only a photo diode so the output is tiny and it needs amplifying before the signal will be big enough for an Arduino to detect. Also the range of this beam will be quite small.

For an example of what you need to do is in this project:- Sneak Thief

If you want a bigger range then you need to use a TSSOP 4038 for a reciever and you will need to modulate ( switch on and off at 38KHz ) your LED. That gets you the sort of range of a TV remote.

Couldn't you drain an INPUT_PULLUP through that photodiode?

Modes of Operation (Photoconductive vs. Photovoltaic)
A photodiode can be operated in one of two modes: photoconductive (reverse bias) or photovoltaic (zero-bias). Mode selection depends upon the application's speed requirements and the amount of tolerable dark current (leakage current).

Photoconductive
In photoconductive mode, an external reverse bias is applied, which is the basis for our DET series detectors. The current measured through the circuit indicates illumination of the device; the measured output current is linearly proportional to the input optical power. Applying a reverse bias increases the width of the depletion junction producing an increased responsivity with a decrease in junction capacitance and produces a very linear response. Operating under these conditions does tend to produce a larger dark current, but this can be limited based upon the photodiode material. (Note: Our DET detectors are reverse biased and cannot be operated under a forward bias.)

Photovoltaic
In photovoltaic mode the photodiode is zero biased. The flow of current out of the device is restricted and a voltage builds up. This mode of operation exploits the photovoltaic effect, which is the basis for solar cells. The amount of dark current is kept at a minimum when operating in photovoltaic mode.

Dark Current
Dark current is leakage current that flows when a bias voltage is applied to a photodiode. When operating in a photoconductive mode, there tends to be a higher dark current that varies directly with temperature. Dark current approximately doubles for every 10 °C increase in temperature, and shunt resistance tends to double for every 6 °C rise. Of course, applying a higher bias will decrease the junction capacitance but will increase the amount of dark current present.

The dark current present is also affected by the photodiode material and the size of the active area. Silicon devices generally produce low dark current compared to germanium devices which have high dark currents. The table below lists several photodiode materials and their relative dark currents, speeds, sensitivity, and costs.

]
https://www.thorlabs.com/tutorials.cfm?tabID=31760

What can I say? My black bulb IR detectors act like phototransistors.

As to "beam", restrict the view of the detector to a target light source and you have your beam. The IR led emits a cone, makes it easier to aim. If both were focused it would be hard. You can color a piece of cardstock black on one edge and roll a tube with non-reflecting inside just big enough to fit the detector bulb in one end and tape it up good, see how it works.

Hi,
Something like this;

Tom.. :slight_smile:

lasers.... eyes.... dumb accidents like whups I tripped

Paul_KD7HB:
I just Googled "ir led circuit" and found a bunch of images that show schematics. Looks like the second one will certainly do what you want.

Paul

Thanks Paul, I was having trouble using Google. How did you think of that :). Can you tell me exactly the one that shows how to do this with a photodiode and an Arduino.

Grumpy_Mike:
That is only a photo diode so the output is tiny and it needs amplifying before the signal will be big enough for an Arduino to detect. Also the range of this beam will be quite small.

For an example of what you need to do is in this project:- Sneak Thief

If you want a bigger range then you need to use a TSSOP 4038 for a reciever and you will need to modulate ( switch on and off at 38KHz ) your LED. That gets you the sort of range of a TV remote.

The range I need is about 6-7 in. The led and the photodiode will both be mounted in a recess aimed directly at each other. Will this suffice? If not, what if I were to use a phototransistor instead of a photodiode.

It was the third circuit. Like this.. Your photo diode is a transistor. Light absorption turn the transistor on. Should work fine for that distance and shielding from stray light is important.

Paul

So I gave it a try and no joy. I also tested the LED's and photodiode IR receiver using this setup:

I was able to get the LED to light so it worked. I also tested the arduino setup with a TV remote and got pin 4 to read low when repeatedly using the remote at close range. What am I missing here?

Thanks

You should be able to see a lit IR led as a white dot with any cheap CCD camera. Your phone might have one, web cams do.
When you do, point the camera at a lit red led. Does it look red in the picture? See if it's not a white dot too.

From your description of the TV remote getting action I wonder if your IR led is always working or not when you use it since you can't see it. A red led especially at close range should work and you can see if it's lit.

I built my 1st IR light beam on a breadboard and had some part backward and was missing a resistor. When I fixed the polarity I smoked my first IR led which.. smells "funny" in a not-good way.

Hi,
I this the circuit you are using?

Or this circuit?

Do you have a DMM?

Thanks.. Tom.. :slight_smile:

So I gave it a try and no joy.

OK so we need to know what you actually did, not what you were following.

The simplest way to do that is to take a clear photograph of your hardware showing all the wiring and post that.

Then we can check against what you thought you were doing against what you actually have done.

I may have bought phototransistors, Evil Mad Scientist sells them.

I know it's off topic but while I was on that site I saw conductive rubber cord that increases resistance as it stretches.... $10/meter.

I looked more and found this: Difference Between Photodiode & Phototransistor (with Comparison Chart ) - Circuit Globe

The reverse bias is where the cathode gets +V, anode gets -V and light causes current to flow, but it's going to be little compared to a proper-biased phototransistor. Still, can it ground an INPUT_PULLUP pin? I don't know if you could see a led lit by that weak 5V so maybe it can work.

I know it's off topic but while I was on that site I saw conductive rubber cord that increases resistance as it stretches.... $10/meter

A cheaper alternitave would be to knit your own sensor as I showed in an article here

Down load it here The MagPi magazine

Video here Stretch - YouTube

Conductive thread is a lot cheaper and IME rubber tends to dry out and snap.

Congrats on having a column in a Maker magazine! Still a few Gromit's in England then?

TomGeorge:
Hi,
I this the circuit you are using?

Or this circuit?

Do you have a DMM?

Thanks.. Tom.. :slight_smile:

Tom, I did the second one. I followed the guide at the page that diagram is posted on here:

FYI, I am using LED's / receivers something like these..

https://www.aliexpress.com/item/10pcs-LED-5mm-940nm-IR-Infrared-Receiving-Diode-Round-Tube-Black-Light-Lamp-Receiver-5MM-led/32803747644.html

The description is usually that the receiver is a diode, not a phototransistor. Personally, I don't fully understand the difference but a lot of the guides (including the one you linked) mention phototransistors so I am thinking that might be the difference.

Assuming a DMM is a digital multimeter? If so, yes I have one.

Thanks for the help.

So what part of:-

Grumpy_Mike:
OK so we need to know what you actually did, not what you were following.

The simplest way to do that is to take a clear photograph of your hardware showing all the wiring and post that.

Then we can check against what you thought you were doing against what you actually have done.

Are you having trouble understanding?

You can detect light with a led. Plug a led long leg into Uno A0 and the short leg into nearby GND. Make a sketch to analogRead A0 about once a second to let it build up a charge under light. I get a volt or so out of a red led in room light, might get more with a white led. Each junction makes weak current when light falls on it, there is a Mitubishi white paper on some uses of that and an Arduino Playground sketch to run a led that adjusts itself to background level (saving eyes and batteries).

Using a led as a photodiode --- likely a poor one:
https://playground.arduino.cc/Learning/LEDSensor

Using LEDs as photodiodes (light sensors):
Background:

LEDs are commonly used as lights, but then can also be used as photodiodes to detect light. Normally, LEDs are turned on by driving current from the anode ((+) side, indicated by a longer leg) to the cathode ((-) side, indicated by a shorter leg) [see the crude text-based schematic in the comments of the code below]. This is known as "forward biasing" the LED. However, photodiodes are designed to operate in "reverse bias". In reverse bias, LEDs (or photodiodes) can be used to sense light in two ways: 1) photovoltaic mode, where the photodiode generates a tiny voltage (like a solar cell) proportional to the incident light, and 2) photoconductive mode, where the diode turns "on" and allows more current flow to be driven through it, proportional to the incident light. In photovoltaic mode, a positive voltage is generated on the LED's anode [again, see schematic below], with the potential to drive a current into the cathode and out of the anode. In photoconductive mode, you place a positive voltage on the LED's cathode (ie: the LED is reverse-biased, and will not emit light this way) from a voltage source. The more incident light that strikes the LED, the more it turns "on" as a photodiode, allowing current flow into the cathode and out of the anode.

Example:

This example circuit uses a single LED as a photodiode in photoconductive mode to sample the ambient light level and then glow at an appropriate brightness. It is tragically flawed by a slow refresh rate in the dark, but nonetheless it shows how to sense light.

The Playground is under the COMMUNITY link up top of the forum here. It's loaded with Arduino projects.

Even more comprehensive:

Photodiode

Photodiode is in the class of photo junction device which is basically a PN junction light sensor. They are generally made from semiconductor PN junctions and are sensitive to visible light and infrared light. When light is incident on a Photodiode, the electrons and holes are separated and will allow the junction to conduct.

If it can allow an INPUT_PULLUP pin to ground then you have a switch your finger won't voodoo.
That depends on how much light/IR hits the detector. If it's at the bottom of a tube aimed right at the IR led (could use analog reads to find the peak), it will only miss light from outside the narrow view. The difference between dark and light will be large. Remember the goal is to ground a very weak 5V or not switch action, it's not necessary to raise 2.8V (5V AVR HIGH) positive signal when you can ground 5V through at least 20K impedance. It don't take much to drain that.

So, I was wondering if it would be better to use a phototransistor so I ordered a few from a guy locally on ebay. Thanks for all the tips but my electrics knowledge is pretty limited and I am looking for a simple solution that is for the most part plug and play. I am hoping this will be a little better to work with. Let me know if I am going down the wrong path.

BTW, I did get a LDR to work. I just didn't like the fact that the ambient light in the room drove large variations in how this worked. So I thought IR would be better (although not perfect).