Site icon Circuit Ideas for You

Arduino Temperature Controller Circuit using DC Fan

This Arduino Temperature Controller Circuit article shows how to assemble a basic temperature controller by using an Arduino UNO board, an LCD display, a DC fan, a transistor, a DHT11 temperature and humidity sensor, and a few resistors.

This circuit will allow us to display changes in both temperature and fan speed on a LCD display and control the fan speed in our house or business places based on the ambient temperature.

The DC fan will be automatically turned on or off by the system depending on the chosen temperature threshold, which will be monitored by the system.

Coding with Explanation:

#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 Logic:

Circuit Working:

Parts List:

ComponentQuantity
Arduino UNO1
DHT11 sensor1
DC Fan 9V1
16×2 LCD1
IC 78091
Transistor 2N22221
Resistors 1k1
Resistors 470Ω1

Circuit working on this project is fairly easy to work on.

Here PWM is developed at the Arduinos PWM pin and applied it to the transistors base terminal.

Subsequently, the transistor generates a voltage based on the PWM input.

The Arduino generates a PWM signal, which is then sent to the transistor to operate the project.

The voltage is then within the transistors control, and this influences the fan speed.

The DHT11 sensor provides temperature and humidity information to the Arduino UNO board.

The selected threshold is compared to the temperature.

The transistor turns on and turns on the DC fan if the temperature rises beyond the threshold.

The transistor is turned off and the DC fan stops if the temperature drops below the threshold.

The LCD shows the current humidity and temperature data.

How to Build:

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

Connection of DC Fan:

Connection of Transistor 2N2222:

Connection of DHT11 Sensor:

Connection of LCD Display to an Arduino board:

Conclusion:

An easy and efficient way to automatically adjust a DC fan depending on the outside temperature is with this Arduino based temperature controller.

The temperature threshold may be changed, and other functions like humidity control and temperature alerts can be added to tailor the system.

References:

Trouble turning on temperature controlled DC fan at the correct value

Exit mobile version