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?