analogRead Question.

Hi friends!

When I use Arduino analogRead function with or without something hooked up to the analog pin (A0), I can see there is a decay value when I power up or call the function after a little while after the last time. Can ambient temperature affect analog values ? If you try the analog read voltage example, after powering up the board, the value decreased by some millivolts until it seattles. If you shut it down the board and quickly power up the value doesn´t decay that much but if you wait like 20 seconds and power it up again you can see the decreasing effect again. Also this happends when you make a sample of the pin and the program does whatever it does and then you make another sample after a while. I need a precise value right after I call the function so when I read a sample I can inmediatly take different actions.

I hope I explain my doubt correctly. This is not a problem of code but more like a physic one.
I was thinking voltage reference for ADC takes a while to seattle due to resistance change by temperature.

With nothing connected to the pin, it is "floating" and will pick up ambient electromagnetic noise and read random or "effectively" random values. Behavior like you are observing is common, as the voltage starts one value, and then slowly drifts due to leakage.

Do not expect meaningful results when you read a floating pin.

Thank you for answering. I do know that when nothing is connected is picking the noise from AC wires and other sources but as I mentioned it also happens when there is a sensor connected.

What sort of sensor is it?

I missed the part about it happening with a sensor connected too.

That's not generally a good thing!

Do the values you're getting make sense?