I made a temperature sensor with my Arduino, but noticed that the measured temperature is sometimes a few degrees too high.
What I think happens is that in the conversion from the analog reading to a voltage, I multiply by 5 V / 1023 steps .
However, what if the supply is not exact 5 V? Say it's 4,8V (when using a longer USB cable) ? The 5/1023 should actually be 4,8/1023...
The 5/1023 is hardcoded in the program, so the output is off when the input voltage isn't exact 5 V.
What are ways to get rid of this dependency? Battery operated sensors must face the same issue, with the battery voltage dropping over time?
Thanks for any ideas!