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

Arduino UNO Based Temperature-Controlled Relay with LCD Display and Humidity Sensing

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Temperature-Controlled Relay with LCD Display and Humidity Sensing

Circuit Documentation

Summary

This circuit is designed to monitor temperature and humidity using a DHT11 sensor and display the readings on an LCD I2C display. It includes an Arduino UNO microcontroller for processing sensor data and controlling a relay based on the temperature. Two pushbuttons allow the user to adjust the set temperature at which the relay is activated. The relay controls a Peltier module and two fans, which are likely used for a temperature regulation application. The circuit is powered by a 12V 5A power supply.

Component List

Wiring Details

Arduino UNO

LCD I2C Display

DHT11

1-Channel Relay (5V 10A)

Pushbuttons (x2)

Peltier Module

Fans (x2)

Terminal PCB 2 Pin

POWER SUPPLY 12V 5AMP

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(DOWN_BUTTON_PIN) == LOW) {
      setTemperature--;
      delay(200); // Debounce delay
    }
    
    // Display set temperature on LCD
    lcd.setCursor(10, 1);
    lcd.print("Set:");
    lcd.print(setTemperature);
  }
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the DHT11 sensor and the LCD display, reads temperature and humidity data, and displays the readings on the LCD. It also controls a relay based on the temperature reading and allows the user to adjust the set temperature using pushbuttons.