How to Make Temperature Controlled Fan Using Arduino and DHT11
2285 Views, 4 Favorites, 0 Comments
How to Make Temperature Controlled Fan Using Arduino and DHT11
Temperature-controlled fans have become a popular DIY project for keeping your surroundings cool automatically. In this blog, we will guide you through creating a temperature-controlled fan using an Arduino board. With just a few electronic components and a little bit of coding, you can have a fan that activates when the temperature starts to rise, providing a cost-effective and efficient solution.
Supplies
Electronics Connection
Connect all the electronics as shown in the figure
You can also Refer to this video - Click here
Download the Arduino IDE
The Arduino IDE is the software you will use to write and upload code to your Arduino board. You can download it for free from the Arduino website.
Connect Your Arduino Board to Your Computer
Upload Code
Connect the Arduino Board with the Arduino IDE and upload the given CODE
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int potPin = A0;
const int fanPin = 3; // Connect the fan to this pin
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address and dimensions
void setup() {
dht.begin();
pinMode(fanPin, OUTPUT);
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0);
lcd.print("Temp Fan Control");
lcd.setCursor(0, 1);
lcd.print("by Your Name");
delay(2000);
lcd.clear();
}
void loop() {
int threshold = map(analogRead(potPin), 0, 1023, 20, 40); // Map potentiometer value to temperature range
float temperature = dht.readTemperature();
if (temperature > threshold) {
digitalWrite(fanPin, HIGH); // Turn on the fan
} else {
digitalWrite(fanPin, LOW); // Turn off the fan
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Threshold: ");
lcd.print(threshold);
lcd.print("C");
delay(1000);
}
You can refer to this video