Min/Max values are taken after FIRST_MIN_MAX millisencods due to measurement failures

of the DHT22 at start.
master
Holger Wirtz 4 years ago
parent 2d88947830
commit 4dd57c2e44
  1. 57
      WLAN_Thermometer.ino

@ -30,6 +30,7 @@
#define WIFI_CONNECT_TIMEOUT 30
#define CFG_PORTAL_TIMEOUT 90
#define DHTTYPE DHT22
#define FIRST_MIN_MAX 300000 // = 5 min
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_COL, LCD_ROW);
looper sched;
@ -195,30 +196,36 @@ void loop()
client.print(temp[ACT]);
client.println(" &deg;C</h2>\n");
client.print("<h2 style=\"color:green;\">Minimum: ");
client.print(temp[MIN]);
if (millis() > FIRST_MIN_MAX)
client.print(temp[MIN]);
client.println(" &deg;C</h2>\n");
client.print("<h2 style=\"color:green;\">Maximum: ");
client.print(temp[MAX]);
if (millis() > FIRST_MIN_MAX)
client.print(temp[MAX]);
client.println(" &deg;C</h2>\n");
client.println("<h1 style=\"color:blue;\">Luftfeuchtigkeit</h1>\n");
client.print("<h2 style=\"color:blue;\">Aktuell: ");
client.print(hum[ACT]);
client.println(" %</h2>\n");
client.print("<h2 style=\"color:blue;\">Minimum: ");
client.print(hum[MIN]);
if (millis() > FIRST_MIN_MAX)
client.print(hum[MIN]);
client.println(" %</h2>\n");
client.print("<h2 style=\"color:blue;\">Maximum: ");
client.print(hum[MAX]);
if (millis() > FIRST_MIN_MAX)
client.print(hum[MAX]);
client.println(" %</h2>\n");
client.println("<h1 style=\"color:gray;\">Gef&uuml;hlte Temperatur</h1>\n");
client.print("<h2 style=\"color:gray;\">Aktuell: ");
client.print(heat[ACT]);
client.println(" &deg;C</h2>\n");
client.print("<h2 style=\"color:gray;\">Minimum: ");
client.print(heat[MIN]);
if (millis() > FIRST_MIN_MAX)
client.print(heat[MIN]);
client.println(" &deg;C</h2>\n");
client.print("<h2 style=\"color:gray;\">Maximum: ");
client.print(heat[MAX]);
if (millis() > FIRST_MIN_MAX)
client.print(heat[MAX]);
client.println(" &deg;C</h2>\n");
DateTimeParts p = DateTime.getParts();
@ -341,9 +348,11 @@ void show_temperature(void)
lcd.print("C");
lcd.setCursor(0, 2);
lcd.print("Min: ");
lcd.print(temp[MIN], 1);
if (millis() > FIRST_MIN_MAX)
lcd.print(temp[MIN], 1);
lcd.print(" Max: ");
lcd.print(temp[MAX], 1);
if (millis() > FIRST_MIN_MAX)
lcd.print(temp[MAX], 1);
lcd.setCursor(0, 3);
lcd.print("LF: ");
lcd.print(hum[ACT], 1);
@ -392,20 +401,24 @@ bool is_wintertime(time_t t)
void get_sensor_data(void)
{
temp[ACT] = constrain(dht.readTemperature(), -40.0, 80.0);
if (temp[ACT] < temp[MIN])
temp[MIN] = temp[ACT];
if (temp[ACT] > temp[MAX])
temp[MAX] = temp[ACT];
hum[ACT] = constrain(dht.readHumidity(), 0.0, 100.0);
if (hum[ACT] < hum[MIN])
hum[MIN] = hum[ACT];
if (hum[ACT] > hum[MAX])
hum[MAX] = hum[ACT];
heat[ACT] = constrain(dht.computeHeatIndex(temp[ACT], hum[ACT], false), -40.0, 80.0);
if (heat[ACT] < heat[MIN])
heat[MIN] = heat[ACT];
if (heat[ACT] > heat[MAX])
heat[MAX] = heat[ACT];
if (millis() > FIRST_MIN_MAX)
{
if (temp[ACT] < temp[MIN])
temp[MIN] = temp[ACT];
if (temp[ACT] > temp[MAX])
temp[MAX] = temp[ACT];
if (hum[ACT] < hum[MIN])
hum[MIN] = hum[ACT];
if (hum[ACT] > hum[MAX])
hum[MAX] = hum[ACT];
if (heat[ACT] < heat[MIN])
heat[MIN] = heat[ACT];
if (heat[ACT] > heat[MAX])
heat[MAX] = heat[ACT];
}
}

Loading…
Cancel
Save