We built a smart mailbox, as related in an article, that had an ambient light sensor to detect when the mailbox door was opened. In that project we used a Vishay ambient light sensor (Mouser Part #782-TEPT4400) that acts very much like an NPN transistor, in fact the part is also referred to as a phototransistor. The difference being (when compared to a normal bipolar junction transistor) that instead of needing a base lead to setup the bias voltage, photons provide energy at the base-collector junction to turn the transistor on, thus allowing current flow from collector-to-emitter.
In that project we were solely worried about the presence or absence of light, not accurately measuring the intensity of the light. Thus we got away with a pretty simple voltage divider circuit to measure the light. In other applications you might be concerned with accurately measuring the light intensity with greater resolution. If your project needs that accuracy, there are many circuits that can give you that resolution. One particular implementation utilizing an operational amplifier (op-amp) is this circuit here:
An advantage to this circuit is that it provides a nice, clean linear voltage output as a function of the amount of light hitting the phototransistor.
One caveat about using phototransistors vice other optical detector components such as photodiodes, while they have better responsitivity (measure of output voltage per unit of optical input), it comes at the expense of longer response times for the output voltage to reflect changes in the amount of light striking the base-collector junction. Therefore, different optical components may be required if you need to deal with extremely fast-changing light sources such as high-speed digital optical communications applications.
Michael Parks, P.E. is the co-founder of Green Shoe Garage, a custom electronics design studio and embedded security research firm located in Western Maryland. He produces the Gears of Resistance Podcast to help raise public awareness of technical and scientific matters. Michael is also a licensed Professional Engineer in the state of Maryland and holds a Master’s degree in systems engineering from Johns Hopkins University.