Hello All,
I'm currently wrapping up a project, but having a little trouble with what seems like should be a simple aspect.
I'm monitoring a temperature probe, and would like to calculate the average temperature of a day (from midnight to midnight).
So, every 5 minutes, I'm measuring the temperature, and adding it to a word variable (TempAverage)...I'm also incrementing the AverageCount variable...so at the end of the day, I should be able to take my TempAverage word, and divide by AverageCount, and arrive at my average...right?
That's all well and good...and appears to work. (I should note I'm not concerned about decimals...just the integer number is fine).
However, It's coming up on winter, and I need to factor in negative temperatures as well...this is where I'm getting muddled up.
I'm using the trusty DS18b20 temperature sensors...which reports a negative temperature as 128 + negative value... (so, -1 would be 129).
My code looks for this, and subtracts the value from the TempAverage (129 would result is a subtraction of 1 from the TempAverage).
However, How to I at the end of the day, calculate the average? How do I tell if the average is positive or negative?
I have a feeling I'm overlooking something very simple...so please feel free to smack me on the back of the head if that's what's needed...I'm just stumped here.
Thanks all!
Brendan
I'm currently wrapping up a project, but having a little trouble with what seems like should be a simple aspect.
I'm monitoring a temperature probe, and would like to calculate the average temperature of a day (from midnight to midnight).
So, every 5 minutes, I'm measuring the temperature, and adding it to a word variable (TempAverage)...I'm also incrementing the AverageCount variable...so at the end of the day, I should be able to take my TempAverage word, and divide by AverageCount, and arrive at my average...right?
That's all well and good...and appears to work. (I should note I'm not concerned about decimals...just the integer number is fine).
However, It's coming up on winter, and I need to factor in negative temperatures as well...this is where I'm getting muddled up.
I'm using the trusty DS18b20 temperature sensors...which reports a negative temperature as 128 + negative value... (so, -1 would be 129).
My code looks for this, and subtracts the value from the TempAverage (129 would result is a subtraction of 1 from the TempAverage).
However, How to I at the end of the day, calculate the average? How do I tell if the average is positive or negative?
I have a feeling I'm overlooking something very simple...so please feel free to smack me on the back of the head if that's what's needed...I'm just stumped here.
Thanks all!
Brendan