Site icon Circuit Ideas for You

Arduino Temperature Controller Circuit using DC Fan

This article show how to make Arduino Temperature Controller Circuit using DC Fan Arduino UNO, LCD, transistor, DHT11 sensor and with few resistors.

It show temperature and fan speed on LCD and control fan speed based on room temperature in home or office.

Fan turns ON and OFF automatic when temperature goes above or below a set limit.

Coding:

#include <LiquidCrystal.h>
#include <DHT.h>

#define DHTPIN 2     // Digital pin connected to DHT sensor
#define DHTTYPE DHT11 // DHT sensor type

#define FANPIN 3     // Digital pin connected to transistor base

#define LCD_RS 7     // LCD Register Select pin
#define LCD_EN  8     // LCD Enable pin
#define LCD_D4  5     // LCD Data pin 4
#define LCD_D5  6     // LCD Data pin 5
#define LCD_D6  11    // LCD Data pin 6
#define LCD_D7  12    // LCD Data pin 7

#define TEMP_THRESHOLD 25.0 // Temperature threshold in degrees Celsius

LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  lcd.begin(16, 2);
  dht.begin();
  pinMode(FANPIN, OUTPUT);
}

void loop() {
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  if (isnan(temperature) || isnan(humidity))   
 {
    lcd.setCursor(0, 0);
    lcd.print("Error reading DHT sensor!");
  } else {
    lcd.setCursor(0, 0);
    lcd.print("Temp: ");
    lcd.print(temperature);
    lcd.print(" C  Humidity: ");
    lcd.print(humidity);
    lcd.print("%");

    if (temperature >= TEMP_THRESHOLD) {
      digitalWrite(FANPIN, HIGH);
    } else {
      digitalWrite(FANPIN, LOW);
    }
  }

  delay(1000);
}

Code Explanation:

Code Logic:

Circuit Working:

Parts List:

ComponentQuantity
Resistor
1k 1/4 watt1
470Ω 1/4 watt1
Semiconductors
Arduino UNO1
DHT11 sensor1
DC Fan 9V1
16×2 LCD1
IC 78091
Transistor 2N22221

This circuit project is easy to work and make.

Arduino make PWM at PWM pin and sends to transistor base.

Transistor give voltage based on PWM signal.

PWM control fan speed through transistor.

DHT11 send temperature and humidity to Arduino.

Arduino check if temperature is more than set limit.

If temperature is high then transistor turns ON and fan starts.

If temperature is low then transistor turns OFF and fan stops.

LCD shows current temperature and humidity.

How to Build:

To build a Arduino Temperature Controller Circuit using DC Fan following are the steps for connections:

DC Fan Connection:

Transistor 2N2222 Connection:

DHT11 Sensor Connection:

LCD Connection to Arduino:

Conclusion:

This Arduino Temperature Controller Circuit control DC fan based on room temperature.

Its threshold temperature can be changed.

If we require more features like humidity and alerts it can be added.

References:

Trouble turning on temperature controlled DC fan at the correct value

Exit mobile version