Hello, I'm trying to get an IR photoresistor (TEFT4300) to work. I already did it some time ago but then I left the project and just came back to it some days ago. When I tried it it was working fine. The IR photoresistor was not using an actual IR LED but a normal Red LED because it was capable of getting the analogRead from 0 to, like, 80 and I was able to actually see if the LED was working.
When I moved it from where it was on another spot and rewired it with better soldering in the exact same way it stopped working: the analogRead gives a value of like 70 and doesn't respond to any light, Red or IR.
I tried using another photoresistor with a different Resistor (the first photoresistor is using a 10kohm, the second one is using 2kohm), wiring it to the arduino and now I have two photoresistors, one giving 70 and the other one giving 230, but none of them works with light.
What am I doing wrong?
The wiring is like in the image (the one you see is the second photoresistor I wired, the first is properly soldered)
You seem to have the polarity wrong. Pay attention to the two different ways the
leads are bent dog-legged at the package - that's the polarity indication (lead length
too, but if the leads have been trimmed that's not useful).
Phototransistors don't work backwards - in fact they can be destroyed if connected backwards at
voltages more than about 5V.
Yes, my bad, it's a phototransistor.
The legs are bent at the package-height symmetrically, how should I tell the polarity?
I already tried to switch the legs but nothing changed, I also noticed that if nothing is connected to the analog pin it reads 1000+, if I connect the Emitter to it (and the Resistor to ground) it reads 70, despite if the collector is connected to the 5v or not
Your phototransistor has a dark lens, so daylight (visible light) will be filtered out. For best results, you should use a matching IRLED ... it will have a clear lens. The TEFT4300 phototransistor has peak wavelength around 920-940nm, so the best IRLED to use will also have a matching peak wavelength peak wavelength of 920-940nm. I would start testing using a 10K resistor (looks like you have 2K in the diagram).
I have two photoresistors, one giving 70 and the other one giving 230, but none of them works with light.
Sounds about right (as per your circuit) ... these numbers will climb when you shine infrared light on the phototransistor. If you don't have an IRLED component, maybe one of your remote controls that have clear IRLEDs on them would work.
Perhaps the phototransistor has already been destroyed. Try a new one, and make sure you can tell the difference between the collector and the emitter (study the data sheet carefully).
I already tried 3 different phototransistors and none of them work.
I tried switching legs but nothing changed.
As I said before, I already tried with Red and IR Led light but they always gives the same value
Currently I have 2 phototransistors wired, One with a 2k resistor and the other with 10k resistor, and the one with 10k resistor was working fine before I moved it.
I even tried changing analog pin but it didn't do anything.
I really don't understand what could be the problem
The collector is the shorter pin, the emitter is the longer pin.
Weird, I followed this Introducing the Phototransistor | LEARN.PARALLAX.COM and some other guides and all told me the collector is the longer leg, also when I first built this it was working as the long leg as Collector.
But even if it was the other way around as you are saying I already tried switching the legs and nothing worked.
I'll try a greater resistor (even though it was working with a 10k).
I know I need a matching LED, and I have one, but neither that nor a normal Red LED is working despite the first time I tried it it was fine
Weird, I followed this Introducing the Phototransistor | LEARN.PARALLAX.COM and some other guides and all told me the collector is the longer leg, also when I first built this it was working as the long leg as Collector.
Yes, your right ... the datasheet is misleading (to me).
Do you have a part# for your IRLED?
I know I need a matching LED, and I have one, but neither that nor a normal Red LED is working despite the first time I tried it it was fine
Its all about the wavelength and focus of the lens ... yours is blind except within a narrow range (forget Red) ... it can only respond to a narrow invisible infrared wavelength range. An incandescent light, although visible, also has a wide range of infrared wavelengths. As an experiment, it should respond to this.
Avoid the "aerial" approach to prototyping. It is unreliable and a waste of your time. Get a plug-in solderless breadboard. They have their drawbacks but are still vastly superior to hanging things in midair.
For the moment, forget the Arudino and just focus on getting the response you expect on a voltmeter. Once you have that sorted out (and which leg is emitter and collector, what kind of response to expect from different light sources, etc), then switch to the Arduino for measurement. If that doesn't work using your previously operational code, you might have a fried i/o pin on the Arduino.
For the moment, forget the Arudino and just focus on getting the response you expect on a voltmeter.
I don't have a breadboard but the first phototransistor is actually soldered and doesn't work anyway, I appreciate the suggestion though.
Ok, I'll try this, but I don't think I have fried pins because I'm using two of them, tried different pins and when I plug in other devices they work fine
ariesbreath:
2) Ok, I'll try this, but I don't think I have fried pins because I'm using two of them, tried different pins and when I plug in other devices they work fine
That's a reasonable indication that the Arduino is okay. Still, when troubleshooting a problem it's usually helpful to break things down into smaller chunks to pinpoint the cause of the problem. An obvious step toward doing that is to eliminate any possibility of the Arduino hardware or its code being at fault by temporarily removing it entirely.
Do think about getting a breadboard. They are inexpensive, and consider this: swapping in a different phototransistor will take 2 seconds with a breadboard. Soldering it takes much longer, plus you always run the risk of damaging the device with excess heat (particularly if your soldering skills are not advanced). A breadboard will enable you to do far more experimentation in the same amount of time. Soldering is for when you want to make a debugged design permanent.
S.
srturner I think I'll get the breadboard then, it's a good idea.
As for the phototransistor I just tried to resolder everything and now it gives some life signal. It will start from 250 and go to 300 at best when I shine it with an IR LED directly on the sensor.
I tried it with a multimeter, it gives 4.59v when I probe Collector and Ground (after 10k resistor) but nothing changes if I shine it with the IR LED (the arduino reads from 250 to 300).
It also gives 3.47v when I probe Collector and Emitter (to analog pin) and goes to 3.3v when the IR LED is in front of it.
I'm more confused than before, wasn'it supposed to increase the voltage the more light goes through it?
With a phototransistor, the current through the load resistor is roughly proportional to the light intensity. It does not matter whether the resistor is connected between 5V and the collector, or between the emitter and ground.
You can measure the current either directly, by opening the circuit and using the mA scale on your multimeter, or by measuring the voltage drop across the resistor.
The latter measurement is easier: connect the plus (red) lead of your multimeter to the resistor lead closest to 5V and the minus (black) to the lead closest to ground. Use the Volts scale.
dlloyd:
Is the voltage swing too high with 100K? (it'll be 10x more sensitive than using 10K)
I switched from a 10k to 100k. While with 10k it was sensing from 250 to 300, now it's sensing from 780 to 900 with 100k, and I have to put the IR LED just in front of the phototransistor.
jremington:
The latter measurement is easier: connect the plus (red) lead of your multimeter to the resistor lead closest to 5V and the minus (black) to the lead closest to ground. Use the Volts scale.
I tried this after I switched resistors. The multimeter senses 3.49v when no light shines through the phototransistor and 3.65v when it does. Now it makes at least sense, but damn I still can't get why it's so insensitive while some time ago when I first built it it just went from 0 to 900+
johnerrington:
I'd guess you have the tr connected the wrong way around.
The "tr"? What is it?
Anyway I don't really know what the problem is so I just used a workaround and placed a 680K ohm resistor to Ground and now it kind of works. I mean, I know I should be fine with just 10k but since I can't ge it to work with it I just went this way. Do you think it's ok?
From Datasheet "Filter bandwidth is matched with 900 nm to 950 nm IR emitters"
Well, I guess you have an 820-880 nm IR LED (which are quite common). Yeah, it doesn't take much of a mismatch to get poor response. 10K should be fine with the proper IR LED.