Arduino Temperature Control
Arduino Temperature Control
Arduino Temperature Control
Temperature
Arduino. With this circuit, we will be able to adjust the fan speed in our home or
office according to the room temperature and also show the temperature and fan speed changes
on a 16x2 LCD display. To do this we will be using an Arduino UNO Board, LCD, DHT11
sensor Module, and DC fan that is controlled by using PWM. Let's discuss more on this is done
so that you can build one on your own. We have also built a project to perform Automatic AC
temperature control, you can also check that out if you are intrested.
Components Required
The following are the materials required to perform a temperature-based fan speed control
using Arduino. Most of the components should be easily available in your local hardware shop
1. Arduino UNO
2. DHT11 sensor
3. DC Fan
4. 2n2222 transistor
5. 9 volt battery
6. 16x2 LCD
7. 1K resistor
8. Connecting wires
temperature sensor namely DHT11. The second section reads the dht11 sensor module’s
output and extracts temperature value into a suitable number in Celsius scale and control
the fan speed by using PWM. And last part of system shows humidity and temperature on LCD
we have only used this DHT sensor for sensing temperature, and then programmed our arduino
Working on this project is very simple. We have created PWM at pwm pin of arduino and
applied it at base terminal of the transistor. Then transistor creates a voltage according to the
PWM input.
Fan speed and PWM values and duty cycles values are showing in given table
26 20 % 51 20%
understand it more simply, if you are applying 5 volt for driving a motor then motor will moving
with some speed, now if we reduces applied voltage by 2 means we apply 3 volts to motor then
motor speed also decreases. This concept is used in the project to control the voltage using
PWM. (To understand more about PWM, check this circuit: 1 Watt LED Dimmer)
The main game of PWM is digital pulse with some duty cycle and this duty cycle is responsible
Suppose we have a pule with duty cycle 50% that means it will give half of voltage that we
apply.
display is used for displaying temperature and Fan speed Status. LCD is directly connected to
Arduino in 4-bit mode (Check this tutorial for more details: LCD Interfacing with Arduino
Uno). Pins of LCD namely RS, EN, D4, D5, D6 and D7 are connected to Arduino digital pin
number 7, 6, 5, 4, 3 and 2. And a DHT11 sensor module is also connected to digital pin 12 of
Arduino. Digital pin 9 is used for controlling fan speed through the transistor.
If you are looking for something simple and more cost-effective you can check out
the temperature controlled LED using LM35 and Temperature controlled Automatic AC
switch projects, both of them are very easy to built and does not need a microcontroller.
for fan.
Then initialize all the things in setup loop. And in loop by using dht function reads DHT sensor
and then using some dht functions we extract temperature and display these on LCD.
After this we compare the temperature with pre define temperature digit and then generate PWM
PWM value is equivalent of analog value. So if we need to generate 20% of duty cycle then we
Code
#include<dht.h> // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
#define dht_dpin 12
dht DHT;
#define pwm 9
byte degree[8] =
{
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
lcd.begin(16, 2);
lcd.createChar(1, degree);
lcd.clear();
lcd.print(" Fan Speed ");
lcd.setCursor(0,1);
lcd.print(" Controlling ");
delay(2000);
analogWrite(pwm, 255);
lcd.clear();
lcd.print("Circuit Digest ");
delay(2000);
}
void loop()
{
DHT.read11(dht_dpin);
int temp=DHT.temperature;
lcd.setCursor(0,0);
lcd.print("Temperature:");
lcd.print(temp); // Printing temperature on LCD
lcd.write(1);
lcd.print("C");
lcd.setCursor(0,1);
if(temp <26 )
{
analogWrite(9,0);
lcd.print("Fan OFF ");
delay(100);
}
else if(temp==26)
{
analogWrite(pwm, 51);
lcd.print("Fan Speed: 20% ");
delay(100);
}
else if(temp==27)
{
analogWrite(pwm, 102);
lcd.print("Fan Speed: 40% ");
delay(100);
}
else if(temp==28)
{
analogWrite(pwm, 153);
lcd.print("Fan Speed: 60% ");
delay(100);
}
else if(temp==29)
{
analogWrite(pwm, 204);
lcd.print("Fan Speed: 80% ");
delay(100);
}
else if(temp>29)
{
analogWrite(pwm, 255);
lcd.print("Fan Speed: 100% ");
delay(100);
}
delay(3000);
}
Video
Tags
arduino
arduino uno
DHT11
sensors
Comments
Submitted by Mohamed on Mon, 08/10/2015 - 03:05
Permalink
Mistake in diagram
Diagram mistake is that there is no ground in fan motor circuit