I have a sketch collecting temperature samples and putting them in an array of 12 rows every 5 minutes. Now I would like to be able to calculate a trend from these samples to know if temp is rising, falling or steady over the last hour.
I'll calculate average "1 hours" value, summing up 12 digit and divide a sum by 12. S(i) = ( T1 + T2 +....+T12 ) / 12.
Than trend is a differential of two S, current and previous:
if ( S(i-1) > S(i) ) trend = "Down";
if ( S(i-1) < S(i) ) trend = "Up";
if ( S(i-1) == S(i) ) trend = "Steady";