Create Temperature controlled fan system

Creating a temperature-controlled fan system is a great way to learn about thermistors, transistors, relays, and basic microcontroller operations. Here’s a step-by-step guide on how to make a temperature-controlled fan using a thermistor, transistor, relay, and a fan.

Components You Will Need

1. Thermistor (NTC or PTC type): A thermistor is a type of resistor whose resistance varies significantly with temperature.

NTC Thermistor: Resistance decreases as the temperature increases.

PTC Thermistor: Resistance increases as the temperature increases (use NTC for this project).



2. Transistor (NPN type, e.g., 2N2222): A transistor will act as a switch to control the relay.


3. Relay: A relay is an electrically-operated switch used to control the fan (usually a higher-voltage AC fan). It can switch larger currents using the lower-current signals from the transistor.


4. Fan (DC or AC): The fan will be controlled by the relay, and will turn on or off depending on the temperature.


5. Microcontroller (Arduino, ESP32, etc.): The microcontroller reads the thermistor’s value and controls the transistor and relay.


6. Power Supply (5V-12V): Depending on the fan and relay type, you will need an appropriate power source.


7. Resistor (10kΩ): A resistor to create a voltage divider with the thermistor to read its value accurately.


8. Diode (Optional, for DC relay): A diode across the relay coil to prevent voltage spikes from damaging the transistor (flyback diode).


9. Wires, Breadboard, and Soldering tools: For prototyping and assembling the components.




---

Step-by-Step Guide

Step 1: Understanding the Components

1. Thermistor:

The thermistor's resistance changes with temperature. When it is colder, the resistance is high; when it is hotter, the resistance is low.

By using a voltage divider circuit, you can convert this change in resistance to a readable voltage for the microcontroller.



2. Transistor:

The transistor will act as a switch. It will allow the microcontroller to control a larger current needed to trigger the relay.



3. Relay:

The relay allows the microcontroller to control the high-voltage fan using the low-voltage signals from the microcontroller and transistor.



4. Fan:

The fan will be powered by a higher voltage and will be turned on or off based on the signal from the relay.




Step 2: Wiring the Circuit

1. Thermistor Voltage Divider:

Connect one leg of the thermistor to 5V (or the appropriate voltage depending on your thermistor type).

Connect the other leg of the thermistor to a 10kΩ resistor and to GND.

The junction between the thermistor and resistor will be connected to the analog input pin of your microcontroller (e.g., A0 on Arduino).



2. Transistor Circuit:

Connect the collector of the NPN transistor to the relay’s control pin (one of the two pins of the relay coil).

Connect the emitter of the transistor to GND.

The base of the transistor will be connected to a digital output pin of the microcontroller (e.g., pin 8 on Arduino) through a 1kΩ resistor to limit current.



3. Relay and Fan:

Connect the NO (Normally Open) terminal of the relay to one of the terminals of the fan.

Connect the other terminal of the fan to 5V (or the appropriate voltage for your fan).

The COM (Common) terminal of the relay should be connected to GND (for DC) or AC live wire (for AC fan).

If you’re using a DC relay, also connect a flyback diode across the relay coil to protect the transistor from voltage spikes.



4. Power Supply:

The microcontroller and transistor need 5V from a power supply, while the fan may need a higher voltage (usually 12V or AC).




Step 3: Programming the Microcontroller (e.g., Arduino)

1. Reading the Thermistor Value:

Use the analogRead() function in Arduino to read the value from the thermistor voltage divider.

Convert this raw value to a temperature value using a calibration equation or thermistor lookup table (based on the thermistor type and specifications).



2. Threshold Temperature:

Set a temperature threshold. If the temperature exceeds this threshold, turn on the fan; if it’s below, turn off the fan.



3. Control the Transistor and Relay:

If the temperature is above the threshold, use the digitalWrite() function to set the transistor’s base pin HIGH (activating the transistor and turning on the relay).

If the temperature is below the threshold, use digitalWrite() to set the transistor’s base pin LOW (deactivating the transistor and turning off the relay).




Sample Arduino Code

const int thermistorPin = A0;  // Thermistor connected to analog pin A0
const int transistorPin = 8;    // Transistor base connected to digital pin 8
const int thresholdTemp = 30;   // Temperature threshold (in Celsius)

void setup() {
  pinMode(transistorPin, OUTPUT);   // Set transistor pin as output
  Serial.begin(9600);               // Initialize serial monitor
}

void loop() {
  int thermistorValue = analogRead(thermistorPin);   // Read thermistor value
  float voltage = thermistorValue * (5.0 / 1023.0);  // Convert value to voltage
  
  // Assuming a simple thermistor lookup (for demonstration):
  // A more accurate method involves using a specific formula for the thermistor
  float temperature = (voltage - 0.5) * 100;  // Example calculation for temperature in Celsius
  
  Serial.print("Temperature: ");
  Serial.println(temperature);
  
  if (temperature > thresholdTemp) {
    digitalWrite(transistorPin, HIGH);  // Turn on transistor and relay (fan ON)
  } else {
    digitalWrite(transistorPin, LOW);   // Turn off transistor and relay (fan OFF)
  }

  delay(1000);  // Wait for a second before reading again
}

Step 4: Testing the System

1. Connect the System:

Power up the system.

Use the Serial Monitor in Arduino to observe the temperature readings.



2. Adjust the Threshold:

Change the thresholdTemp variable in the code to the desired temperature at which the fan should turn on/off.



3. Observe Fan Behavior:

When the temperature exceeds the threshold, the transistor will turn on the relay, activating the fan.

When the temperature drops below the threshold, the fan will turn off.




Step 5: Final Assembly

1. Assemble the Circuit:

Once the system is working on the breadboard, you can transfer it to a permanent soldered circuit board.



2. Enclosure:

Place the components (thermistor, transistor, relay, and microcontroller) into an enclosure for protection and better aesthetics.



3. Power Supply:

Ensure that your power supply is capable of handling both the microcontroller and the fan. For the Arduino, you can use a 5V USB power supply or a 12V adapter if using a higher voltage relay and fan.




Applications of the Temperature-Controlled Fan

Energy-Efficient Cooling: Automatically turning on the fan only when needed can help save energy and maintain a comfortable temperature.

Automated Climate Control: Useful for environments where maintaining a certain temperature is crucial, like computer servers, electronics, and small greenhouses.

Home Automation: Can be integrated into a larger home automation system to control temperature-dependent devices.



---

Final Notes

If you're using an AC fan, be very careful with the relay wiring and ensure it’s rated for the AC voltage (typically 120V or 230V).

Calibration: To get an accurate reading, you may need to calibrate the thermistor. A simple way is by measuring its resistance at known temperatures and calculating the corresponding temperature.

Enhancements: You can add an LCD or OLED screen to display the current temperature or control the threshold temperature via a button or rotary encoder.


By following these steps, you can create your own temperature-controlled fan, which provides automatic cooling based on ambient temperature.

Comments

Popular posts from this blog

scientific principles used in mobile phones

The syllabus for Elective III

Renewable Energy Systems course: