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

Arduino UNO Controlled Temperature-Activated Motor with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Temperature-Activated Motor with LCD Display

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions using a DHT11 sensor and display the temperature and humidity on an LCD screen. It also includes a DC motor that is controlled by a relay, which is activated when the temperature exceeds a certain threshold. The Arduino UNO serves as the central microcontroller unit, interfacing with the DHT11 sensor, the LCD screen via I2C, and controlling the relay to manage the DC motor. A 9V battery provides power to the relay, and the Arduino UNO's 5V output powers the other components.

Component List

Arduino UNO

DHT11

LCD screen 16x2 I2C

DC Motor

12V SINGLE CHANNEL RELAY

9V Battery

Wiring Details

Arduino UNO

DHT11

LCD screen 16x2 I2C

DC Motor

12V SINGLE CHANNEL RELAY

9V Battery

Documented Code

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

// Define pin connections
#define DHTPIN 2 // DHT11 data pin connected to Arduino D2
#define DHTTYPE DHT11 // DHT11 sensor type
#define RELAY_PIN 3 // Relay IN pin connected to Arduino D3

// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);

// Initialize the LCD (address 0x27, 16 columns and 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize the DHT sensor
  dht.begin();

  // Initialize the LCD
  lcd.init();
  lcd.backlight();

  // Initialize the relay control pin as an output
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW); // Start with the relay off
}

void loop() {
  // Read temperature and humidity values
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  // Check if any reads failed and exit early (to try again).
  if (isnan(temperature) || isnan(humidity)) {
    lcd.clear();
    lcd.print("Failed to read");
    return;
  }

  // Display temperature and humidity on the LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print("C");

  lcd.setCursor(0, 1);
  lcd.print("Humidity: ");
  lcd.print(humidity);
  lcd.print("%");

  // Control the relay based on the temperature
  // For example, turn on the motor if the temperature is above 25 degrees Celsius
  if (temperature > 25) {
    digitalWrite(RELAY_PIN, HIGH); // Turn on the relay (and the motor)
  } else {
    digitalWrite(RELAY_PIN, LOW); // Turn off the relay (and the motor)
  }

  // Wait a bit before reading again
  delay(2000); // Delay of 2 seconds
}

This code is responsible for reading temperature and humidity data from the DHT11 sensor and displaying it on the LCD screen. It also controls the relay, which in turn controls the DC motor, based on the temperature readings.