Temperature Based Fan Speed Control & Monitoring With Arduino

Temperature Based Fan Speed Control & Monitoring With Arduino (Last Updated On: December 1, 2018)

Temperature Based Fan Speed Control & Monitoring With Arduino:

In this post we have described how to design Temperature Based Fan Speed Control & Monitoring With Arduino and LM35 Temperature Sensor. The microcontroller controls the speed of an electric fan according to the requirement & allows dynamic and faster control and the LCD makes the system user-friendly. Sensed temperature in Celsius Scale and fan speed in percentage are simultaneously displayed on the LCD panel.

The applications areas of this project are air-conditioners, water-heaters, snow-melters, ovens, heat-exchangers, mixers, furnaces, incubators, thermal baths and veterinary operating tables.


Components Required:

1. Arduino UNO Board
2. LM35 Temperature Sensor – (Buy Online from Amazon)
3. 2N2222 Transistor
4. 16*2 LCD Display
5. 12V DC Fan – (Buy Online from Amazon)
6. 1N4007 Diode
7. 1K Resistor – 2
8. 10uF Electrolytic Capacitor
9. LED
10. 12 Volt Battery/ Adapter




Temperature Based Fan Speed Control & Monitoring With Arduino


Circuit Diagram & Connections:

Temperature Based Fan Speed Control & Monitoring With Arduino

Circuit diagram of the Temperature Based Fan Speed Control & Monitoring With Arduino & LM35 is shown above. Arduino is at the heart of the circuit as it controls all functions. LM35 is a precision integrated circuit whose output voltage is linearly proportional to Celsius (Centigrade) temperature. It is rated to operate over a -55°C to 150°C temperature range. It has +10.0mV/Celsius linear-scale factor.




The 2N2222 transistor acts as a switch and controls the fan speed depending upon temperature. 1N4007 diode controls the fan from being damaged. LED glows whenever the temperature exceeds 60°C.


Working of the Circuit:

Temperature sensor LM35 senses the temperature and converts it into an electrical (analogue) signal, which is applied to the ATmega328 microcontroller of Arduino UNO Board. The analogue value is converted into digital value. Thus the sensed values of the temperature and speed of the fan are displayed on the LCD. When temperature exceeds 30°C the fan starts rotating.

A low-frequency pulse-width modulation (PWM) signal, whose duty cycle is varied to adjust the fan’s speed is used. An inexpensive, single, small pass transistor like 2N222 or BD139 can be used here. It is efficient because the pass transistor is used as a switch.

Temperature Based Fan Speed Control & Monitoring With Arduino

Temperature Based Fan Speed Control & Monitoring With Arduino




Source Code/Program:

The program for Temperature Based Fan Speed Control & Monitoring With Arduino is given below. Simply copy this code and paste it in your Arduino IDE. Then compile the code and then upload it.

#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
int tempPin = A0; // the output pin of LM35
int fan = 11; // the pin where fan is
int led = 8; // led pin
int temp;
int tempMin = 30; // the temperature to start the fan 0%
int tempMax = 60; // the maximum temperature when fan is at 100%
int fanSpeed;
int fanLCD;

void setup() {
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
pinMode(tempPin, INPUT);
lcd.begin(16,2);
Serial.begin(9600);
}

void loop()
{
temp = readTemp(); // get the temperature
Serial.print( temp );
if(temp < tempMin) // if temp is lower than minimum temp
{
fanSpeed = 0; // fan is not spinning
analogWrite(fan, fanSpeed);
fanLCD=0;
digitalWrite(fan, LOW);
}
if((temp >= tempMin) && (temp <= tempMax)) // if temperature is higher than minimum temp
{
fanSpeed = temp;//map(temp, tempMin, tempMax, 0, 100); // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255);
fanSpeed=1.5*fanSpeed;
fanLCD = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100
analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
}

if(temp > tempMax) // if temp is higher than tempMax
{
digitalWrite(led, HIGH); // turn on led
}
else // else turn of led
{
digitalWrite(led, LOW);
}

lcd.print("TEMP: ");
lcd.print(temp); // display the temperature
lcd.print("C ");
lcd.setCursor(0,1); // move cursor to next line
lcd.print("FANS: ");
lcd.print(fanLCD); // display the fan speed
lcd.print("%");
delay(200);
lcd.clear();
}

int readTemp() { // get the temperature and convert it to celsius
temp = analogRead(tempPin);
return temp * 0.48828125;
}

Video Tutorial & Explanation:





Leave a Reply

Your email address will not be published. Required fields are marked *