[go: up one dir, main page]

0% found this document useful (0 votes)
3 views7 pages

Temperarure Based Fan Speed Control Using Arduino

Uploaded by

adrijazen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Temperarure Based Fan Speed Control Using Arduino

Uploaded by

adrijazen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

TEMPERARURE BASED FAN SPEED CONTROL USING ARDUINO

Components Needed:
1. Arduino Board (e.g., Arduino Uno)
2. Temperature Sensor (e.g., DHT11 or DHT22)
3. DC Fan or Servo Motor (with PWM control for variable speed)
4. Transistor (e.g., TIP120) to control the fan (if the fan uses high current)
5. Diode (e.g., 1N4007) to protect from back EMF if you're using a DC fan
6. Resistor (for base current limiting)
7. Power supply for the fan (if different from Arduino's supply)
8. Breadboard and jumper wires
Wiring Diagram:
• DHT11/DHT22 Sensor: Connect the data pin to an available digital pin (e.g., Pin 2),
VCC to 5V, and GND to ground.
• Fan (DC Motor): Connect the fan to the motor driver (e.g., TIP120 transistor). The
motor's power should be supplied by an external source. Connect the control pin of the
transistor to a PWM-enabled pin on Arduino (e.g., Pin 9).
• Power Supply: Ensure that both the Arduino and the fan have proper power
connections
Basic Operation:
1. Temperature Measurement: The Arduino reads the temperature from the sensor.
2. Fan Speed Control: Based on the temperature, the Arduino adjusts the fan's speed via
PWM signal, which controls the transistor to drive the fan.
CODE:
 #include <DHT.h>

 // Pin definitions
 #define DHTPIN 2 // Pin where DHT sensor is connected
 #define FAN_PIN 9 // Pin connected to the transistor controlling the fan

 // DHT sensor type


 #define DHTTYPE DHT11 // Change to DHT22 if you're using a DHT22 sensor

 DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor

 void setup() {
 Serial.begin(9600); // Start serial communication
 dht.begin(); // Initialize DHT sensor
 pinMode(FAN_PIN, OUTPUT); // Set fan pin as an output
 }
 void loop() {
 // Wait a few seconds between measurements
 delay(2000);

 // Read temperature from the sensor


 float temp = dht.readTemperature();

 // Check if the reading is valid


 if (isnan(temp)) {
 Serial.println("Failed to read from DHT sensor!");
 return;
 }

 // Display the temperature on the serial monitor


 Serial.print("Temperature: ");
 Serial.print(temp);
 Serial.println(" *C");

 // Control fan speed based on temperature


 int fanSpeed = map(temp, 20, 30, 0, 255); // Adjust temperature range if needed
 // Ensure fan speed is between 0 and 255
 fanSpeed = constrain(fanSpeed, 0, 255);

 // Set fan speed (PWM)


 analogWrite(FAN_PIN, fanSpeed);

 // Wait before next reading


 delay(500);
 }

 // Control fan speed based on temperature


 int fanSpeed = map(temp, 20, 30, 0, 255); // Adjust temperature range if needed

 // Ensure fan speed is between 0 and 255


 fanSpeed = constrain(fanSpeed, 0, 255);

 // Set fan speed (PWM)


 analogWrite(FAN_PIN, fanSpeed);

 // Wait before next reading


 delay(500);
 }

You might also like