I have a thermistor hooked up to my #5 analog input and cannot get it to stop reading and bouncing around from 73.5°F to 74.92°F.
I am trying to use it as a thermostat and don't want the darn stat clicking on and off when it gets close to set point.
Any suggestions on leveling off or averaging this sensor?
Are the sensors always like this? (Bouncing like mad).
Actually that might be a normal reading for your setup. Not sure of how much of the total 0-5vdc range your sensor is using without knowing more about the sensor and how you have wired into your circuit. Also how you are scaling or mapping the value might give some light to the situation. Keep in mind that the 10 bit A/D conversions give around 5mv steps of resolution for each count. Figure out what a 5mv change represents for your scaling and see if you aren't just seeing the normal LSB switching on and off. Also the Atmel total accuracy spec is +/- 2 LSB, or +/- 20mv on a 0-5 volt scale.
All that aside it sound like what you have can be made to work. What most thermostats have mechanically built in, and what you need to add to you code, is called hysteresis so you don't 'chatter' on and off right at the setpoint value.
What you need is a moving band of temperature, say maybe 2 degrees wide. Say you have a target setpoint, of desired temp of 70 degrees. Your decision to turn on the heat should be at 69 and lower and turn off at 71 and higher. This gap has to be adjusted to change with the setpoint such that if you demanded 80 degrees the the on and off decision points would be 79 and 81.
You may have to increase that gap wider depending on the amount of noise or variation of your sensor readings, the total heat load of what you are heating up and the heat capacity of you heat source.
Tighter control then that would require more sophisticated control algorithms such as PID control and a variable output control, either analog or PWM to drive the heating element.
Lefty