Temperature Controlled Fan Using Arduino Uno (Step-by-Step Guide)

 Temperature controlled fan using Arduino 


Introduction

The Temperature Controlled Fan using Arduino is a smart automation project that regulates a fan based on room temperature.

This project uses the LM35 temperature sensor to measure ambient temperature. When the temperature crosses a predefined threshold (for example 30°C), the Arduino automatically turns ON the fan or increases its speed using PWM (Pulse Width Modulation).

This project is ideal for:

  • Smart home automation

  • Energy-saving systems

  • School exhibitions

  • Beginner IoT learning

How the LM35 Sensor Works

The LM35 temperature sensor outputs a voltage that is directly proportional to temperature.

  • Output: 10 mV per °C

  • Example:

    • 25°C → 250 mV (0.25V)

    • 30°C → 300 mV (0.30V)

The Arduino reads this voltage using its Analog-to-Digital Converter (ADC) and converts it into temperature.

Components Required

  • Arduino UNO

  • LM35 Temperature Sensor

  • DC Fan

  • NPN Transistor (e.g., BC547 / 2N2222)

  • Diode (e.g., 1N4007)

  • 10kΩ Resistor

  • External Power Supply (for fan)

  • Breadboard & Jumper wires

The transistor is required because the Arduino cannot supply enough current to drive the fan directly.

 Step-by-Step Circuit Connections

Step 1: Connect LM35

  • VCC → 5V

  • GND → GND

  • OUT → A0

Step 2: Connect Transistor & Fan

  • Transistor Base → Arduino Pin 9 (via 10kΩ resistor)

  • Transistor Collector → Negative terminal of fan

  • Transistor Emitter → GND

  • Fan Positive → External 5V/9V supply

Step 3: Connect Diode

  • Place diode across fan terminals

  • Cathode → Positive side

  • Anode → Negative side

(Diode protects against back EMF)

Arduino Code (ON/OFF Control)

int sensorPin = A0;
int fanPin = 9;

float temperature;

void setup() {
pinMode(fanPin, OUTPUT);
Serial.begin(9600);
}

void loop() {

int sensorValue = analogRead(sensorPin);
float voltage = sensorValue * (5.0 / 1023.0);
temperature = voltage * 100; // LM35 conversion
Serial.println(temperature);

if(temperature > 30) {
digitalWrite(fanPin, HIGH);
}
else {
digitalWrite(fanPin, LOW);
}

delay(1000);
}

 Arduino Code (PWM Speed Control Version)

int sensorPin = A0;
int fanPin = 9;

void setup() {
pinMode(fanPin, OUTPUT);
}

void loop() {

int sensorValue = analogRead(sensorPin);
float voltage = sensorValue * (5.0 / 1023.0);
float temperature = voltage * 100;

int speed = map(temperature, 20, 50, 0, 255);
speed = constrain(speed, 0, 255);

analogWrite(fanPin, speed);

delay(1000);
}

Working Principle

  1. LM35 senses temperature.

  2. Arduino converts analog voltage into temperature.

  3. If temperature > 30°C:

    • Fan turns ON.

  4. In PWM mode:

    • Higher temperature → Higher fan speed.

  5. Transistor acts as a switch/driver.

Learning Outcomes

Students will understand:

  • Analog sensor interfacing

  • ADC conversion

  • Transistor switching

  • PWM speed control

  • Smart automation logic

Applications

  • Smart cooling systems

  • CPU cooling automation

  • Industrial temperature control

  • Energy-efficient ventilation

  • IoT climate monitoring

 Troubleshooting Tips

  • Ensure common GND between Arduino and external power supply.

  • If fan doesn’t spin, check transistor wiring.

  • Use proper external power for high-current fans.

Code:



Try this in tinker cad:

Temperature controlled fan

BEGINNER PROJECTS (Foundation Skills)

  1. Ultrasonic Distance Measurement
  2. Traffic Light Simulation with 7-Segment Display
  3. 7-Segment Display Counter
  4. Kids Piano Circuit (8-Key Version)
  5. 16×2 LCD Display with Text Output
  6. LCD I2C to Arduino UNO
  7. Temperature Measurement using Arduino UNO
  8. LDR Controlled Street Light

INTERMEDIATE PROJECTS (Build Your Skills)

  1. Servo Motor Control Using Potentiometer
  2. DC Motor Speed Control
  3. Temperature Controlled Fan
  4. PIR Based Theft Alert System
  5. LPG Gas Leakage Detection System
  6. Automatic Door Locking System
  7. Soil Moisture Based Automatic Watering System
  8. Simple Digital Clock using Arduino UNO
  9. Automatic Voting Machine (EVM)
  10. Joystick Control using Arduino Uno
  11. RGB Lamp Control using Arduino Uno

    ADVANCED PROJECTS (Master Level)

    1. Home Automation Using Arduino UNO
    2. Bluetooth RC Car using Arduino Uno
    3. Obstacle Avoiding Robot
    4. Line Follower Robot
    5. Radar System Using Arduino UNO
    6. Automatic Parking System
    7. Bi-Directional People Counter using Arduino Uno 
    8. Automatic Plant Watering System
    9. NeoPixel LED Ring Control using Arduino Uno
    10. Smart Gloves for Bedridden People

      ROBOTICS & MOTION PROJECTS

      1. RC Car Using L293D Motor Driver
      2. Robot Arm and Leg Control Using Servo
      3. Smart Irrigation System using Arduino Uno

      Comments