In this project, we are going to build something very simple project, a temperature controlled relay that is used to turn on a dc fan. You can actually change the DC Fan to other electrical devices such as light or servo motor. We are going to make an automatic fan that will be ON when the temperature rises above certain threshold temperature and OFF when it is below.



Just follow the steps below and you are ready to get yourself one Temperature-Controlled Automatic Fan!

Things that you need

Arduino UNO

LM35 Temperature Sensor(Celsius) – datasheet

Relay Module ( May refer to my previous post on how to make a relay module)

A 9V battery (To supply to the coil of relay and the fan)

A DC fan (9V/12V)

Some jumper wires

16 x 2 LCD

Okay, now let’s get started.

Step 1

Connect the hardware according to the schematic below:

LCD & LM 35

Relay Module

DC Fan

Done with the hardware part? Awesome!

Part 2: Software

For the software part, I program it using arduino IDE v1.01.

#include int reading = 0; int sensorPin = A0; int relay =7; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); pinMode(relay,OUTPUT); } void loop() { reading = analogRead(sensorPin); int celsius = reading/2; lcd.setCursor(0, 0); lcd.print("Temperature: "); lcd.setCursor(0,1); lcd.print(celsius, DEC); lcd.print((char)223); lcd.print("C"); if (celsius >35) { digitalWrite(7,HIGH); } else { digitalWrite(7,LOW); } delay(500); lcd.clear(); }

Some brief explanation about the coding:

1. reading = analogRead(sensorPin);

– Read analog pin from LM35 temperature sensor input pin and store at reading.

2. int celsius = reading/2;

– LM35 are design to give the exact value of temperature in Celsius. To get the celsius

value, the ADC value are required to divided by 2 .

So, load this code into your arduino UNO and you are ready to go!

Demo video

Problem Encountered & Solutions

Problem 1

The GND of the 9V battery is not connected to the GND of the arduino. So, this cause the fan unable to move even if the temperature exceed the threshold temperature.

Solution 1

Connect the GND of the battery to the GND of arduino – common GND. If you are using a 5V relay instead of 12V relay, you only have to connect the arduino GND. I am using a 12V relay. So the coil voltage required would be higher.

Problem 2

When done uploading the code into my arduino UNO, the LCD display nothing.

Solution 2

After some troubleshoot work, I realised it is due to the contrast(pin 3 on LCD). You have to adjust the potentiometer connected to pin 3 of LCD until the LCD would display what you want it to display.

Hope this simple guides would lead you to make your own success Temperature-Controlled Automatic Fan too.

If you have any doubt, do leave your comments or contact me.

Hope you enjoy. Happy reading !

Thank you.