Light becomes volts
Light makes a current through the phototransistor, about half a microamp per lux for a typical part, and the 4.7 kΩ resistor turns that current into SIGNAL. So 100 lux gives about 0.24 V. Double the light and the voltage doubles, until it meets a ceiling just under VCC.
A current, then a voltage
The phototransistor passes a current in proportion to the light on it. That current flows out of its emitter, down through the 4.7 kΩ resistor to ground, and the voltage across the resistor is SIGNAL. It is Ohm's law and nothing else: SIGNAL is the current times 4.7 kΩ.
The datasheet gives the current at three light levels, with VCC at 5 V: 5 µA at 10 lux, 15 µA at 30 lux and 50 µA at 100 lux, for a typical part. That is a straight line, half a microamp per lux.
Slide the light up from 100 lux. The current is 50 µA, and 50 µA through 4.7 kΩ is about 0.24 V. At 10 lux, about 24 mV; at 30 lux, about 71 mV. The dots are the datasheet's three rows, and the band around the line is its minimum and maximum: any one part can be 30 % either side of typical.
Past 100 lux
The datasheet stops at 100 lux. Beyond it, the figure carries the same straight line on, and the shaded part is labelled for what it is: extended, not measured. On that line 300 lux is about 0.7 V and 1000 lux about 2.35 V. The part very likely behaves roughly like that. Nobody promises it.
For scale, and roughly: a dim room is under 100 lux, a lit room or office somewhere around 100 to 500, a desk under a lamp more. Daylight through a window is often thousands, and a phone torch held close to the sensor is far past anything on the slider.
The ceiling
The line cannot go on for ever. The transistor needs a little voltage across itself to work: its datasheet gives at most 0.4 V when it is carrying 2 mA. So SIGNAL can climb to about VCC minus 0.4 V and no further. With VCC on 5 V that is about 4.6 V, reached at about 1960 lux for a typical part. Anything brighter reads the same.
In the dark
With no light, the datasheet allows at most 0.1 µA of leakage. Through 4.7 kΩ that is under half a millivolt, and every board reads 0 or within a count of it. A block that reads 0 in a lit room is a different problem, and when the reading is wrong starts there.
When it does not work
Roughly, and only under a light like the datasheet's. For a typical part it is about 2.35 mV per lux, so 235 mV is about 100 lux. Any one unit can be 30 % off either way, and a different light source changes the answer, so treat it as an estimate and calibrate against a lux meter if the number matters.
Because a room is not very bright. A typical lit room is roughly 100 to 500 lux, which is about 0.24 to 1.2 V on SIGNAL: the bottom quarter of an Uno's scale. The rest of the scale is for daylight and torches. It is working.
In principle a larger resistor gives more volts per lux and reaches the ceiling sooner; a smaller one gives fewer. It also changes the filter with the 100 nF. It is a surface-mount part, and this book assumes the board as it ships. Averaging, in the flicker article, is the easier way to get a steadier low reading.
Why VCC does not change the reading in a room, and why it still has to be 3V3 beside a 3.3 V board.
VCC sets the ceiling →Edit this page — content/books/ambient-light-sensor/light-becomes-volts.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Ambient Light Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.