Calculate average dewpoint from multiple sensor measurements

This commit is contained in:
2024-09-19 21:50:55 +02:00
parent 053ee1674d
commit 682650dedb

View File

@@ -112,6 +112,7 @@ static int Init(void)
static void Update(void) static void Update(void)
{ {
float t[6], rh[3], dp[3]; float t[6], rh[3], dp[3];
float t_avg, rh_avg, dp_avg;
word raw; word raw;
Info("Reading sensor values..."); Info("Reading sensor values...");
@@ -138,9 +139,14 @@ static void Update(void)
dp[1] = Dewpoint(t[1], rh[1]); dp[1] = Dewpoint(t[1], rh[1]);
dp[2] = Dewpoint(t[2], rh[2]); dp[2] = Dewpoint(t[2], rh[2]);
t_avg = (t[0] + t[1] + t[2]) / 3;
rh_avg = (rh[0] + rh[1] + rh[2]) / 3;
dp_avg = Dewpoint(t_avg, rh_avg);
Info("T1=%.2fC, RH1=%.2f%%, NT1=%.2fC, DEW1=%.2fC", t[0], rh[0], t[3], dp[0]); Info("T1=%.2fC, RH1=%.2f%%, NT1=%.2fC, DEW1=%.2fC", t[0], rh[0], t[3], dp[0]);
Info("T2=%.2fC, RH2=%.2f%%, NT2=%.2fC, DEW2=%.2fC", t[1], rh[1], t[4], dp[1]); Info("T2=%.2fC, RH2=%.2f%%, NT2=%.2fC, DEW2=%.2fC", t[1], rh[1], t[4], dp[1]);
Info("T3=%.2fC, RH3=%.2f%%, NT3=%.2fC, DEW3=%.2fC", t[2], rh[2], t[5], dp[2]); Info("T3=%.2fC, RH3=%.2f%%, NT3=%.2fC, DEW3=%.2fC", t[2], rh[2], t[5], dp[2]);
Info("T_AVG=%.2fC, RH_AVG=%.2f%%, DP_AVG=%.2fC", t_avg, rh_avg, dp_avg);
// TODO: Implement state machine // TODO: Implement state machine
// TODO: Handle serial commands // TODO: Handle serial commands