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.
Bill of Materials
S.N. | Components Name | Quantity | Purchase Links |
---|---|---|---|
1 | Arduino UNO Board | 1 | Amazon | AliExpress |
2 | LM35 Temperature Sensor | 1 | Amazon | AliExpress |
3 | 12V DC Fan | 1 | Amazon | AliExpress |
4 | 16x2 LCD Display | 1 | Amazon | AliExpress |
5 | Potentiometer 10K | 1 | Amazon | AliExpress |
6 | Transistor 2N2222 | 1 | Amazon | AliExpress |
7 | Resistor 1K | 1 | Amazon | AliExpress |
8 | Diode 1N4007 | 1 | Amazon | AliExpress |
9 | Capacitor 10uF | 1 | Amazon | AliExpress |
10 | LED 5mm Any Color | 1 | Amazon | AliExpress |
11 | 12V Power Supply/Adapter | 1 | Amazon | AliExpress |
12 | Connecting Wires | 20 | Amazon | AliExpress |
13 | Breadboard | 1 | Amazon | AliExpress |
Circuit Diagram & Connections:
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. The LED glows whenever the temperature exceeds 60°C.
Working of the Circuit:
Temperature sensor LM35 senses the temperature and converts it into an electrical (analog) signal, which is applied to the ATmega328 microcontroller of the Arduino UNO Board. The analog value is converted into a digital value. Thus the sensed values of the temperature and speed of the fan are displayed on the LCD. When the 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.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#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:
The IoT Version of this project can be made using ESP8266 & DS18B20 Waterproof Temperature Sensor . The fan speed and data can be monitored on Blynk Application. Click on the image below for the project info.
51 Comments
Is the code working. ..
Yes
Did you complete the project successfully
Sir show d connection of 16X2LCD display
Its already showing in the circuit diagram
Sir please give link of making video
Hello, is it possible if you could show the LCD inputs? (e.g: VSS, VDD, D0, D1…etc). I’ve tried this, but the LCD wont light up.
Hello, is it possible if you could show the LCD inputs? (e.g: VSS, VDD, D0, D1…etc). I’ve tried this, but the LCD wont light up.
I AM GETTING LIKE THIS WHILE UPLOADING THE CODE TO THE ARDUINO BORD.PLEASE HELP ME TO OVER COME THIS PROBLEM.
“Sketch uses 4374 bytes (13%) of program storage space. Maximum is 32256 bytes.
Global variables use 246 bytes (12%) of dynamic memory, leaving 1802 bytes for local variables. Maximum is 2048 bytes”.
Sir how can we get that wires
..what are names of that multiple colour wires
And what is that white colour board
Use male to male jumper wires. Search for male to male wires, female to male wires and female to female wires.
How many wires we have to take according their names like male to male ,female to male and female to female …..plz sir tell me quickly
1 packet each. All contains 60 wires.
How much cost it would be for 1 pack
I gave connections as per circuit diagram.but motor not varying
Y lcd is not displaying
Use 10K Potentiometer at Pin 3 of lcd to adjust contrast
Would it be possible to add a Max voltage (12V) option by adding an additional wire from the negative terminal of the battery to the negative terminal of the motor with a switch in the wire? I want to have the option to turn it fully to max manually if needed (for quick ventilation)
Which software have you used for circuit diagrams?
I want change fan speed how can I do it sir ?????
1)DC12V 9.1W motor conncted but not motor runing
2)I check the voltage in multimeter in 6 to 9v varing but motor not run it not a fault motor it’s run in 9v HW battery
3)I use 3v DC motor but not run
4)Please send replay
sir please tell me which online stimulation have you used in the diagram pls sir its an emergency please reply now pls sir
Excellent project and very well presented. By altering the tempMin and tempMax values and adjusting the fanSpeed factor to 1.1, I have very good control of the fan in my linear amplifier. Well do everything and thanks!
can i used in ac fan
You can’t use AC fan.
You need to use TRIAC with optocoupler to control such a big appliance.
please tell me can i used in ac fan ?????
please tell me how to connect
please give me the circuit diagram and one more question my lcd is not display temperature
how to connect ? please give me the circuit diagram .
sir,this project can control by iot?
Can you give me the circuit diagram of this project using components symbol(like !> – diode)
Hi sir why if is it need to use 10k potentialmeter since ur description didt record about 10k potentialmeter answer pls emergency thanks
To adjust the lcd contrast
Hey Hi can i use 9v dc motor as well as 9v battery instead of 12v fan and 12v battery? I really do hope for your response sir thank you, For project purposes
Yes, you can.
why do we use 1.5 * fan speed in the code?
Please can you help me with same project code that I can use to control a fan regulator. Please
Sir can this project be made by using stm32f103c8t6 instead of arduino uno ?
Pls can i get a copy of this in PDF
do you the flowchart for this?
do you have a flowchart for this?
Can I use more than one fan? Thank You
Hello, I executed the exact circuit diagram shown above but the lcd isn’t displaying, neither the fan is turning on
Can you show the total connection which is on breadboard by phtoto or virtual on virtual breadboard
Can i use tmp36 temp sensor and if, what do i change to the code?
Can i use temp sens. Tmp36?
I just put 0.162760417 (0.48828125/3). Now it shows correct. (Lm35 250 mv and tmp36 750mv).. i hope it shows/calculates correct….
how to use potentiometer show it please in the lcd display
Thank you for this! I’m about to try it without the LCD. Can you show me how to use it with I2C instead of this way with all those extra wires? I would really appreciate it!
sir the project is not working the lcd is not turning on its an emergency I am a student I need help please i have to show my project in 2 days
how i provide 12v power supply to circuit . please specify the component name.