diff --git a/src/main.c b/src/main.c index dbe3796..2ddc4cb 100644 --- a/src/main.c +++ b/src/main.c @@ -73,22 +73,24 @@ int main(void) /* Set relais based on temperature if heating logic is enabled */ if (heating_logic_enabled) { - bool temp_condition = temp < temperature_threshold; - bool floor_condition = true; // Default: ignore floor temp if sensor not available + bool temp_below_threshold = temp < temperature_threshold; + bool floor_below_threshold = true; // Default: ignore floor temp if sensor not available // Only check floor temperature if MLX sensor is working if (mlx90614_sensor_available) { - floor_condition = floor_temp < floor_temp_threshold; + floor_below_threshold = floor_temp < floor_temp_threshold; } - if (temp_condition && floor_condition) + // Heat ON only if BOTH temperatures are below their thresholds + // Heat OFF if ANY temperature reaches its threshold + if (temp_below_threshold && floor_below_threshold) { - relais_state = 1; // Heat on below thresholds + relais_state = 1; // Heat on - both temps below thresholds } else { - relais_state = 0; // Heat off if any threshold exceeded + relais_state = 0; // Heat off - at least one threshold reached } set_relais_state(relais_state); }