Temperature-Activated Smart Fan Using DC Motor
by dmcits in Circuits > Sensors
42 Views, 2 Favorites, 0 Comments
Temperature-Activated Smart Fan Using DC Motor

This project uses an Arduino Uno to monitor temperature via a TMP36 sensor. When the room temperature reaches or exceeds the set threshold, an LED lights up to signal that it’s too hot. At that point, if a button is pressed, a DC fan powers up gradually, then winds down — providing a manual cooling response based on environmental data.
This system simulates a smart cooling control system — useful in homes, server rooms, or greenhouses where automated, responsive environments are crucial.
Supplies
- Arduino Uno
- TMP36 Temperature Sensor
- DC Motor (Fan)
- TIP120 NPN Transistor
- 1N4001 Diode
- LED
- 200Ω Resistor (for LED)
- Pushbutton
- 10kΩ Resistor (for button)
- 9V Battery + Battery Clip or 9V DC Power Supply
- Breadboard + Jumper Wires
Build Circuit

Connect the TMP36 Temperature Sensor
- Insert the TMP36 sensor onto the breadboard with its flat side facing you.
- Left pin → Connect to 5V on the Arduino.
- Middle pin → Connect to A0 on the Arduino (analog input).
- Right pin → Connect to GND.
Wire the Pushbutton
- Place the pushbutton across the central groove of the breadboard.
- Connect one side of the button to digital pin 2 on the Arduino.
- Connect the same side to GND through a 10kΩ pull-down resistor.
- Connect the other side of the button to 5V.
This ensures a stable LOW reading when the button is not pressed.
Connect the Status LED
- Place an LED on the breadboard.
- Anode (long leg) → Connect to pin 13 on the Arduino through a 200Ω resistor.
- Cathode (short leg) → Connect to GND.
Set Up the DC Fan Motor with TIP120 Transistor
- Insert the TIP120 NPN transistor onto the breadboard.
- TIP120 pinout (flat side facing you):
- Left pin = Base
- Middle pin = Collector
- Right pin = Emitter
- Connect one lead of the motor to the 9V battery positive terminal.
- Connect the other motor lead to the collector (middle pin) of the TIP120.
TIP120 Control:
- Connect the emitter (right pin) of the TIP120 to GND.
- Connect the base (left pin) of the TIP120 to digital pin 9 on the Arduino.
Add a Flyback Diode for Motor Protection
- Place the 1N4001 diode across the motor terminals.
- Stripe (cathode) → Connect to the positive motor lead (battery side).
- Non-striped end (anode) → Connect to the TIP120/motor side.
(This protects the transistor from voltage spikes caused by the motor.)
Connect External Power (9V Battery)
- Connect the positive terminal of the 9V battery to the motor (already done in Step 4).
- Connect the negative terminal of the battery to the Arduino GND (shared ground).
Final Check Before Uploading Code
Make sure:
- All GNDs are connected (Arduino, TMP36, TIP120 emitter, button resistor, and LED).
- The TMP36 is not reversed (double-check the flat face and pin layout).
- The TIP120 is controlling the fan — don’t wire the motor directly to the Arduino.
- The 9V battery powers the motor (not the Arduino — unless using a barrel jack).
Downloads
Upload Code + Breakdown
Code:
Section-by-Section Breakdown
Variable Declarations
- buttonPin: The pushbutton is connected to digital pin 2.
- motorPin: The motor (controlled via a TIP120 transistor) uses pin 9, which supports PWM.
- ledPin: The status LED for high temp is connected to pin 13.
- tempPin: The TMP36 sensor is connected to analog pin A0.
Setup Function
- pinMode(): Defines pin roles.
- Button as input.
- Motor and LED as outputs.
- Serial.begin(9600);: Starts serial communication for debugging. You'll see temperature logs in the Serial Monitor.
Main Loop Function
- Reads analog voltage from TMP36. Value is between 0 and 1023.
- Converts the analog value to actual voltage.
- 5.0V is the Arduino reference voltage.
- Converts the TMP36 voltage to Celsius.
- TMP36 outputs 0.5V at 0°C, and every 0.01V = 1°C.
- Converts Celsius to Fahrenheit.
Display Temperature
- Prints the temperature to the Serial Monitor for debugging or monitoring.
Check Temperature Condition
- If it’s 85°F or hotter, the system gets ready to cool.
- Turns on the LED to signal high temperature.
Check Button Press
- If the button is pressed, we start the cooling cycle.
Ramp Up the Fan
- Increases the PWM signal to the fan gradually.
- PWM value from 0 to 50 (out of 255) gives a gentle spin-up.
- Each increase pauses for 50ms to create a smooth ramp effect.
Ramp Down the Fan
- Slows the fan back down smoothly.
Else Condition (Normal Temp)
- If it’s cooler than 85°F, the system:
- Turns off the LED
- Keeps the motor off
Loop Delay
- Adds a half-second pause before the loop repeats.
- Helps smooth sensor readings and reduce noise.