This is an old revision of the document!
At the grandma's house, where I currently live, I use a wood-burning central heating unit to stay warm during the winter months. This central heating unit uses a fan to provide fresh air to the fire, which turns off when the water (that's running through the radiators in the house) reaches the operating temperature (90 degrees Celsius). That's great, otherwise my pipes would explode.
What's controlling the fan, you may ask? A little knob on the side of the central heating unit that tells the fan (using a bimetalic strip) how cold the water has to be for it to start doing something.
That's great, but there is a small problem: when the fire dies down eventually, there is no mechanism in place to automatically tell the fan to not turn back on once the water temperature drops below the threshold set earlier by the knob… so you have to always go back to the central heating unit once the fire has started to turn the knob, in essence shutting down the fan for good.
I wanted to fix that :)
There is a lot of logic that controls the icons that are displayed in the interface, I'll stick them below in the code snippets because talking about them is really really boring, I just thought of all the possible cases and coded them in.
Initial checks when ESP32 starts (maybe the user resets it manually):
if (initialTempC >= 30.0) { // If temperature is already high, set servo to triggered position and fan OFF lastServoPos = SERVO_TRIGGER_POS; fanState = false; fireState = "off"; Serial.println("Initial state: Temperature above 30°C - Setting servo to 30° and fan OFF"); // Actually move the servo to 30° position myServo.attach(SERVO_PIN, 700, 2300); myServo.write(SERVO_TRIGGER_POS); delay(700); // Give servo time to move to position myServo.detach(); Serial.println("Servo physically positioned at 30° and detached"); } else { // If temperature is normal at startup, initialize to 0° position lastServoPos = SERVO_RESET_POS; fanState = true; fireState = "starting"; Serial.println("Initial state: Temperature below 30°C - Setting servo to 0° and fan ON"); // Actually move the servo to 0° position myServo.attach(SERVO_PIN, 700, 2300); myServo.write(SERVO_RESET_POS); delay(700); // Give servo time to move to position myServo.detach(); Serial.println("Servo physically positioned at 0° and detached"); // Clean database at startup Serial.println("Performing initial database cleanup..."); cleanupDatabase(); }