     static unsigned long tsMeasure, tsMeasureOld;
     static unsigned int cntMeasure;
     static int rainValueOld;
-    static unsigned char rainStatusOld;
+    static unsigned char rainStatusOld = rainStatus;
     if (millis() - tsMeasure >= PERIOD_MEASURE_RAIN || tsMeasure == 0) {
         tsMeasure = millis();
         // Value

    static unsigned long tsMeasure, tsMeasureOld;
    static unsigned int cntMeasure;
    static int waterValueOld;
    static unsigned char waterStatusOld;
    if (millis() - tsMeasure >= PERIOD_MEASURE_WATER || tsMeasure == 0) {
        tsMeasure = millis();
        // Value

retained int lightValueMin = 4096, lightValueMax;
retained int rainValueMin = 4096, rainValueMax;
retained int waterValueMin = 100, waterValueMax;
retained unsigned char lightStatus, rainStatus, waterStatus;

// Statistical smoothing and exponential filtering
const float FACTOR_RSSI  = 0.1;    // Smoothing factor for RSSI
