ESP ZeroCode AI · Community
Auto Air Cooler Relay
An automatic air cooler switch, if the temperature get greater than 25 degrees celsius the air cooler automatically turn ON and as soon as the temperature is below 22 degrees it turns OFF the Air cooler using a relay
What it does
- Temperature monitoring — AHT20 sensor reads ambient temp via I2C
- Relay control — GPIO 10 drives SRD-05VDC relay to switch air cooler
- Hysteresis logic — ON when temp > 25°C, OFF when temp < 22°C
- Power-on behavior — reads temperature at startup, relay state follows current reading
- Local operation only — no Wi-Fi, no cloud, no remote monitoring
- No user feedback — silent operation, no LEDs or displays
Manual
Device Type
name: Auto Air Cooler Relay — problem: Manual air cooler switches require constant monitoring to turn the unit on and off based on room temperature. This device automates that process using a simple hysteresis thermostat, eliminating the need for manual intervention while maintaining energy efficiency.
Hardware
chip: ESP32-C3 — board: ESP32-C3-DevKitM-1 — gpios: gpio4: I2C SDA (AHT20 temperature sensor) — gpio5: I2C SCL (AHT20 temperature sensor) — gpio10: Relay control signal (SRD-05VDC) — peripherals: name: AHT20 Temperature/Humidity Sensor — type: I2C Sensor — bus: I2C (GPIO 4 & 5) — purpose: Measures ambient temperature for control logic · name: SRD-05VDC Relay — type: Electromagnetic Relay — pin: GPIO 10 — purpose: Switches the air cooler on/off based on temperature thresholds
Inputs
kind: Temperature sensor — label: AHT20 (I2C) — hardware: AHT20 Temperature/Humidity sensor connected via I2C — behavior: Continuously reads ambient temperature. Device samples reading to evaluate control logic.
Outputs
kind: Relay — label: Air Cooler Control — hardware: SRD-05VDC relay driven by GPIO 10 — behavior: Relay energizes when temperature exceeds 25°C (ON). Relay de-energizes when temperature drops below 22°C (OFF). In the 22-25°C band, relay maintains its current state (hysteresis).
Connectivity
stack: None — transport: Local only — purpose: Device operates autonomously with no Wi-Fi, cloud, or remote control capability. All logic executes locally on the ESP32-C3.
Business Logic
powerOnBehavior: On startup, the device initializes the AHT20 sensor and GPIO pin. It reads the current ambient temperature and immediately sets the relay state: ON if temperature > 25°C, OFF if temperature ≤ 25°C. After startup, the device continuously polls the temperature sensor and applies hysteresis logic. — dayToDayOperation: The device continuously monitors room temperature. When temperature crosses 25°C going upward, the relay activates (air cooler turns ON). The relay remains on until temperature falls below 22°C, at which point it deactivates (air cooler turns OFF). This 3°C deadband prevents rapid on/off cycling. There are no user controls, displays, or feedback indicators — the device runs silently in the background.
Failure Modes
scenario: AHT20 sensor fails or becomes unresponsive — behavior: Device will attempt to read sensor but will not receive valid data. Behavior depends on firmware error handling — typically the relay remains in its last known state or defaults to OFF for safety. A firmware watchdog or periodic retry could be implemented. · scenario: Relay fails to energize — behavior: Air cooler will not turn on even when temperature exceeds 25°C. This is a hardware failure outside firmware control. An external monitoring mechanism (manual check) is recommended. · scenario: Power loss and recovery — behavior: On power restoration, the device boots and immediately reads the current temperature, setting the relay state based on that reading. No state is persisted across power cycles — this is the intended behavior.
Published 2026-09-11
Built with ESP ZeroCode AI — describe a device, get production firmware.
Terms of Service · Privacy Policy