Phototransistor usage in 3.3V system

I’m using a 3.3V Arduino, and want to use these two phototransistors on my custom PCB:


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?

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

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…,

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.


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.


@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