A room temperature controller with relay and fan automation maintains comfortable room temperatures by automatically switching fans, coolers, or ACs based on sensor readings. This practical Arduino project is perfect for Indian homes and offices where temperature management directly affects comfort and productivity.
Project Overview
This project uses an Arduino or ESP32 to read room temperature, display it on an LCD, and control a relay that switches an AC fan or cooler. The system turns cooling on when temperature exceeds the set point and off when it drops below — with hysteresis to prevent rapid cycling.
Components Required
- Arduino Uno (₹193) or ESP32 (₹329 for WiFi)
- DHT22 temperature and humidity sensor (₹91)
- 16×2 I2C LCD display for local readout
- Relay module — 5V for fan, SSR for AC unit
- Pushbuttons (2) for set point adjustment
- Buzzer for alerts
- 5V power supply or USB power
Core Components
Circuit Design
- DHT22: VCC→5V, GND→GND, Data→Arduino pin 2
- LCD I2C: SDA→A4, SCL→A5
- Relay IN→Arduino pin 7
- Button UP→pin 3, Button DOWN→pin 4 (with internal pull-ups)
- Buzzer→pin 8
Arduino Code with LCD Display
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHT_PIN 2
#define RELAY_PIN 7
#define BTN_UP 3
#define BTN_DOWN 4
#define BUZZER 8
#define HYST 2.0
DHT dht(DHT_PIN, DHT22);
LiquidCrystal_I2C lcd(0x27, 16, 2);
float setpoint = 28.0;
bool fanOn = false;
void setup() {
dht.begin();
lcd.init(); lcd.backlight();
pinMode(RELAY_PIN, OUTPUT);
pinMode(BTN_UP, INPUT_PULLUP);
pinMode(BTN_DOWN, INPUT_PULLUP);
pinMode(BUZZER, OUTPUT);
}
void loop() {
if (!digitalRead(BTN_UP)) { setpoint += 0.5; delay(200); }
if (!digitalRead(BTN_DOWN)) { setpoint -= 0.5; delay(200); }
setpoint = constrain(setpoint, 18, 35);
float temp = dht.readTemperature();
float hum = dht.readHumidity();
if (temp >= setpoint + HYST && !fanOn) {
digitalWrite(RELAY_PIN, HIGH); fanOn = true;
} else if (temp = 40) tone(BUZZER, 2000, 500); // High temp alarm
lcd.setCursor(0, 0);
lcd.print("T:"); lcd.print(temp,1); lcd.print("C ");
lcd.print("H:"); lcd.print(hum,0); lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Set:"); lcd.print(setpoint,1);
lcd.print(fanOn ? " FAN ON " : " FAN OFF");
delay(2000);
}
Multi-Zone Control
For multi-room control, add more DHT22 sensors and relay channels. Each zone gets its own set point. Use an Arduino Mega (more pins) or ESP32 with I2C expander for 4+ zones.
Adding WiFi with ESP32
Upgrade to an ESP32 to add WiFi control, smartphone app (via Blynk or web server), temperature logging to InfluxDB, and Telegram alerts. The core control logic remains identical — only the communication layer changes.
Recommended Components
Room Controller Components
Extending the Project
- Add a real-time clock (DS3231) for scheduled temperature profiles (cooler at night, warmer during day)
- Add an SD card for data logging — analyse temperature patterns over weeks
- Integrate with home automation (MQTT to Home Assistant)
- Add occupancy detection (PIR sensor) — turn off cooling when room is empty
Frequently Asked Questions
Can this control my AC?
For split ACs, use an IR LED with IRremoteESP8266 library to send IR commands — no relay needed. For window ACs or coolers, use a relay to switch the mains power.
What is the cost of this project?
Under ₹500 for the basic version (Arduino + DHT22 + relay + LCD). Under ₹1,000 with ESP32 for WiFi control. Significantly cheaper than commercial smart thermostats.
How accurate is the temperature reading?
DHT22 provides ±0.5°C accuracy. For most room temperature control applications, this is more than sufficient. Mount the sensor away from heat sources and AC vents.
Can I use this with a desert cooler?
Yes. Connect the relay to the cooler’s pump and fan circuit. When temperature rises above the set point, the cooler turns on. This works perfectly for Indian desert coolers.
Is it safe to switch mains with this circuit?
Yes, when properly built: use rated relay modules, mains-rated wire, fused connections, and an insulated enclosure. Never leave exposed mains connections. Consider SSR for heavy loads.
Shop Cooling & Thermal Components at Zbotic
India’s trusted store for electronics components. Fast shipping, genuine products, and expert support.
Add comment