Analysing the change in temperature. Any good ideas?

Hi

While cooling down a substance i will meassure the temperature with a DS18B20 sensor and i would like to use this data for calculating the slope coefficient.

If, lets say, i meassure the temperature every 10th second, and the change in temperature is -0,5 degrees C (+/- 5%) 5 times in a row, the slope coefficient is -0,5.

The cooling curve is expected to be quite linear.

So what i need is basically the ability to save the current temperature, wait 10 seconds and compare the new temperature with the old one.
This gives us some kind of figure for the deviation in temperature.
Also this deviation is saved and 10 seconds later compared to the new deviation.

If the two values for deviation are the same (plus or minus my tollerance of 5%), a counter should count one up.
If the values are not the same, the counters value should be reset.

Once the counter has counted to 5, the latest value for deviation (they should almost be identical) should be available for printing to a LCD or similar.

I am open to any good ideas. Perhaps there's even a library that can help me on the way, but i haven't found it yet.

The state change detection example in the IDE (File, Examples, Digital) shows how to detect changes from one time to the next and act depending on rise or fall or no change. The blink without delay example (same location) or the several things at a time thread shows how to do non-blocking timing.

Do you have the temperature sensors working?

That was quite helpfull, thanks. The state change detection example is written for boolean values, but i guess its not that difficult to modify.

Yes, the sensor and LCD is up and running.

You've already passed the first hurdle by defining the problem very well. Usually that is where beginners get hung up. You just need to learn some coding, but what you describe is very simple. Look at some similar examples and you'll be fine.

The state change detection example is written for boolean values

No. The state change detection example shows you how to detect that the current value is, or is not, the same as some previous value. It does NOT matter than the current value is an int (as in the example) that represents the value read from a digital pin or a float that represents a temperature or an unsigned long that represents time.