Arduino based temperature controlled fan

Most of the power electronics system use big heatsink to dissipate excessive heat. Some of these uses active cooling method, by using a fan on heatsink which help to remain the temperatures more stable. But when running these things on a low power fan is still on and feel noisy. So why not to make a programmable fan which can be turned on when required. Using Arduino and temperature sensor we can make a temperature-controlled fan. More applications of this type of fan can be found in UPS, Inverters, Amplifiers and Bench power supplies.

ice_screenshot_20220726-130952.png

To make a better demonstration of the project we will design a PCB which based on 12c connections. I am using JLCPCB PCB prototype service for a long time. They are providing best service in just $2 for 5 pcs of multilayer PCB.

Basic Idea:

mini_20220730_152735.jpg

A temperature sensor (lm35) can be attached directly to the heatsink of the system which reads the temperature. Arduino made some calculations and control the speed of fan using PWM output signal. A transistor can be used as a switch to turn ON/OFF the fan. To make the project more demonstration cooler a screen can also be added which is used to display the temperature and fan speed respectively.

Temperature sensor (Lm35):

The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling.

lm35-pinout.jpg

As the LM35 device draws only 60 μA from the supply, it has very low self-heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C to 150°C temperature range

More Features:

Calibrated Directly in Celsius (Centigrade)

Linear + 10-mV/°C Scale Factor

0.5°C Ensured Accuracy (at 25°C)

Operates From 4 V to 30 V

How to read temperature:

Lm35 has a linear 10mv constant per degree, When ever the output of sensor is increased by 10mv the temperature rises 1 degree Celsius. So we can design a code to read the temperature using this method.

ice_screenshot_20220731-112719.png

First of all using Arduino ADC we can read the value of output voltage.

float voltage = reading * (5.0 / 1024.0);

Then we can turn the output voltage into respective temperature readings.

float temperatureC = voltage * 100;

Made all the connections according to the given schematics. To check the temperature constant and voltage output, heat and cold test can be performed. After making the connections with Arduino, upload the code given below. Then open the serial monitor and start performing some test by heating/ cooling.

// Define the analog pin, the LM35's Vout pin is connected to
#define sensorPin A0

void setup() {
  // Begin serial communication at 9600 baud rate
  Serial.begin(9600);
}

void loop() {
  // Get the voltage reading from the LM35
  int reading = analogRead(sensorPin);

  // Convert that reading into voltage
  float voltage = reading * (5.0 / 1024.0);
  Serial.print("voltage:");
Serial.println(voltage);
  Serial.print("ADC VALUE:");
Serial.println(reading);

  // Convert the voltage into the temperature in Celsius
  float temperatureC = voltage * 100;

  // Print the temperature in Celsius
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.print("\xC2\xB0"); // shows degree symbol
  Serial.println("C");
 Serial.println("       ");
  delay(1000); // wait a second between readings
}

These are some observations I got, at room temperature:

ice_screenshot_20220730-152645.png

On heating:

ice_screenshot_20220730-153142.png

On cooling:

ice_screenshot_20220730-152916.png

Using the same idea of reading temperature, we can program Arduino to generate a PWM signal. Which then trigger the switching transistor and hence control the fan and fan speed.

Components required:

20220730_151059.jpg
  • · LM35 Temperature sensor
  • · Arduino Nano/ Uno
  • · CPU fan
  • · 9V battery
  • · LCD screen 16×2 with I2C
  • · 2N2222 switching transistor
  • · 1k resistor and 47uf capacitor
  • · Connecting wires
  • · Custom PCB from JLCPCB

Circuit diagram:

You can find 2 circuit diagrams here, because most of the students don’t want to use 12c protocol with this. So in the first circuit you can find direct connection of screen with Arduino. The program can be downloaded from here.

ice_screenshot_20220730-141136.png

The second one is the modified schematics, which use 4 wire 12C protocol to display values on the screen. This will reduce the overall connection and a better method to make a communication between microcontroller and screen.

ice_screenshot_20220730-182216.png

Here in the circuit, fan speed is controlled using 2n2222 transistor. You can also use dedicated motor controllers but this project is designed according to the consuming current of a CPU fan. From the D11 pin of the Arduino a PWM signal through a 1k resistor is given to base of the switching transistor.

PCB designs:

According to the modified circuit I made this schematic and fi you wan to use the same designs then get them from here.

ice_screenshot_20220730-182751.png

JLCPCB is the most reliable PCB manufacturer offering 5 piece of 2layer PCB in just $2. And if you sign-up using this link you will get free coupons of $54. Visit JLCPCB now and check all the best services.

Code:

All the required libraries can be installed from the manage libraries section under tools menu. This code is for 12c project other project details with code can be downloaded form here.

20220730_151108.jpg
// To find the I2C address of your 16x2 screen follow this tutorial: 
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // in most of the screen the address is 0x27

int tempPin = A0; // the output pin of LM35
int fan = 11; // the pin where fan is
int led = 8; // led pin
int temp;
int tempMin = 30; // the temperature to start the fan 0%
int tempMax = 60; // the maximum temperature when fan is at 100%
// change Above values to change the start temperature and max speed of fan
int fanSpeed;
int fanLCD;
 
 
void setup() {
pinMode(fan, OUTPUT);
pinMode(led, OUTPUT);
pinMode(tempPin, INPUT);
 lcd.init();                      // initialize the lcd 
  lcd.init();                    // Print a message to the LCD.
  lcd.backlight();
Serial.begin(9600);
}
 
void loop()
{
temp = readTemp(); // get the temperature
Serial.print( temp );
if(temp < tempMin) // if temp is lower than minimum temp
{
fanSpeed = 0; // fan is not spinning
analogWrite(fan, fanSpeed);
fanLCD=0;
digitalWrite(fan, LOW);
}
if((temp >= tempMin) && (temp <= tempMax)) // if temperature is higher than minimum temp
{
fanSpeed = temp;//map(temp, tempMin, tempMax, 0, 100); // the actual speed of fan//map(temp, tempMin, tempMax, 32, 255);
fanSpeed=1.5*fanSpeed;
fanLCD = map(temp, tempMin, tempMax, 0, 100); // speed of fan to display on LCD100
analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
}
 
if(temp > tempMax) // if temp is higher than tempMax
{
digitalWrite(led, HIGH); // turn on led
}
else // else turn of led
{
digitalWrite(led, LOW);
}
 
lcd.print("TEMP: ");
lcd.print(temp); // display the temperature
lcd.print("C ");
lcd.setCursor(0,1); // move cursor to next line
lcd.print("FANS: ");
lcd.print(fanLCD); // display the fan speed
lcd.print("%");
delay(200);
lcd.clear();
}
 
int readTemp() { // get the temperature and convert it to celsius
temp = analogRead(tempPin);
return temp * 0.48828125;
}

Working:

My Video.gif

The temperature controller is working quite fine. As I make the contact of lm35 with heated solder Iron the fan speed is increased to 90% and temperature can be seen respectively to it. Don’t forget to claim coupons of $54 from JLCPCB.

Similar Posts

Leave a Reply

Your email address will not be published.