Phototransistor usage in 3.3V system

Thanks so much. I get some stuff ordered right away.

Looking at the data sheet of the NJL5902R-2-TE1, I can’t tell for sure the orientation of the chip. The pads on the bottom, one is L shaped. Is that the Emitter? It seems slightly ambiguous in the diagram.

Looks like anode to me based on typical conventions for multi-view drawings. It’s indeed a thing that could’ve been made clearer.

I agree that the “L” shaped pad is the anode. Standard engineering drawings rotate the part 90 degrees from one drawing to the next (top, side, bottom, from left to right in that set of drawings) so the anode is going to be on the top right position on the right-most drawing.

Therefore, the emitter of the photo transistor is in the top left position in the right-most drawing.

1 Like

Confirmed. I asked the company and they said it is the Anode.

Ugh, I’ve been working with this NJL5902R-2-TE1 for about a month now, and it has been exhausting! with it being inside my enclosure and needing a light pipe to the outside world, I think it gets a lot of static light. My light pipe is a 3mm x about 5mm, coming down close to the component. It works great, but not consistent. sunlight is there real threat. Sunlight would saturate my analog pin right up to 800-900, and covering the light pipe with my finger would hardly even change it. Light must seep in like water! Then indoors, the different types of light like you say, give off different amounts of IR. So sometimes I’d get readings like 100 or 300, and sometimes like 40 or 50. but then 800/900 near a window or outside. I added a calibration routine to my code, but even still, a little light change or shadow… no good.
It’s too bad the APDS-9960 has gone obsolete. there’s one built on the Feather Sense, which I used in my first version, and it worked, thru a light pipe, aways. it didn’t do all the fancy gesture sense stuff, but it always could give me a reliable on/off state from a finger cover.
This NJL5902R-2-TE1, I’m currently experimenting with the emitter turned off completely. so it only detects IR from my ambient light, and it calibrates itself on startup. I had to greatly change the R value in the voltage divider, but I did get it t where it would work in most lights. Direct sunlight though, is still a no go.
I can hardly believe it is so difficult to get a simple on/off detection from covering a sensor with a finger. When the IR emitter was turned on, my analog value would actually change the way a finger cover was detected! in the bright sunlight, the value actually went down!, then indoors the value would go up, from the reflected light. that was a nightmare. that’s why I disabled the emitter.
I’m about at a loss as to what to try next. I’m thinking of just an ordinary photo transistor. I could have it have a digitally tunable POT, so that on startup it adjusts the reading to a midpoint analog value around 500/600. it sound complex just to detect a simple finger covering.
I had no idea this could be so difficult. I’m thinking about a capacitive touch sensor. but I can see drawbacks to it as well. like false taps on my IMU.

I’m looking at the https://www.digikey.com/en/products/detail/vishay-semiconductor-opto-division/VEML7700-TT/6210690
and wondering about how it might perform in various lighting situations. adafruit has a BOB and library to test it out.
https://learn.adafruit.com/adafruit-veml7700

If the Arduino analog pin is responding that much with that much variance, you may want to consider adding a small 5V+ capacitor to ground from the analog pin connection. The online recommendation is anywhere from 10 to 100nF. You may also want to setup some kind of map function if the sensor is providing way too high values. There are a lot of methods to get the analogRead to work properly. It can be quite a pain.

the analog pin wasn’t the problem. I could get it into a satisfactory range, but I’d have to manually adjust the R value on the divider. So, with the extreme differences in light it’s about impossible to get it to work in all scenarios with any one given adjustment. I’m thinking the veml7700 might be much better. It has built in filtering, and gain control features.

1 Like

Hi SouthernAtHeart,

I’m not clear as to why cap-touch wouldn’t be a viable solution, but you have never explained what your device actually is/does, and this may be important. Cap-touch would most likely solve most, if not all of your issues of properly sensing a finger touch. If you are worried about sensing motion with a touch in your IMU, I could imagine a software solution which automatically filters out any motion sensing concurrent with a touch detection. Also, if a capacitive touch could cause an undesired motion detection event, couldn’t a finger touching a light pipe do the same?

Regardless, the veml7700 may well be a reasonable solution. It’s high dynamic range largely takes care of the saturation problem with standard photo transistors. No need for potentiometers and such with that.

From an algorithm perspective, I would think that one would want to regularly monitor the output for current ambient conditions and then look for significant temporary drops in measured light followed by a return to a value near the previous ambient condition. If the temporary dip of the specified duration (you’d have to characterize what is too short and what is too long a duration for a finger touch) is of a large enough percentage (I would lean toward a percentage change rather than an absolute magnitude change, as the magnitude of change under low-light conditions would be much much smaller) then you could consider that a positive detection event.

If you go with this method, it would resolve the effectively zero light condition problem of false detection when sitting in a dark environment unused, as it’s looking for temporary changes rather than just getting a measurement below some predetermined value.

Even with the method described, I would expect that it would still give false-positive detections on occasion, as one cannot account for all random temporary light changes, but with trial and error, I would think it could get pretty decent results.

1 Like