Phototransistor usage in 3.3V system

I’m using a 3.3V Arduino, and want to use these two phototransistors on my custom PCB:
https://www.digikey.com/en/products/detail/sunled/XZRNI56W/13559342

and

https://www.digikey.com/en/products/detail/würth-elektronik/1540052NA3090/12368509

The second one is the exact one used in the DigiKey blog “How to Use a Phototransistor with an Arduino” (I can’t post the link, due to new user 2 link limitation)

I have two questions:
will they work with a 3.3V (I’m using the Adafruit feather sense board) The data sheet for the PTH component says 5V max. But I’m not sure if that means it will work on 3.3V?
and do I need to change the 10K resistor in the voltage divider?
thanks.

https://www.digikey.com/en/maker/blogs/2022/how-to-use-a-phototransistor-with-an-arduino

This is the maker blog I’m going by.

Hi SouthernAtHeart,

Either phototransistor would likely work with a 3.3V system, though the XZRNI56W appears to conduct far less current than the 1540052NA3090 (about 2.7% as much for a given irradiance), so it will likely require a much higher R1 resistor value to get a measurable output voltage.

The XZRNI56W would probably not perform as well, for a few different reasons, and neither would likely work quite as well at 3.3V. Affecting both parts is that they will have a reduced dynamic range at 3.3V because their minimum voltage (saturation voltage) is greater than zero. The 1540052NA3090 datasheet does not define the saturation voltage, but the XZRNI56W saturation voltage is listed as about 0.8V. This means that the range between the minimum output voltage at R1 (zero volts) and the maximum output voltage (3.3V - 0.8V = 2.5V) is not as great as if running at 5V (5.0V - 0.8V = 4.2V). It would still likely work, but the resolution would be reduced because of the lower dynamic range.

Additionally, especially because of the higher R1 value necessary for the XZRNI56W, the ADC measurements will be somewhat less accurate. This is because the input impedance of the ADC will be in parallel with R1, and a high R1 will cause less accurate readings on your ADC. If this matters in your application, then to avoid this problem, you could add a rail-to rail input/output op-amp such as the MCP6006T-E/OT or MCP6021-I/P configured as a buffer between R1 and your ADC input to negate the effect of a high R1 value.

Buffer amplifier configuration
image

You would also need to lower the value of the LED current limiting resistor (R2), as it’s purpose is to drop the excess voltage from the supply voltage to get the proper current for the Blue LED. A typical blue LED, such as the C503B-BCN-CV0Z0461, will drop about 3.2V at 20mA. This means you have very little margin for the current limiting resistor, but if you went without one, you run the risk of allowing too much current to flow and damaging the LED or burning out the I/O pin of your MCU.

At a lower forward current, the voltage drop across the LED will be reduced, so I would recommend getting a few different values ranging from 100Ω down to about 20Ω, and start with the highest value and work down until you get adequate brightness. Be certain that the LED current never exceeds 20mA. Also keep in mind that if you plan on making multiple boards, that the LED forward voltage will vary somewhat from part to part, so err on the side of a higher resistance value to account for that.

Thanks for your quick response.
In my final application, I will be using the photo transistor as a switch. And not in itself, but rather with an analog pin in my MCU. I will only need it to detect “light” from “dark”, so the dynamic range of the transistor shouldn’t matter to me. And since it’ll be getting a reading from the voltage divider, I can adjust the on/off threshold in my code. I may need to adjust the R value making up the voltage divider, but I can’t really tel from the data sheet what I would need. But I can experiment with different values.
In light of this scenario, Do you think these two photo transistors would work? I am needing one 5mm, PTH, and one SMD, right angle variant. If these will not work, would you have something that you would recommend?
Thanks much

Hi SouthernAtHeart,

In your scenario using it as a simple “go / no-go” application, I’m pretty sure both sensors could be made to work, though the XZRNI56W is a little more questionable due to its much lower light sensitivity (about 400uA at Ee = 1mW/cm2 with 5V Vce). The environment in which these are intended to be used, whether outdoors or indoors, and the nature of your intended light source, could significantly affect the results.

If the XZRNI56W didn’t work out, other options for full visible light spectrum SMT right angle photo transistors would be these:

Thanks. I’ll use the PT12-21C/TR8
Like you suggested. Actually, there’s been a change in my design, and the 5MM PTH variant can be replaced with a SMD one, just not R/A, so there’s probably one just like the PT12-21C/TR8
I’ll see what I find…,
Thanks.

Would this one be suitable for general switching, in a 3.3V system?

The PT11-21C/L41/TR8 will typically put out about twice the current of the XZRNI56W (typically about 800uA vs. 400uA under same conditions).

So, just to be sure we’re looking at the right type of product, what are you actually trying to use these for? Are you looking at detecting ambient light (indoor or outdoor), are you trying to detect a specific light source, or something else?

There are also such things as ambient light detectors, photo logic sensors, and photo resistors (cadmium sulfide cells).

They will be inside an enclosure, that is sealed up, with 3mm light pipes mounted directly over them on the PCB, and then the user will be able to put their finger over the light pipe to activate it as a switch. A normal tactile push button does not work in my scenario because the unit is very sensitive to movement from the onboard IMU.

OK, well, as long as there is adequate ambient light available, it would likely work. However, if not, wouldn’t this dark state then be interpreted as someone activating the “button”?

There are probably other non-contact sensing methods out there that are more likely to give you fewer false positives. There’s capacitive touch, gesture sensing, proximity sensing, etc.

Well, it will be used in a normal lit room, so it should detect a fair measure of light. I’m assuming it would. And the fact that when it is covered with a finger, it will be completely dark, it seems to reason that it should be easy to get a definitive on/off value. Any amount of light at all would represent the off state, vs total darkness an on state. Unless I’m not understand how a photo transistor works. I was thinking it worked similar to a cadmium photocell resistor.

@SouthernAtHeart

A standard phototransistor would allow current to flow through the unit when light is applied to the unit. You would be able to invert this behavior with additional circuitry that can make it behave the way you are needing.

From the data I see for the PT12-21C/TR8 or the PT11-21C/L41/TR8. these should behave normally.

You should wire up a phototransistor to test out the circuit sensitivity with a DMM before committing to a design.

You may find that a finger still lets through too much light in some configurations and with some levels of ambient light. Also that when the lights go out at night, or during a power failure, ambient light is so low it appears as if a finger is acting on it.

This is from my young teen memories designing similar circuits back in the early 70s. Also I suspect there is a very good reason why every commercial product I’ve seen this century with non-contact sensing uses methods other than ambient light sensing.

3 Likes

@PaulHutch has several good points. I think that the likelihood of it working as intended under all expected and unexpected conditions is not great. If the negative consequences of getting a false positive reading of your “switch” is negligible, then it may not matter. However, if it is important that it not false trigger, then I think you should consider alternatives.

I vaguely remembered seeing a simple non-contact finger detection done on a recent eval PCB but couldn’t remember where until now.

Adafruit 5913, generates IR so is not dependant on ambient light, has sensitivity adjustment and has Arduino and other SBC libraries.

The Adafruit product page shows the video I remembered seeing of finger detection in action.

1 Like

Hi Again, after some testing, I see that a indeed a phototransistor is too uncertain for my application.
I have used the APDS-9960 in the past, but this is now obsolete.

I’m wondering if there are smaller optical reflective sensors in SMT packages, and also I need much lower current. the TCRT1000 BOB by adafruit shows 100mA down to 10mA for the IR LED. I will have 4 of these in my tiny battery powered project. But perhaps I can pulse the IR on for a few ms, while taking a reading. This is how the APDS-9960 works, which uses less than 2mA on proximity detection.

edit: perhaps this would work?
https://www.digikey.com/en/products/detail/onsemi/QRE1113GR/965451

(it will be used in a 3.3V system)

I’m planning to go with the VEMT2523X01 (top view version of the one you suggested).
A question for my voltage divider that I’ll be reading from an analog pin:
It’s a 3.3V system, so is there a way to actually calculate the R1 value to give me a good Vout reading? If not, I’ll just use something like a 100K POT to experiment with.
thanks,

Hi SouthernAtHeart,

Trying to catch up on this one . . .

Looks like you’re still considering using ambient light, if you are considering the VEMT2523X01. I still think it’s going to be difficult to make this work consistently under a broad range of ambient light conditions.

I found a set of graphs from here which show typical wavelength distributions for various lighting sources. Note that natural sunlight is quite consistent throughout the visible spectrum (and well into the infrared, too, though not shown on the graph), whereas LED, fluorescent, and incandescent lighting all have significantly different distributions of wavelengths. Not shown is the absolute magnitude differences between the various light sources. Sunlight will tend to be much greater magnitude than the other sources.

This means that your sensor will respond very differently depending on which environment it happens to be placed in. The graph below shows the relative sensitivity of the VEMT2523X01 to various wavelengths. Note that it’s peak sensitivity is at about 850nm, and that it’s sensitivity reduces significantly with shorter wavelengths, such that it will much less sensitive to green and blue (≤ 530nm) as it is to red and infrared (≥ 600nm) wavelengths.

Regarding the resistor(s) – Typically for a phototransistor, one would only use a single resistor either between the collector and Vcc or between the emitter and ground, depending one whether you want negative or positive logic, respectively, on your MCU input pin. Using a larger value will tend to make it more sensitive, though slower to respond. However, speed should not be an issue in your application. I do think that using a potentiometer for the resistor is a good idea, as it allows you to play with it to try to optimize performance. However, as mentioned above, performance could vary considerably depending on the particular ambient light conditions present.

Back to alternative options, have you looked at something like the NJL5902R-2-TE1 reflective sensor. It’s a very small surface mount part with integrated IR emitter and phototransistor. It is designed for close-proximity detection. For power saving, I would recommend pulsing the emitter for a millisecond or two and sensing only during that pulse, and then turning it off between pulses. If you are detecting a finger nearby, one could probably run at something like 1% duty cycle and still be functional.

Here’s the typical schematic for a positive-going output upon detection for the NJL5902R-2-TE1:

Hi. Thanks for your response.
I will order a few things to test out, including those phototransistors I mentioned. But what you suggested sounds very good the NJL5902R-2-TE1

One reason I was shying away from these is the power consumption. But if I can just pulse it on at a low duty cycle that would be very good. I’ll look at the datasheet and try to see what R values I need to bench test it in a 3.3volt environment, and get back with my findings. Thanks.

Edit: I calculated about a 500 ohm resistor would be used on the emitter LED when my voltage in is 3.3 volts. Rd on the schematic. To detect the Voltage output on an 3.3 volt analog pin, what resistor value or POT value might be good to experiment with? That would be ResistorL on the schematic
Thanks

Hi SouthernAtHeart,

I’d agree that 500 Ohms is in the ballpark for the RD resistor value for setting the current to 4mA with a 3.3V supply. For a little better sensitivity, I might suggest lowering the resistor value a bit to boost the LED drive current, at the cost of somewhat worse power consumption. As long as you maintain a low duty cycle, the somewhat higher drive current won’t have a huge impact on your power budget.

Depending on the LED drive level, sensing distance, and reflectivity of the sensed object (presumed to be a finger), it looks like the output current could range from 50uA to about 200uA with no more than a 6mA LED drive current.

For 50uA output current drive to bring the output voltage up to about 3.0V, one would probably need about 60k Ohms for RL. Higher values should make it more sensitive, with a trade-off in speed. However, speed is not a factor in a human interface application, since that is really slow, by definition. I would suggest trying a 100k Ohm potentiometer for RL and a 500 Ohm one for RD.