How to design Temperature Based Fan Speed Control & Monitoring With Arduino

In our technologically advanced society, new innovations are being developed constantly. These new developments in electronics projects are the result of a continually expanding network that works to exchange and acquire information about the most recent trends in the industrial Platform. This post discusses how to use an Arduino and LM35 temperature sensor to construct temperature-based fan speed control and monitoring systems. The LCD makes the system user-friendly, and the microprocessor dynamically and quickly changes the speed of an electric fan in accordance with the requirements. The LCD panel concurrently displays the sensed temperature in Celsius and the fan speed in percentage.

Air conditioners, water heaters, snow melters, ovens, heat exchangers, mixers, furnaces, incubators, thermal baths, and veterinary operating tables are some of the applications this project can be used in.

Components Required

  • Arduino UNO R3 Development Board
  • LM35 Analog Temperature Sensor
  • 12V DC Fan
  • 2N2222 NPN Transistor
  • JHD162A 16×2 LCD Display
  • Potentiometer 10K
  • 12V Battery/Adapter
  • 10uF Electrolytic Capacitor
  • 1N4007 Diode
  • Resistor-1K
  • 5mm LED Any Color
  • Breadboard
  • Connecting wires
Temperature Based Fan Speed Control & Monitoring With Arduino

Circuit Diagram & Connections:

Fan Speed Controller Temperature

The temperature-based fan speed control and monitoring circuit diagram using an Arduino and an LM35 is displayed above. The circuit’s brain, Arduino, regulates every operation. The output voltage of the precision integrated circuit LM35 is linearly proportional to temperature in Celsius (Centigrade). It has a temperature operating range of -55 to 150 degrees Celsius. Its linear-scale factor is +10.0 mV/Celsius.

Depending on the temperature, the 2N2222 transistor functions as a switch and regulates the fan speed. The fan is kept from harm by a 1N4007 diode. Anytime the temperature rises above 60 °C, the LED illuminates.

Working of the Circuit:

The Arduino UNO Board’s ATmega328 microprocessor receives an electrical (analogue) signal from the temperature sensor LM35, which monitors the temperature. A digital value is created out of the analog value. As a result, the fan’s speed and temperature readings are presented on the LCD. The fan begins to turn when the temperature rises above 30°C.

To change the fan’s speed, a low-frequency pulse-width modulation (PWM) signal is employed, with a variable duty cycle. Here, a cheap, single, small pass transistor, such as the 2N222 or BD139, can be employed. The usage of the pass transistor as a switch makes it efficient.

Source Code/Program:

The following section contains the programme for Temperature Based Fan Speed Control & Monitoring With Arduino. Put this code in your Arduino IDE by simply copying and pasting it. Compile the code next, after which 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);

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);
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);
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

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


I hope all of you understand how to design Temperature Based Fan Speed Control & Monitoring With Arduino and LM35 Temperature Sensor. We MATHA ELECTRONICS will be back soon with more informative blogs.

Leave a Reply

Your email address will not be published.