I've found a photoresistor (yes, resistor, probably 30 years old) in my scrap box, attached it to an ATtiny as ambient light sensor, with a 100kΩ resistor as voltage divider towards +5V.

On power on, the ATtiny measures the ambient light using its ADC capability, and uses that value as switching threshold later on.


That works extremely well, slight differences in dark ambient conditions can be resolved, and give consistently reproducible results as twilight switch. Looks like my choice of the 100kΩ resistor was a lucky find, my goal was to use as much as possible of the 0–5V voltage range for ATtiny's the 10bit ADC.

I'm so happy with the result, I wanted to get a couple more of these photoresistors. Turns out: I cannot buy them anymore, at least not easily:

The use of CdS and CdSe photoresistors is severely restricted in Europe due to the RoHS ban on cadmium.

They seem to have fallen from favour, and been replaced by phototransistors and photodiodes.

What should I use to replace the photoresistor? A photodiode, or a phototransistor? What details are important to make a good choice for the described use case?

The device is not required to act particularly fast. It is more important to me

  • to be able to discern slight variations in dark conditions,

  • have a wiring of similar simplicity (I think I do understand voltage dividers, and I'd rather not have to use more components),

  • work in a 3.3—5.5V setting, which would allow me to power from USB, 3×1.5V AA or 4×1.2V AAA batteries,

  • and the resulting circuit should draw little current, it's intended to last for days, up to weeks.

I lack the knowledge to draw a conclusion from looking at data sheets, (e.g., this one, found at Reichelt). I assume the sensor should be sensitive to wavelengths in the range of 450–650nm, which rules out all devices labelled “IR”. But I don't know what to look for exactly.

I have no idea how to interpret the irradiance values. I see the number and unit, but I cannot estimate the ballpark of my use case. I don't own equipment to measure the lighting conditions at the site of intended use.

Also for the electrical characteristics: Assuming the 100kΩ resistor I'm now using for the voltage divider, I'd assume 50μA current maximum. Is that the I_c to look for? What role do the other values play?

  • \$\begingroup\$ >which rules out all devices labelled “IR" False assumption \$\endgroup\$ Commented Jun 1, 2022 at 20:36
  • \$\begingroup\$ Your problem is no tolerance specs for component variances and no , light threshold specs or dynamic range. Can u specify more for tolerances and threshold ? PD and Light sensors are avail and best choice \$\endgroup\$ Commented Jun 1, 2022 at 20:37
  • \$\begingroup\$ Maybe your search terms are off? If you search "cds photocell" you will find many options. \$\endgroup\$
    – vir
    Commented Jun 1, 2022 at 20:38
  • \$\begingroup\$ @TonyStewartEE75: No, unfortunately I cannot give any numbers. The setup was experimantal (I'm a beginner with electronics) and worked just fine. The use case as I've described is as precise as I'm capable of making it—of course this is a problem. \$\endgroup\$
    – stefan
    Commented Jun 1, 2022 at 21:03
  • 2
    \$\begingroup\$ @stefan CDS cells are banned in EU for new consumer goods. There are many instances of legacy equipment wherein they are permitted. You're only making 3 or 4 devices. Your hobby actions aren't the target of the EU restrictions. Don't eat the cells. \$\endgroup\$
    – Kyle B
    Commented Jun 1, 2022 at 21:14

1 Answer 1

  • Never use a phototransistor for accurate light readings as the hFE range spans many octaves. (unless you calibrate hFE and compensate for temp.)

The keyword you need is: Ambient Light Sensor (ALS)

IR PD's usually span visible range unless they are filtered for IR remote controls. Yet may detect IR range from visible light with a slope towards UV.

PD's are practical but why not use ones good for camera photometers. Panasonic made the best AM302 but are obsolete from low camera demand. They spanned over 3 decades with a log output and many more decades with variable fixed R loads.

These ALS parts are a good selection in stock at the time of this writing and are low cost. Some are eye-corrected for wavelengths.


TEPT5700 ambient light sensor is a silicon NPN epitaxial planar phototransistor in a T-1¾ package. It is sensitive to visible light much like the human eye and has peak sensitivity at 570 nm.

These are very accurate unlike Cd photoresistors and will do what you expect at 10uA in dim 10 Lux light.

use 250k from 5V to get 2.5V at 10uA.


Check uA at green 10lux 550 nm +/- 1xx range .. to calibrate Rs for 50% drop to compare, but if you edit my 1st link change "ca to de"(or your country code) & it will show local stock sorted by lowest cost. You can add a cap to filter noise and transient sensor blocking RC=T

  • 1
    \$\begingroup\$ Wow, thank you. I'll try to get one of these. Would you mind pointing out what the most relevant characteristics are in the datasheet? I'm asking because I might have to look for an alternative (mouser.de says “out of stock” and reichelt.de does not list them), and I don't want to pester others with doing the searching for me =) \$\endgroup\$
    – stefan
    Commented Jun 1, 2022 at 21:41
  • \$\begingroup\$ Check uA at green 10lux 550 nm +/- 1xx range .. to calibrate Rs for 50% drop to compare, but if you edit my 1st link change "ca to de" it will show local stock sorted by lowest cost. You can add a cap to filter noise and transient sensor blocking \$\endgroup\$ Commented Jun 2, 2022 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.