you can do
- recognize the spike, and reread the value until a reasonable value comes up
do
{
T = getTemperature();
} while (abs(T-prevT)> 10);
prevT = T;
- use a low pass filter
T = 0.85 * T + 0.15 * getTemperature();
The new read value will only count for 15% of the read value. Spikes will be tampered, but the effect is that T smoothes a bit, becomes "slower"in following the real temp
- a mix
T = getTemperature();
if (abs(T-prevT) > 10) T = 0.85 * prevT + 0.15 * T;
prevT = T;
hope this helps