Эксперемент — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by korenovskagk73.

Components

Sketch code

// ================================================================
//   GARAGE CLIMATE CONTROL (Velxio, no manual mode) — FIXED v3
//   Sensors: DHT22 indoor (GPIO4), outdoor (GPIO16 or constants)
//   Door: GPIO12 (HIGH=closed), Car: GPIO14 (LOW=present)
//   LEDs: Vent (GPIO2), Dryer (GPIO5), Wait (GPIO18)
// ================================================================

// ---------- SETTINGS ----------
// Indoor sensor: true = real DHT22 on GPIO4, false = constants
#define USE_REAL_INDOOR   false
#define INDOOR_TEMP       22.0
#define INDOOR_HUM        80.0

// Outdoor sensor: true = real DHT22 on GPIO16, false = constants
#define USE_REAL_OUTDOOR  false   // Velxio only GPIO4 works, so use constants
#define OUTDOOR_TEMP      20.0
#define OUTDOOR_HUM       50.0

// ---------- PINS ----------
#define PIN_DHT_IN        4
#define PIN_DHT_OUT       16
#define PIN_LED_VENT      2       // blue
#define PIN_LED_DRYER     5       // red
#define PIN_LED_WAIT      18      // yellow
#define PIN_DOOR          12      // door sensor (HIGH = closed)
#define PIN_CAR           14      // car presence (LOW = present)

// ---------- HUMIDITY / AH THRESHOLDS ----------
// Normal humidity threshold differs depending on car presence:
// without car, slightly more humidity is allowed (70%) because there is
// no fresh condensation from the body/wheels.
#define HUM_THRESHOLD_CAR     65.0f   // normal with car in garage
#define HUM_THRESHOLD_NOCAR   70.0f   // normal without car

// Hysteresis for absolute humidity for ventilation (car present)
// to avoid relay chattering: turn on when difference is large,
// turn off only when it really almost leveled.
#define DELTA_AH_ON         0.8f   // g/m3 — turn on ventilation (with car)
#define DELTA_AH_OFF        0.3f   // g/m3 — turn off (AH leveled)

// Without car, dehumidifier is UNAVAILABLE (nothing to dry), so
// ventilation is the only tool. Make it more "aggressive":
// turn on at a smaller AH difference and do not cut operation by fixed
// 10 minutes, but run until full equalization (within the overall
// limit MAX_CONTINUOUS_RUN = 60 min, which always applies).
#define DELTA_AH_ON_NOCAR   0.5f   // g/m3 — turn on ventilation (without car)

// ---------- TIMER VARIABLES ----------
unsigned long ventStartTime = 0;
unsigned long ventStopTime = 0;
unsigned long preventiveLastRun = 0;
unsigned long winterLastRun = 0;
unsigned long forcedPauseStart = 0;
unsigned long activeCycleStopTime = 0;

bool ventilationActive = false;
bool dryerActive = false;
bool waitModeActive = false;
bool ventJustStopped = false;
bool forcedPauseActive = false;
bool activeCycleJustCompleted = false;   // true after full 30-min cycle

// ---- Dehumidifier: short-cycle protection ----
unsigned long dryerStartTime = 0;
unsigned long dryerStopTime = 0;
bool dryerJustStopped = false;

// ---- Wait after door closing ----
unsigned long doorClosedTime = 0;
bool startupWaitActive = false;
bool doorClosedPrev = false;

// ---- Emergency ventilati