Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Temperature Based Fan Speed Controller using Arduino
Arduino Projects

Temperature Based Fan Speed Controller using Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:December 25, 202253 Comments2 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Temperature Based Fan Speed Control & Monitoring With Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

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 NameQuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
2LM35 Temperature Sensor1Amazon | AliExpress
312V DC Fan1Amazon | AliExpress
416x2 LCD Display1Amazon | AliExpress
5Potentiometer 10K1Amazon | AliExpress
6Transistor 2N22221Amazon | AliExpress
7Resistor 1K1Amazon | AliExpress
8Diode 1N40071Amazon | AliExpress
9Capacitor 10uF1Amazon | AliExpress
10LED 5mm Any Color1Amazon | AliExpress
1112V Power Supply/Adapter1Amazon | AliExpress
12Connecting Wires20Amazon | AliExpress
13Breadboard1Amazon | AliExpress



Temperature Based Fan Speed Control & Monitoring With Arduino


Circuit Diagram & Connections:

Fan Speed Controller Temperature

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:

Temperature Based Fan Speed Control & Monitoring With Arduino
Watch this video on YouTube.

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.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleWeighing Machine using Arduino Load Cell & HX711 Module
Next Article BMP180 with Arduino to measure Altitude, Pressure & Temperature

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 53 Comments

53 Comments

  1. Satya on February 8, 2019 5:42 PM

    Is the code working. ..

    Reply
    • Alex Newton on February 9, 2019 1:51 AM

      Yes

      Reply
      • Satya on February 10, 2019 12:06 PM

        Did you complete the project successfully

      • Dinesh on February 27, 2019 2:42 PM

        Sir show d connection of 16X2LCD display

      • Alex Newton on February 27, 2019 3:49 PM

        Its already showing in the circuit diagram

      • 6303620092 on September 28, 2019 4:06 PM

        Sir please give link of making video

  2. Mark Valencia on March 8, 2019 9:14 AM

    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.

    Reply
    • abdessamad on June 6, 2019 11:02 PM

      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.

      Reply
  3. N.Sai Manoj on June 17, 2019 10:23 PM

    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”.

    Reply
  4. Krishna on August 24, 2019 11:48 PM

    Sir how can we get that wires
    ..what are names of that multiple colour wires
    And what is that white colour board

    Reply
    • Alex Newton on August 25, 2019 12:32 AM

      Use male to male jumper wires. Search for male to male wires, female to male wires and female to female wires.

      Reply
  5. Krishna on August 25, 2019 2:31 PM

    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

    Reply
    • Alex Newton on August 25, 2019 2:32 PM

      1 packet each. All contains 60 wires.

      Reply
  6. Krishna on August 25, 2019 3:00 PM

    How much cost it would be for 1 pack

    Reply
  7. Naga Chetan on October 15, 2019 12:05 PM

    I gave connections as per circuit diagram.but motor not varying

    Reply
  8. Ganesh on October 23, 2019 9:19 PM

    Y lcd is not displaying

    Reply
    • Alex Newton on October 23, 2019 9:31 PM

      Use 10K Potentiometer at Pin 3 of lcd to adjust contrast

      Reply
  9. Lachlan on January 6, 2020 3:54 AM

    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)

    Reply
  10. piyush on February 14, 2020 2:46 PM

    Which software have you used for circuit diagrams?

    Reply
  11. Anand on February 24, 2020 11:38 PM

    I want change fan speed how can I do it sir ?????

    Reply
  12. Aaron.J on April 8, 2020 11:30 AM

    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

    Reply
  13. neeshad kumar sakure on May 19, 2020 3:14 PM

    sir please tell me which online stimulation have you used in the diagram pls sir its an emergency please reply now pls sir

    Reply
  14. Robert on June 14, 2020 10:31 PM

    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!

    Reply
  15. bishwajit on July 18, 2020 8:24 PM

    can i used in ac fan

    Reply
    • Mr. Alam on July 18, 2020 8:53 PM

      You can’t use AC fan.
      You need to use TRIAC with optocoupler to control such a big appliance.

      Reply
  16. bishwajit on July 18, 2020 8:47 PM

    please tell me can i used in ac fan ?????

    Reply
  17. bishwajit on July 18, 2020 9:34 PM

    please tell me how to connect

    Reply
  18. bishwajit on July 18, 2020 9:39 PM

    please give me the circuit diagram and one more question my lcd is not display temperature

    Reply
  19. bishwajit on July 18, 2020 11:10 PM

    how to connect ? please give me the circuit diagram .

    Reply
  20. eidz on August 6, 2020 10:41 AM

    sir,this project can control by iot?

    Reply
  21. SAISARATH.R on January 16, 2021 10:47 AM

    Can you give me the circuit diagram of this project using components symbol(like !> – diode)

    Reply
  22. Chris on May 7, 2021 11:35 AM

    Hi sir why if is it need to use 10k potentialmeter since ur description didt record about 10k potentialmeter answer pls emergency thanks

    Reply
    • Alex Newton on May 7, 2021 12:39 PM

      To adjust the lcd contrast

      Reply
  23. Denise Panaginip on June 18, 2021 9:31 PM

    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

    Reply
    • Alex Newton on June 18, 2021 9:41 PM

      Yes, you can.

      Reply
  24. SriRam on June 24, 2021 12:31 PM

    why do we use 1.5 * fan speed in the code?

    Reply
  25. tuferu2021 on July 27, 2021 8:21 PM

    Please can you help me with same project code that I can use to control a fan regulator. Please

    Reply
  26. Prerna on September 10, 2021 3:50 PM

    Sir can this project be made by using stm32f103c8t6 instead of arduino uno ?

    Reply
  27. IKENNA on December 1, 2021 1:29 AM

    Pls can i get a copy of this in PDF

    Reply
  28. Abdul on March 2, 2022 7:33 PM

    do you the flowchart for this?

    Reply
  29. Abdul Qawiy on March 2, 2022 7:34 PM

    do you have a flowchart for this?

    Reply
  30. Dan Marc Cuaderno on March 22, 2022 9:47 PM

    Can I use more than one fan? Thank You

    Reply
  31. Adarsh on May 15, 2022 7:50 PM

    Hello, I executed the exact circuit diagram shown above but the lcd isn’t displaying, neither the fan is turning on

    Reply
  32. Prasad Jadhav on June 22, 2022 9:33 AM

    Can you show the total connection which is on breadboard by phtoto or virtual on virtual breadboard

    Reply
  33. Henri Juutinen on August 14, 2022 3:48 PM

    Can i use tmp36 temp sensor and if, what do i change to the code?

    Reply
  34. hjuutinen on August 14, 2022 3:49 PM

    Can i use temp sens. Tmp36?

    Reply
  35. hjuutinen on August 14, 2022 6:06 PM

    I just put 0.162760417 (0.48828125/3). Now it shows correct. (Lm35 250 mv and tmp36 750mv).. i hope it shows/calculates correct….

    Reply
  36. Nishant Niuraula on August 28, 2022 6:06 AM

    how to use potentiometer show it please in the lcd display

    Reply
  37. JR on September 3, 2022 6:45 PM

    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!

    Reply
  38. GKD on January 25, 2023 11:51 AM

    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

    Reply
  39. Himanishi on June 30, 2023 3:46 AM

    how i provide 12v power supply to circuit . please specify the component name.

    Reply
  40. Meenu on February 26, 2025 10:18 PM

    hello would you like sell this product??

    Reply
    • Mamtaz Alam on February 26, 2025 10:19 PM

      If you are from India, contact:
      Amzad: +91 95722 81077

      Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • L293D Dual H-Bridge Motor Driver IC Pins, Circuit, Working
    L293D Dual H-Bridge Motor Driver IC Pins, Circuit, Working
  • LD2410 Sensor with ESP32 - Human Presence Detection
    LD2410 Sensor with ESP32 - Human Presence Detection
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.