Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Smart Temperature Control System with Wi-Fi and LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Temperature Control System with Wi-Fi and LCD Display

Circuit Documentation

Summary

This circuit is designed to monitor temperature and humidity using a DHT11 sensor and display the readings on an I2C LCD. It also includes a relay to control a water pump based on the temperature readings. The circuit is powered by a 12V power supply and includes an Arduino UNO as the main microcontroller, an ESP8266-01 WiFi module for connectivity, and additional components like a fan and a resistor.

Component List

  1. Arduino UNO

    • Description: Main microcontroller
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LCD I2C Display

    • Description: 16x2 character display with I2C interface
    • Pins: GND, VCC, SDA, SCL
  3. 1-Channel Relay (5V 10A)

    • Description: Relay module for switching high-power devices
    • Pins: NC, signal, C, power, NO, ground
  4. POWER SUPPLY 12V 5AMP

    • Description: Power supply unit
    • Pins: 220V Positive Pole (AC), 220V Negative Pole (AC), GND, GND (DC), 12V-24V Output (DC)
  5. DS18B20

    • Description: Temperature sensor
    • Pins: VDD, DQ, GND
  6. Battery

    • Description: Power source
    • Pins: -, +
  7. WiFi module ESP8266-01

    • Description: WiFi module for connectivity
    • Pins: RX, GPIO0, GPIO2, GND, +3V3, Reset, CH-PD Chip power down, TX
  8. Water Pump

    • Description: Pump for water circulation
    • Pins: positive, negative
  9. Resistor

    • Description: 200 Ohms resistor
    • Pins: pin1, pin2
  10. Fan

    • Description: Cooling fan
    • Pins: GND, 5V

Wiring Details

Arduino UNO

LCD I2C Display

1-Channel Relay (5V 10A)

POWER SUPPLY 12V 5AMP

DS18B20

Battery

WiFi module ESP8266-01

Water Pump

Resistor

Fan

Documented Code

#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Define pin assignments
#define DHTPIN A3
#define DHTTYPE DHT11
#define UP_BUTTON_PIN 6
#define DOWN_BUTTON_PIN 7
#define RELAY_PIN 3

// Create DHT sensor object
DHT dht(DHTPIN, DHTTYPE);

// LCD setup (assuming you are using an I2C LCD)
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the address and size if necessary

// Variables
int setTemperature = 23; // Temperature to activate relay
const unsigned long INTERVAL = 1000; // Update interval for sensor readings
unsigned long previousTime = 0;

void setup() {
  Serial.begin(9600);
  
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH); // Initially turn off the relay
  
  pinMode(UP_BUTTON_PIN, INPUT_PULLUP);
  pinMode(DOWN_BUTTON_PIN, INPUT_PULLUP);
  
  dht.begin();
  
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Initializing...");
  delay(1000);
  
  lcd.clear();
  Serial.println("DHT11 Humidity & Temperature Sensor");
  delay(1000);
}

void loop() {
  unsigned long currentTime = millis();
  
  if (currentTime - previousTime >= INTERVAL) {
    previousTime = currentTime;
    
    // Read temperature and humidity
    float humidity = dht.readHumidity();
    float temperature = dht.readTemperature();
    
    // Check if readings failed
    if (isnan(humidity) || isnan(temperature)) {
      Serial.println("Failed to read from DHT sensor!");
      return;
    }
    
    // Print to Serial Monitor
    Serial.print("Current humidity = ");
    Serial.print(humidity, 1);
    Serial.print("%  Temperature = ");
    Serial.print(temperature, 1);
    Serial.print((char)223);
    Serial.println("C");
    
    // Display on LCD
    lcd.setCursor(0, 0);
    lcd.print("Hum:");
    lcd.print(humidity, 0);
    lcd.print("%");
    
    lcd.setCursor(0, 1);
    lcd.print("Temp:");
    lcd.print(temperature, 0);
    lcd.print((char)223);
    lcd.print("C");
    
    // Relay control
    if (temperature > setTemperature) {
      Serial.println("Relay: ON");
      lcd.setCursor(9, 0);
      lcd.print("SW:ON  ");
      digitalWrite(RELAY_PIN, LOW);
    } else {
      Serial.println("Relay: OFF");
      lcd.setCursor(9, 0);
      lcd.print("SW:OFF ");
      digitalWrite(RELAY_PIN, HIGH);
    }
    
    // Button handling
    if (digitalRead(UP_BUTTON_PIN) == LOW) {
      setTemperature++;
      delay(200); // Debounce delay
    }
    
    if (digitalRead