Temperature effects on Photo Resistor
doggiedoc
Posts: 2,242
I've encountered and interesting and unexpected problem with my automatic chicken coop door. I am using a CdS photo resistor and an Analog input on the PropBOE to measure light intensity and compare the result to logical thresholds to determine when to open or close the coop door. The phenomenon I have noticed seems to be related to fluctuations in ambient temperature.
It appears to me that on recent cooler evenings the door does not close (ie the lower threshold of light intensity is not reached) even though on previous evenings (warmer I suspect) the door has closed at an ideal time. Tonight I went out after 10pm and the door still had not closed. So... I went in and grabbed my Mac and sat out there - I'm sure if any neighbors noticed they'd think it was normal - and sat by the coop to check the readings from the CdS. The same thing happened a couple of weeks ago when we got our first round of cooler weather. I adjusted the threshold then and all was fine, for a day or two. But then it warmed back up and I had to adjust the threshold again. Now I'm back to dealing with cooler evenings. WTF?
This "automatic door" concept is requiring too much manual tweaking.
So, questions:
1) Am I correct in my suspicion that temperatures are affecting the sensitivity of the CdS cell?
2) If so, is there a way to compensate for temperature variations (actively or passively)?
3) Is there an alternative to measuring light intensity that is not affected by temperature variations? (I have some of these.)
Doc
It appears to me that on recent cooler evenings the door does not close (ie the lower threshold of light intensity is not reached) even though on previous evenings (warmer I suspect) the door has closed at an ideal time. Tonight I went out after 10pm and the door still had not closed. So... I went in and grabbed my Mac and sat out there - I'm sure if any neighbors noticed they'd think it was normal - and sat by the coop to check the readings from the CdS. The same thing happened a couple of weeks ago when we got our first round of cooler weather. I adjusted the threshold then and all was fine, for a day or two. But then it warmed back up and I had to adjust the threshold again. Now I'm back to dealing with cooler evenings. WTF?
This "automatic door" concept is requiring too much manual tweaking.
So, questions:
1) Am I correct in my suspicion that temperatures are affecting the sensitivity of the CdS cell?
2) If so, is there a way to compensate for temperature variations (actively or passively)?
3) Is there an alternative to measuring light intensity that is not affected by temperature variations? (I have some of these.)
Doc
Comments
Another quick fix would be to substitute a BPW34 for the CdS photo-cell. Reverse biased would be the most immune to temperature swings, but measuring the open-circuit voltage gives the best dynamic range. (and with a >1 mA photo-current under "full-sun" you shouldn't need to change the load resistor much)
Lawson
-Phil
Get a government grant for $50K and assign a task force to study temperature effects on indeterminate-RohS compatible CdS cells. A second Prop can monitor 17 different types of temperature sensors and throw out the high & low (and the East German sensor) readings and average the rest together. Another round of grant funding can auto-generate the temperature correction algorithm and compensate for any delta T variations in your system.
Simple. DUH!
Doc,
I'm interested in using a CdS LDR in some future products that could be exposed to severe shifts in temperature, so I've emailed the west coast support person at Adanced Photonix, a manufacturer of said product. The datasheets did not relate anything other than the min/max temperature allowed. I'll let you know what's answered.
I have to believe that being a resistive element, temperature will affect the overall response; it'd be nice to know how much.
Later,
DJ
One way to overcome this, be it temperature or humidity, is to use two sensors in close proximity so that the ambient fluctuations happen equally, but use one sensor as a reference in a way it won't be affected by your input.
On one hand, you might expect a temperature dependence based on electrons being kicked up into the conduction band at higher temperatures. There may be compensating effects. My photonics book describes it in terms of a ratio between carrier lifetime and transit time and I don't understand what they are talking about. On the other hand, CdS photocells have been used successfully in simple controls for so many years that it hardly seems possible that they all had serious problems or serious need for temperature compensation. CdS cells are very sensitive, for example, Tony Messina's moonlight sensor. Resolution of the conundrum may take the $50k study that Erco suggested! Too late. The industry is getting away from anything containing Cadmium.
Photodiodes do have a temperature coefficient, both for the dark current (spontaneous production of electron-hole pairs) and sensitivity (changes in light absorption), but those effects are very small until you start pushing the limits. The open circuit voltage of a photodiode under constant illumination has the familiar -2.1mV/°C dependence.
DoggieDoc, is there anything else in the circuit that might have a temperature dependence? Can we presume it is just a voltage divider with the photocell and a resistor, into the ADC input? All in all, the TSL230 is a sure bet until you can train that one chicken to do it.
Yes, humidity, particularly if the resistances in the divider are high. That would call for the whole circuit to be mounted in a waterproof dry capsule. Keep it away from direct view of the sky so condensation is less likely to form on the surface.
Looking at the CdS LDR supplied in the WAM kit, there's a glass(?) coating over the element. Wouldn't that prevent any humidity issues?
@Phil Could you elaborate on this immunity?
@erco - LOL
@Humanoido I don't know where to begin with that one. Suggestions?
@skylight - Obviously your chickens are smarter than mine
@davejames - Cool, I'd like to see what they say about temperature variations.
@Beau - I too had that thought when this first happened. My solution (or not) was to encase the CdS cell in a tube with a cork stopper.
I don't know if it made a difference. It is entirely possible that the tube doesn't seal out enough humidity or perhaps humidity isn't a factor. I don't think there is any issue with dew/condensation as the sensor is inside the coop and about about 6 feet from the ground.
@Tracey Allen - The sensor is wired to the BOE with a phone cable - about 6 feet long. The voltage divider is with a 20K 1/4 Watt Carbon Film resistor (5%) into the ADC input of the PropBOE. I don't remember how I arrived at the 20K value at the moment. Perhaps it's too high combined with the 6 feet of thin phone wire?
Thank you all for the help!
Paul
On the other hand if this actually was a temperature dependent phenomena I would just arrange to have two of them. One would be illuminated by the ambient light and one would be in a box illuminated by a LED. Comparison of the output of one with the other would trigger whatever you want to do. To change the set point just change the current driving the LED to make it brigher or dimmer. i.e the light level you want to trigger at.
Or perhaps one of your chickens has learned how to tweak the adjustments so that they can go in and out when they please:)
-Phil
Aim one sensor towards the East, and aim the other sensor towards the West.
This was the simplest attempt at a fix so I thought I'd give it a run first. Minor adjustments to the code: I added a second adc object and added the to values together (rawVal) and finally divide by the number samples x 2 I'll report back - first I'll need to recalibrate the threshold values since the combined sensors equates to a movement of the location.
Thanks for the help.
Paul
Or perhaps a stray light is affecting the circuit such as car headlamps, neighbours using a torch or something?
I think perhaps I need to get this all soldered to a board. Currently using the bread board on the PropBOE. Perhaps switching to soldering the components to a prototype board will help.
Paul
Presuming the connecting wires/cable are heating/cooling and you are taking resistance readings (light on cell), the length of run (from board to sensor) maybe a factor?
how precise is the function that decides whether the door opens or closes? You might have to factor in a margin to cover for heating effect?
Which boils down to what I was saying earlier, is the circuit and programming too sensitive for the application?
Training may involve teaching the chickens to flap their wings to stabilise the coop's temperature
The photocell resistance should decrease over several orders of magnitude as light level goes from ~100000 lux in full sunlight to <1 lux in darkness. Maybe the choice of 20k is not so good. In terms of voltage or ADC counts, what is your typical threshold value? I think you probably want that to be at around half-scale, 2048 counts. With the CdS cell attached to the ohmmeter, measure its resistance at the light level at which the door should be closing. Use that value for the fixed or adjustable resistor in your divider circuit.
I found an an ingenious set of amateur experiments...
http://www.brighton-webs.co.uk/electronics/light_dependent_resitor.htm
It includes a look at temperature dependence. At a single light level, the resistance change due to a temperature change of 30°C was less than 10%. The experimenter immersed the sensor in a bowl of hot water, with the sensor looking out at the light source of interest (a 100W light bulb at some distance), and then recorded the resistance reading as the water cooled off. You could do that at your critical light level, along with a temperature measurement, and then use that factor for temperature compensation in your software if that is in fact the problem. Yet again, the 10% temperature effect should normally be swamped by order-of-magnitude changes in light level.
Anyway, just a random thought. I hope it helps.
-- Glenn
-Phil
Nah, Browser was busy telling the vet you don't give him enough shrimpz.
C.W.