Temperature regulation with Arduino

The project is very compact and uses a few components only. It can be implemented for several applications including air-conditioners, water-heaters, snow-melters, ovens, heat-exchangers, mixers, furnaces, incubators, thermal baths and veterinary operating tables. The project will help save energy/electricity.

Circuit diagram of the temperature-based fan speed control and monitoring using Arduino.jpg
Circuit diagram of the temperature-based fan speed control and monitoring using Arduino

This standalone automatic fan speed controller that controls the speed of an electric fan according to the requirement. Use of embedded technology makes this closed-loop fEedback-control system efficient and reliable. The microcontroller (MCU) ATMega8/168/328 allows dynamic and faster control and the LCD makes the system user-friendly. Sensed temperature and fan speed levels are simultaneously displayed on the LCD panel.

Software for the automatic temperature controller and monitor circuit is written in Arduino programming language. Connect Arduino board to the PC and select the correct COM port in Arduino IDE. Compile the program (sketch). Then select the correct board from Tools Board menu in Arduino IDE and upload the sketch (auto-fan.ino) to Arduino through standard USB port. Copy Below code.

Code: Select all

#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
int tempPin = A1;   // 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%
int fanSpeed;
int fanLCD;

void setup() {
  pinMode(fan, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(tempPin, INPUT);

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); 
       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);
       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

int readTemp() {  // get the temperature and convert it to celsius
  temp = analogRead(tempPin);
  return temp * 0.48828125;

LM35 is a precision integrated circuit whose output voltage is linearly proportional to Celsius (Centigrade) temperature. It is rated to operate over a -55°C to 150°C temperature range. It has (+10.0mV/Celsius) linear-scale factor. Temperature sensor LM35 senses the temperature and converts it into an electrical (analogue) signal, which is applied to the MCU through an analogue-to-digital converter (ADC). The analogue signal is converted into digital format by the ADC. Sensed values of the temperature and speed of the fan are displayed on the LCD. Temperature and monitoring using Arduino The MCU on Arduino drives the motor driver to control fan speed.

Fan speed control technique. A low-frequency pulse-width modulation (PWM) signal, usually in the range of about 30Hz, whose duty cycle is varied to adjust the fan’s speed is used. An inexpensive, single, small pass transistor can be used here. It is efficient because the pass transistor is used as a switch.

Leave a comment

Your email address will not be published. Required fields are marked *