I've stumbled across something very weird in the combination of Arduino and CdS photocells: when I regularly read a CdS photocell using the standard voltage divider arrangement on an Arduino analog input, it produces oscillatory outputs that closely approximate sine waves.
The amplitudes of these oscillations are roughly 5% of the average reading; their frequencies, however, vary with the frequency of the sampling rate. I tried sampling periods of 10 msec, 100 msec, 300 msec, 1000 msec, and 10000 msec, getting different periodicities for each sampling rate. The sampling rates between 100 ms and 1000 msec produced the closest approximations to sine waves; the sampling rates of 10 msec and 10000 msec produced jerky oscillations. Yet in every case, the periodicities appeared to be stable.
I also tried different analog pins, finding minor differences between them, but the differences were smaller than the amplitudes of the oscillations. I also tried using both the USB power source and the plug-in battery source; there was no significant difference.
I thought that somehow this might be the result of heating of the photoresistive material by the sampling current, but cooling the photocell with an air spray had only a tiny effect.
I also used an ohmmeter on the cell, getting a stable output to within 0.1%.
I also tested two very different photocells, getting much the same results with the two photocells.
I also ran the same test on a simple resistor, and got rock-solid stable output.
So we have some sort of interaction between the Arduino analog measurement system and the photocell. It looks for all the world like some sort of harmonic interaction, but I cannot for the life of me figure out what's going on here.
First, could somebody replicate my findings?
Second, does anybody have any hypothesis that would explain this weird behavior?
Third, can anybody suggest a workaround that would give me stable readings from the photocell?