Hi, I have a lm19 temperature sensor and a photo resistor hooked up to analog inputs of my arduino and I'm getting some very strange readings. I dont think my code is the problem but here it is just in case:

So the problem is that as the light level drops below the temperature level, I get erratic readings from the temperature sensor. I posted a picture of one of the readings I graphed, where green is light and red is temperature. The only thing I can think of is adding a capacitor between ground and the temp. sensor Vout pin but really I'd just like to know what's causing this interference.

The Arduino only hjas one ADC which is multiplexed. If readings differ too much they interfere.

solutions:* do double readings and ignore the first (see below)* do multiple readings and average them (exercise for you * do a running average e.g. temp = (2 * analogRead() + 14 *temp) / 16;* take care there is enough time between the readings (move reading of light after Serial prints (temp)

The Arduino only hjas one ADC which is multiplexed. If readings differ too much they interfere.

solutions:* do double readings and ignore the first (see below)* do multiple readings and average them (exercise for you * do a running average e.g. temp = (2 * analogRead() + 14 *temp) / 16;* take care there is enough time between the readings (move reading of light after Serial prints (temp)

Thanks, the code works perfectly but I'm still not really understanding the problem. This is how I understand it: I tell the arduino to read a pin, it sends the voltage through the ADC and stores the number it gets in the ram, then it clears the ADC and switches to the next pin...

So how could there be interference in the values?

Also, "take care there is enough time between the readings (move reading of light after Serial prints (temp)"

I tried that and it worked aswell, yet if I use my original code with a very generous 100ms delay(far more than serial printing) between reading the temp pin and the light pin I get the same interference.

The ADC is an analog device, it does not behave like a digital switch internally. I don't know how it works exactly but it builds up a charge internally and the time this takes is a measure for the voltage applied - ADC GURU's please fill in the gaps - It takes time to "remove" this old charge completely, it is definitely no digital on/off bit. If you start a new reading before the ADC is "clean" you have your interference.