Introduction: Temperature Controlled Fan
I have chosen to make a Temperature Controlled Fan for my final project this semester. I have decided to do this project on this because I thought it would be interesting and fun to figure out. After hours of troubleshooting this circuit I finally finished it which was really rewarding seeing it working.
My Temperature Controlled Fan circuit has a Liquid Crystal Display
connected to the Arduino to display the temperature in Celsius and fan speed (50-255 PWM) this controls the duty cycle of the fan which then controls the fan speed. The temperature sensor output is read by the Arduino and the software establishes the desired fan speed for a given temperature reading.
This is done at the PWM output pin 6 which varies the square wave duty cycle thereby increasing or decreasing the effective power to the fan thus changing the fan speed. This type of circuit is commonly used in HVAC systems to vary fan speeds as temperature changes as when there is a reduction of heating or cooling requirements during overnight hours. The fan is a 12V DC Brushless Motor. Another important component is the NPN Transistor in the circuit. The transistor will not allow the fan to turn on without enough current going into the base of the transistor from the PWM pin 6 of the Arduino in series with a 1KΩ Resistor to saturate the transistor which then allows the DC fan to energize.
Step 1: Parts You Will Need
The parts I used to do this
· Genuino UNO
· Temperature Sensor – key part
· 1KΩ Resistor
· 100µF/16V Capacitor
· PN2222A NPN Transistor – Key part to turn on the fan
· 12V DC Brushless Fan – key part
· 1N4007 Diode
· AC – DC Plug in Adapter 120VAC to 12VDC
· Liquid Crystal Display
· Extra Breadboard
Step 2: Schematic
Step 3: Source Code // Commented
#include // library for LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); float temp; // set temp as a whole number int tempPin = A0; //arduino pin used for temperature sensor int tempMin = 23; // the temperature to start the buzzer int tempMax = 26; // temperature full speed int fan = 6; // the pin where fan is connected int fanSpeed = 0; // fan speed variable
void setup() { pinMode(fan, OUTPUT); // declaring fan pin 6 as output pinMode(tempPin, INPUT); // declaring tempPin A0 as input lcd.begin(16, 2); // LCD intialize lcd.clear(); // clears lcd lcd.print("Fan Speed:"); // prints "Fan Speed" 50-255 PWM lcd.setCursor(0,1); // Sets cursor for next line lcd.print("Temperature:"); // Prints "Temperature" below "Fan Speed" Serial.begin(9600); // begins the serial monitor }
void loop() { temp = analogRead(tempPin); float voltage = (temp/1024)*5.0; float temperature = (voltage - 0.5) * 100; // formula for degrees celcius Serial.println(temperature); // prints temp in serial monitor lcd.setCursor(12,1); // 12 character to the right on the first column lcd.print(temperature); // prints the number on the 12 character delay(1000); // delay in between reads for stability if(temp < tempMin) { // if temp is lower than minimum temp fanSpeed = 0; // fan is not spinning digitalWrite(fan, LOW); // pin 6 output is low } if((temperature >= tempMin) && (temperature <= tempMax)) //if temperature is higher than the minimmum range { fanSpeed = map(temperature, tempMin, tempMax, 50, 255); // the actual speed of fan analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed Serial.println(fanSpeed); // prints fan speed in serial monitor lcd.setCursor(12,0); // sets cursor lcd.print(fanSpeed); // prints lcd.print(" "); // fixes an error of random number display } }
Step 4: Conclusion
This project was a really enjoyable experience for me to learn. I am glad to share it online to everyone due to having lots of trouble finding a good website on how this circuit works.