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);
}
- The DHT11 sensor measures the ambient temperature and humidity
- LCD display shows the humidity and temperature values as of right now.
- Transistor uses temperature to regulate the DC fan.
- The temperature threshold is the point at which the fan activates.
Code Logic:
- It utilizes the DHT11 sensor to read the temperature and humidity.
- Looks for inaccuracies in the sensor readings.
- Shows the measurements on the LCD.
- Checks the temperature against the cutoff.
- Depending on the comparison, turns the fan on or off.
Circuit Working:

Parts List:
Component | Quantity |
---|---|
Arduino UNO | 1 |
DHT11 sensor | 1 |
DC Fan 9V | 1 |
16×2 LCD | 1 |
IC 7809 | 1 |
Transistor 2N2222 | 1 |
Resistors 1k | 1 |
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:
- Gather all the components mentioned in the above circuit diagram.
- Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
- Connect a resistor 470Ω from LCD backlight anode to Arduino 5V.
Connection of DC Fan:
- Connect positive terminal of DC Fan to the collector pin of the transistor 2N2222.
- Connect Negative Terminal of DC Fan to ground GND.
Connection of Transistor 2N2222:
- Connect collector of transistor 2N2222 to positive wire of DC Fan.
- Connect base of transistor 2N2222 to pin 13 of digital pin on Arduino board through resistor 1k.
- Connect emitter of transistor 2N2222 to ground.
Connection of DHT11 Sensor:
- Connect the DHT11s VCC pin on the Arduinos board 5V pin.
- Connect the DHT11s GND pin on the Arduinos board GND pin.
- Connect the DHT11s DATA pin on digital pin on the Arduino pin 2
Connection of LCD Display to an Arduino board:
- Connect the LCDs VDD pin to 5V on the Arduino.
- Connect the LCDs VSS GND pin to GND on the Arduino.
- Connect the LCDs D4 pin to Arduino board pin 5
- Connect the LCDs D5 pin on the Arduino board pin 6
- Connect the LCDs D6 pin on the Arduino board pin 11
- Connect the LCDs D7 pin on the Arduino board pin 12
- Connect the LCDs RS pin on the Arduino board pin 7
- Connect the LCDs Enable pin on the Arduino board pin 8
- Connect the LCDs R/W pin on the Arduino board ground.
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
Leave a Reply