This project presents an embedded system for intelligent water heater control using an ESP32 microcontroller. The system provides dual operational modes—manual and automatic—with real-time temperature monitoring, safety features, and a user-friendly interface. The controller employs a thermocouple sensor for precise temperature measurements and implements hysteresis-based control logic to maintain water temperature within specified ranges while preventing excessive heating cycles.
Water heating systems consume significant energy in residential and commercial applications. This project addresses the need for efficient, safe, and user-controllable water heating through an embedded control system. The controller offers flexibility through two distinct operating modes while maintaining critical safety thresholds to prevent overheating.
- Implement dual-mode operation (manual and automatic) for diverse user requirements
- Provide real-time temperature monitoring and display
- Ensure system safety through maximum temperature limits
- Minimize relay switching cycles through hysteresis control
- Create an intuitive user interface for configuration and monitoring
The system comprises the following key components:
| Component | Model/Type | Function |
|---|---|---|
| Microcontroller | ESP32 | Main processing unit and control logic |
| Temperature Sensor | MAX6675 Thermocouple | High-precision temperature measurement |
| Display | SSD1306 OLED (128×64) | User interface and status display |
| Relay Module | SPDT Relay | Heater power control |
| Mode Switch | SPDT Switch | Manual/Auto mode selection |
| Push Button | Momentary Switch | User input and configuration |
Temperature Sensor (MAX6675):
- SO: GPIO 19
- CS: GPIO 5
- SCK: GPIO 18
Display (I2C):
- SDA: GPIO 21
- SCL: GPIO 22
Control Inputs:
- MANUAL_PIN: GPIO 14
- AUTO_PIN: GPIO 27
- BUTTON_PIN: GPIO 26
- RELAY_PIN: GPIO 25
The system implements a state-machine architecture with independent state management for manual and automatic modes. Temperature readings occur at 500ms intervals, and the display refreshes continuously to provide real-time feedback.
- Maximum Temperature Limit: 70°C hard limit to prevent overheating
- Sensor Fault Detection: System halts heating if invalid temperature readings occur
- Mode Transition Protection: Safe state reset during mode changes
The automatic mode provides two operational scenarios:
- System initializes with current temperature as baseline
- After 10-second idle period, establishes asymmetric temperature range: [T_current + 2°C, T_current + 7°C]
- Maintains temperature within this range using hysteresis control
- Asymmetric range provides gradual warming from ambient temperature
- User sets desired temperature via button press (increment by 1°C per press)
- After 3-second confirmation delay, establishes symmetric control range: [T_set - 2°C, T_set + 2°C]
- System maintains temperature within tighter band centered on user preference
Control Logic:
- Heater activates when temperature ≤ lower threshold
- Heater deactivates when temperature ≥ upper threshold
The manual mode offers two distinct control methods:
- Each button press adds 60 seconds to heating timer
- Input confirmation period: 3 seconds
- Heater operates for specified duration
- Status displays remaining time in MM:SS format
- Activates after 6-second idle period
- User sets target temperature (initialized to current temperature)
- System heats until target temperature achieved
- 10-second timeout for temperature input
- Automatic reset after target reached
- Short Press: Increment timer (Manual) or temperature setting
- Long Press (>2 seconds): System reset to initial state
- Connect MAX6675 thermocouple module to designated GPIO pins
- Wire SSD1306 OLED display via I2C interface
- Connect relay module to GPIO 25
- Install mode selection switch between GPIO 14 and GPIO 27
- Attach momentary push button to GPIO 26
- Ensure all components share common ground with ESP32
- Arduino IDE (version 2.x or later)
- ESP32 board support package
- Adafruit_GFX
- Adafruit_SSD1306
- max6675
- Open
Final_Code/Final_Code.inoin Arduino IDE - Select board: "ESP32 Dev Module"
- Configure upload settings and select appropriate COM port
- Compile and upload to ESP32
- Power on the system
- Select desired mode using SPDT switch (Manual/Auto)
- Follow on-screen instructions for configuration
- Monitor temperature and heater status on OLED display
The OLED display provides comprehensive system status:
Water Heater
Controller
[MODE NAME]
Heater: [ON/OFF] T: [XX.X]C
- Auto Mode: Set temperature or operational range
- Manual Mode: Remaining time or target temperature
- Temperature Range: 0°C to 70°C (safety limited)
- Temperature Resolution: 0.25°C (MAX6675 specification)
- Update Rate: 500ms for temperature readings
- Control Method: Hysteresis-based bang-bang control
- Power Supply: 5V DC (ESP32 standard)
- Relay Rating: As per relay module specification
The Components_testing directory contains modular test programs developed during system integration:
- OLED_initial_test: Display initialization verification
- Thermocouple_test: Temperature sensor validation
- ESP32_OLED_SPDT: Mode switching functionality
- ESP32_OLED_ManualPushbutton_Relay: Integrated component testing
These test programs facilitate troubleshooting and component verification.
This project is provided as-is for educational and development purposes. Users assume all responsibility for implementation and safety compliance.
Component Libraries:
- Adafruit Industries (Display Libraries)
- MAX6675 Library Contributors
Authors: Shass27, sumedha2932-source Platform: Arduino IDE