Brief overview of light and choosing a sensor.

In this report I intend to elaborate on some basics of light sensing, and then apply this to a comparison between the two most common and inexpensive sensors: the photoresister(aka photocell) and the phototransistor.

First of all, its helpful to remember that our eyes are sensors - like all light detectors, our eyes have their own spectral response:

The visual spectrum that our eyes can see ranges from about 400-700 nanometer wavelengths of electromagnetic radiation. Just beyond that is infrared - up to appx 10,000 nm. Think of different wavelengths as different colors. Keeping the spectrum in mind really helps when looking at data sheets for both light emitters and detectors, look out for the number listed in nanometers (nm).


Also like light sensors we work with, eyes have a peak sensitivity to certain wavelengths. Ours peak around green / 550 nm. Compare this with a phototransistor's spectral response, which peaks in the longer wavelengths. (below)

In addition to thinking about which sensor to choose depending on its own peak sensitivity, we also should consider what type of light they are sensing. Most white-light emitting lamps give off a wide range of different colored photons (with many different wavelengths from the visible spectrum which combine to form white) ; while LEDs only emit a particular wavelength (color). This makes LEDs pretty monochromatic and emitters of a narrow band of light. To detect an LED you need a sensor that will be sensitive to similar wavelengths. Photocells are the most common as they detect all visible light.

narrow band led emission

Other issues to attend to regarding sensors and light relate to the geometry / viewing angle of their emission or detection. For the sensors, lens styles (if applicable) affect the focal range and field of view. For the light source - some light are omnidirectional, launching light in all directions - others are more focused. In short, each light source has a particular emission spectrum and a particular focal geometry/emitting angle. And detectors have specific response curves in return. (This is why its useful to look at the specs, as well as test out the same lighting condition with different sensors...)

Ideally, peak sensitivity of detector is around the same wavelength of the emissions of the emitter/light source. (especially if used in applications such as a break-beam configuration.) IE the light and sensor are "matched."

Here are some example pairs of compatible light-emitting and light-detecting devices:

-Incandescent tungsten bulbs and photocells -Xenon flashbulbs and photocells -Red laser beam and visible-light-sensitive phototransistors -Infrared emitters and detectors

Photocell vs. Phototransistor

There are many types of light detectors... photodiodes, phototransistors, photoresistors, photomultipliers....How do you choose one type of device rather than the other? I decided to focus this report on the two most accessible and useful for most projects, but am hoping that you will know what to look out for should you need a more specific sensor, based on the concepts presented here. (For example, you can research the photovoltaic effect for infos about photodiodes and solar cells.If you need to detect really fast pulses of light (especially toward the infrared range), photodiodes are ideal.)

Silicon phototransistors and Cadmium Sulfide (CdS) photocells are the most common and least expensive forms of light sensing. Both of these sensors incur less current flow when darkened than when lighted. Phototransistors change their conductance; photocells change their resistance depending on the intensity of the light falling on them. Other kinds of light sensors include photodiodes and solar cells (a type of photodiode) .

To begin with, photocells are extremely easy to work with, being just variable resistors controlled by light intensity, but their response time is slow compared to the phototransistor’s semiconductor junction. This means photocells are suitable for detecting levels of ambient light, or acting as break-beam sensors in low frequency applications. They are best at detecting presence of light. Photocell readings are more likely to continuously vary between extremes, and they detect ALL visible light, which is great if your application needs "presence" detection; not so good if you only want to detect a particular type of light. Applications: Photoresisters are typically used in light and dark-activated circuits and light-sensitive detector circuits, and as break-beam sensors (when ambient light isnt an issue).

The sensitivity and range of a photocell varies from one model to the other, and its material makeup will affect which particular wavelengths it is most sensitive to. Cadmium sulfide photoresisters respond best to light in 400-800 range (the whole visible light spectrum and just beyond) and lead sulfide photocells respond best to infrared.

Other drawbacks to photocells: The resistance specification has a wide tolerance - a max/min ratio of 3 is not uncommon. The resistance also has "long term memory" which depends, at any given time, on the amount of light actually incident on the sensor plus the sensor light history...

The phototransistor is a light-sensitive transistor; essentially a light-sensitive current source: the more light which reaches the phototransistor, the more current passes through it. Unlike the photodiode, which usually require an op amp circuit to raise their voltage levels for a microcontroller to read, the phototransistor conveniently has its own built-in gain. When exposed to light, a small current generates and controls a larger collector-to-emitter current. Wikipedia says: "A phototransistor is in essence nothing more than a bipolar transistor that is encased in a transparent case so that light can reach the base-collector junction. The electrons that are generated by photons in the base-collector junction are injected into the base, and this current is amplified by the transistor operation. Note that although phototransistors have a higher responsivity for light they are unable to detect low levels of light any better than photodiodes."

A phototransistor is better to use than a photocell if very rapid response time is required. Also, these devices are more sensitive to small levels of light, which allows the illumination source to be a simple LED element. One example application where a phototransistor would be advantageous to a photocell would be a simple tachometer. What's that? You could count the frequency of a rotating disc which has a hole in it, allowing light to pass through once every revolution, thus triggering the light sensor into conduction. For more about this, refer to "Practical Electronics for Inventors," page 527.

I also found that the phototransistor doesn't react to common ambient room light very much, so this is a great sensor if you want to match events with a very specific lighting scenario (such as a laserbeam being broken) without a lot of accidental "noise." More observations in the section below.

A note about Photodarlingtons: this is yet another type of sensor to look into if you still are anxious to experiment. Photodarlingtons are much more light-sensitive than phototransistors (they have two stages of gain instead of one), but have slower response times. And then there are hyper-accurate photomultiplier tubes, which are typically expensive and require high voltages... they sure look neat though, like miniature cities in a vacuum tube. Anyhow, moving along....

The Specifics / Exercise / Code Sample

I thought it would be useful to do this basic exercise whereas I connect both sensors to a breadboard, and under the same lighting conditions (which I experimented with alot) , observe the data readings and compare each sensor's reactions to each other.

The phototransistor I am using (bought from Jameco) is an example of a 3-lead NPN phototransistor. These are often used instead of 2-lead PTs . The extra base lead can be fed extra current to help boost the number of electrons injected into the base region. Presence of light alters an already present base current. However, in this circuit, the base isnt used (i just bent it out of the way but it can be cut).

The model number is the BPW77 Transistor and the Datasheet =

Other features is that it has a lens, making the detection range very focused (see diagram below). Light must enter it from a very straight line. Coming in from an angle sometimes garners no reaction at all - in some applications this could be very desirable. Also, note that its sensitivity and peaks around 850 nm --- this is in the infrared, so it will respond best to red in the visible spectrum.

Next, I used this CDS (Cadmium Sulfide) photocell from Jameco.

Here's the catalog page =

I could not find a data sheet with a spectral detection chart , but experiments with the cell revealed a much wider angle of sensitivity, to all forms of light. Some more stats: Applications include: auto-focus lenses, exposure meters, contrast controls for TVs, dimmer or light switches, flame detectors, electronic toys, street lamp switches, optocouplers, and resistance is 27k ohms(light), to 2Mohms(dark).

the breadboard and code

Circuitry is extremely simple. I just used this phototransistor example from Tom Igoe's "Physical Computing" , page 365, but I connected the emitter pin to analog in (not digital as in the book) on an Arduino microcontroller. A 22K pull-down resister is used.

Next, I added a photocell in a similar configuration (also with a pull-down resister) and 2 leds to PWM pins, 1 for an analagous reading/event from each sensor.

(thats the photocell on the left. one can already see that it is reacting to my common ambient room light (its respective led is lit) while the phototransistor in the same lit space doesnt provide a reading at all.)

here is the code, which will light an led more intensely for each sensor's light intensity, and will clearly print out the values of each sensor in the serial window.

here's a view of the serial monitor while i shined a compact fluorescent lamp at a 45 degree angle towards the breadboard, showing that the photocell is getting a much higher reading than the phototransistor, which doesn't respond.

And now is the fun part: playing with lights and watching the sensors do their thing! i experimented with a red laser, a xenon strobe, incandescent, blue led, and various filters to test sensitivity to different wavelengths. i found that the phototransistor only incurs a reading when the light source is pointed directly at the lens, outside of this, it will read a '0,' whereas the photocell gave a reading throughout the presence of all light in the room.

In the phototransistor, values had a much quicker observable reaction time. A very spunky sensor! In response to an abrupt pulse of light, the phototransistor values switch just as abruptly; the photocell seems to 'cascade' more slowly from one extreme to the other in its readings - the rises and falls are much less abrupt. A very good sensor when quickness is needed.

The phototransistor responded the most to the red laser pointer at its specific focal point (which makes perfect sense given its peak sensitivity is in the IR) and the least to the color blue . It did not respond to a xenon strobe being pointed directly to it. The photocell responded to all light from any angle.

Here are some photos from my light experiments. I found this to be a great exercise that could be used to decide exactly which sensor best suits a project. TeraHerz-range electromagnetic luck to you on your light-project!