How to Make Automatic Remote Controlled AC Fan

Home automation is a step toward what is referred to as the “Internet of Things,” it is fun to build and easy if you have the right tools. Specifically, this home automation project is centered on automatic remote controlled AC Fan. That is, how to make an automatic temperature regulated and Infrared (IR) regulated remote controlled AC fan smart fan.

This remotely controlled fan facilitates the operation of fan regulators around the home or office from a distance. It provides a system that is simple to understand and also to operate, a system that will be reliable, easy to maintain, and durable irrespective of its usage. It adds more comfort to everyday living by removing the inconvenience of having to move around to operate a fan regulator. This automatic and IR-regulated smart fan is designed with an in-built temperature sensor module that measures the room temperature of the room at every time. It then regulates the fan speed controls based on this temperature.

automatic remote controlled AC Fan
automatic remote controlled AC Fan

Infrared radiation that produces Infrared signals or radiation (IR) are actually beams of light, it is that portion of the electromagnetic spectrum that extends from the long wavelength, or red, end of the visible-light range to the microwave range. Invisible to the eye, it can be detected as a sensation of warmth on the skin. Most of the radiation emitted by a moderately heated surface is infrared; it forms a continuous spectrum. Molecular excitation also produces copious infrared radiation, but in a discrete spectrum of lines or bands. Everything that produces heat, emits infrared like our human body. Infrared has the same properties as visible light, like it can be focused, reflected, and polarized like visible light. IR devices are those photonic components that contain semiconductor materials that are sensitive to IR radiation. They are divided into IR Transmitters (LED) and IR Receivers (IR).

Understanding the Project

But first, a brief explanation on the basics of home automation and why this project design. This project aims to automate an AC fan by controlling its speed based on the room temperature. The fan will run at different speeds depending on the temperature detected by the sensor:

  • High Speed: When the temperature is high.
  • Medium Speed: When the temperature is moderate.
  • Low Speed: When the temperature is low.
  • Off: When the temperature is below a certain threshold.

The fan also can be controlled by the user using a remote control. The infrared transmitter device is decoded by the IR receiver onboard the designed mounted on the Automatic Remote Controlled AC Fan project design.

How to Make An Automatic Remote Controlled AC Fan: Materials for the Project Design

  • Power Supply rated 5V, ≥ 2A or you can build your own here
  • Atmeg328p-pu microcontroller
  • 16MHz crystal oscillator (Newark part number 16C8140)
  • 10nF capacitors
  • A 10KΩ pull-up resistor
  • A reset push button.
  • Dallas temperature sensor DS18B20, maxim part number, 1534C4:
  • A 4.7KΩ pull-up resistor
  • Infrared receiver TSOP1738
  • IR remote controller or any old TV remote( that’s IR Transmitter)
  • 560Ω 5 band resistor
  • 1µF ceramic capacitor
  • Generic Jumper wires: male and female type.
  • 16 × 2 Liquid Crystal Display
  • 10KΩ potentiometer (trimmer)
  • 56OΩ precision resistor
  • LCD connector wires’
  • Header pins
  • 5V 4-channel Relay Module
  • A standing fan

Buy the complete kit for this project design by contacting us here.

How to Make An Automatic Remote Controlled AC Fan: The Circuit Diagram

how to make an automatic remote controlled AC Fan
The complete circuit diagram

The Circuit Diagram Explanation

The algorithms programmed into the microcontroller (MCU) chip have two objectives: first; if, say, the room temperature is too hot, it would switch to a speed that would make the room cold and cozy and if it is too cold, it would switch to a speed level that is comfortable or turn off totally. Mostly, if the user feels that he or she doesn’t like the speed of the fan, he or she can pick up a remote control and select the desired speed of choice; giving it a user-enabled option.

When the part units are assembled together, the above circuit diagram was achieved. To keep the design working properly and achieve the desired goal, the MCU had to run a series of programs. Let’s break the circuit into units and explain each unit.

Connecting the Temperature Sensor

DS18B20 circuit diagram connection
DS18B20 circuit diagram connection

The temperature sensor DS18B20 is connected as shown in the circuit diagram above. You can choose to connect your data pin of the temperature sensor to any of your microcontroller pin of your choice, whether analog or digital pin. Just be sure to define it in your source code. It is also very important to add the 4.7kΩ pullup resistor. If this connection is omitted, the temperature sensor wouldn’t work and the displayed readings would be confusing like -127°C on the serial monitor window or LCD.

Connecting the Relay Module Unit

how to make an automatic remote controlled AC Fan
the relay module

The relay module unit is an arrangement of a electromagnetic switches and other discrete linear components that can sense very minimum current input and allow a high voltage to flow across its switch. The module as shown above is designed with an optocoupler which is made up of  LED and phototransistors; signal diodes for relay protection, general purpose NPN transistor and low value resistor.

The relay module has four relays that works on the following operation: if we consider the first relay, having switch K1, the anode of the  LED in the optocoupler is connected to the +5v Vcc through a resistor R1. Also the Collector of the transistor Q1 is given a +5v having a common emitter connection to baise the coil of the relay. Current would flow through the anode of the LED and it would glow (although this was not seen since it was encased) thereby biasing base of the transistor which would then conduct, allowing current to flow through the Vcc at the collector and since the base of Q1 is already open through R2 to the -5v(ground). This would in turn energize the coils of the K1 and the pole would change from terminal 3((Normally closed, NC) to terminal 1 (Normally Open, NO) of the Relay. The other relays K2, K3 and K4 works on the same operation.

IR Receiver Unit

This unit as earlier mentioned is composed of the infrared receiver TSOP1738 that has three terminals with the Pin 3 connected to the HIGH of the PSU (+5 Vcc) supply and the Pin 2 connected to the ground terminal(or LOW) of the PSU while the Pin 1 is the output pin. It is called the data pin (or terminal) Do. To stop  the sensor (TSOP1738) from sending fluctuation signals to the MCU due to IR impulse from random sources, a very low capacitive capacitor isconnected from the data pin to the ground. This is shown below.

how to make an automatic remote controlled AC Fan
the IR module

A Brief Explanation Of Hex Codes

The Decimal number system is also known as Base Ten, since it’s comprised of ten numerals (symbolized by 0 through 9). Although we can only represent up to the number 9 by a single decimal digit, it’s possible to reference up to ten items by using zero ( 0) as an index to refer to the first ( 1st) item; thus, the numeral 9 would refer to the tenth ( 10th) item. With two digits we can refer to 100 items (zero through 99). In terms of the number of digits, 10 n (where n is the number of digits) equals the maximum number of items we can refer to. Therefore, the decimal equivalent of the largest binary number we can represent in 6 bits ( 111111 ) can be found as the sum of the first six powers of 2; starting with 2 to the power of zero (2 ^0): 20 + 21 + 2 2 + 23 + 24 + 25 = 1 + 2 + 4 + 8 + 16 + 32 = 63.

Or, by simply using the formula: 2n – 1 = 64 – 1 = 63.

To convert any binary number to hexadecimal, that is, base 16, simply order the bits into as many four-bit groups as possible, from the least significant position to the most significant position with any remaining group of only 3, 2 or 1 bits at the far left. Then convert each group to a single hex digit of 0 through 9 or A through F . So, to convert our 6-bit number of 111111 (63 decimal) to hex, we simply group the bits as: 111111 which is easily converted to: 3F hex. An 8-bit or 1-byte hexadecimal number can contain a maximum value of 255 decimal. A 10-bit binary number cannot exceed: 11 11111111 or 3FF  or 1023 decimal. But, the maximum number of Cylinders we can reference in 10 bits is 1024, since we begin counting from zero.

A 32-bit unsigned integer value can be from 0 to 2(32-1). That is, from 0 to 2147483647.  Similarly, 64-bit unsigned integer value can be from 0 to 2(64-1). Now, 32-bit hex value can be from 0 to 0x7f f f f f f f There will be only 8 digits i.e. 7 f f f f f f f because 1 digit corresponds to 4 bit. Hence 8 digits correspond to 8×4 = 32 bits. So, this means the digits which are followed by 0x are hexadecimal. There are two important aspects to the beauty of using Hexadecimal with computers: First, it can represent 16-bit words in only four Hex digits, or 8-bit bytes in just two.

How to Make an Automatic Remote Controlled AC Fan: The LCD UNIT

how to make an automatic remote controlled AC Fan

The liquid crystal display is a display module programmable, economical and can display special characters. A 16×2 LCD means it can display  16 characters per line and there are two of such lines. Each character is displayed in 5×7 pixel matrix. The LCD has two registers namely; Command and Data. The pins and their functions are explained as:

  • Register Select (RS): this pin selects Command register when low and Data register when high.
  • Read/Write (R/W): this pin writes to the register when low and reads from the register when high.
  • Enable (E): this pin sends data to the Data pins when a high to low pulse is given to it.
  • Pin 7 to 14 (D4 to D): these are 8-bit pins that are used to send and and receive data to/from the LCD.
  • Pin 15 ( ): this is the positive (+Vcc) backlight of the LED (LED+) of the LCD. This pin is usually connected with a pullup resistor ( ≤ 1kΩ). this is important to limit current flowing in the LEDs of the LCD.
  • Pin 16 (D16): this is the  negative (ground ) −−Vcc  pin. It is connected to the groud of the DC power supply.
  • The circuit connections is summarised as:
    •  * LCD RS pin to pin 18 (D12)
    •  * LCD Enable pin to pin 17 (D11)
    •  * LCD D4 pin to pin 12 (D5)
    •  * LCD D5 pin to pin 6 (D4)
    •  * LCD D6 pin to pin 5 (D3)
    •  * LCD D7 pin to pin 4 (D2)
    •  * LCD R/W pin to ground (-5V VDD)
    •  * LCD VSS pin to ground (-5V VDD)
    •  * LCD VCC pin to +5V (Vcc)
    •  * 10K resistor:
    •  * ends to +5V and ground
    •  * wiper to LCD VO pin (pin 3)

The Source-Code

#include <LiquidCrystal.h>
//state which pins of the MCU connected 4 LCD
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <OneWire.h>
#include <DallasTemperature.h>
#include <IRremote.h>
//state where the input of the temp sensor is connected
#define ONE_WIRE_BUS A0
int led1 = 6;
int led2 = 7;
int led3 = 8;
//set the OneWire lib to comm with other bus
OneWire oneWire(ONE_WIRE_BUS);
//transfer the data to Dallas temp Lib
DallasTemperature sensors(&oneWire);
//state the IR input to the MCU
#define RECV_PIN A1
//make it recognised to IR Lib
IRrecv irrecv(RECV_PIN);
//ask it it get results and save it
decode_results results;
void setup() {
   //begin the LCD to start displaying
  lcd.begin(20,4);
   //enable the IR
  irrecv.enableIRIn();
  //begin the temp sensor
  sensors.begin();
  //outline the inputs and output pins
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
//Serial.begin(9600);
//Display a welcome note
lcd.setCursor(0, 0);
lcd.print("Welcome Chinny!");
lcd.setCursor(0, 1);
lcd.print("Smart FAN Project");
delay(3000);
lcd.setCursor(0, 1);
lcd.print("Please Wait.......");
delay(2000);
lcd.setCursor(0, 1);
lcd.print("Smart FAN Ready");
delay(1000);
}
void SPEED1()
{
       digitalWrite(led1, HIGH);
       digitalWrite(led2,LOW);
       digitalWrite(led3, LOW);
       lcd.setCursor(0, 1);
       lcd.print("FAN AT SPEED 1 ");
      //Serial.println("FAN AT SPEED 1");
 }
void SPEED2()
{
      digitalWrite(led1, LOW);
      digitalWrite(led2,HIGH);
      digitalWrite(led3, LOW);
      lcd.setCursor(0, 1);
      lcd.print("FAN AT SPEED 2 ");
      //Serial.println("FAN AT SPEED 2");
 }
 void SPEED3()
 {
      digitalWrite(led1, LOW);
      digitalWrite(led2,LOW);
      digitalWrite(led3, HIGH);
      lcd.setCursor(0, 1);
      lcd.print("FAN AT SPEED 3 ");
     // Serial.println("FAN AT SPEED 3");
 }
 void fan_off()
 {
      digitalWrite(led1, LOW);
      digitalWrite(led2,LOW);
      digitalWrite(led3, LOW);
      lcd.setCursor(0, 1);
      lcd.print("FAN TURNED OFF! ");
      //Serial.println("FAN TURNED OFF");
 }
void tempSensor() {
  if(irrecv.decode(&results)) 
  {
     irrecv.resume();
    //print the remote results in HEX codes
     //Serial.println(results.value, HEX);
  }
  sensors.requestTemperatures();
  float roomTemp = sensors.getTempCByIndex(0);
  lcd.setCursor(0, 0);
  lcd.print("ROOM TEMP:");
  lcd.setCursor(10, 0);
  lcd.print(roomTemp);
  lcd.setCursor(14, 0);
  lcd.print("'C");
  if( roomTemp < 20.00 )
    {
      fan_off();
    }
   else if(roomTemp >= 20.01 && roomTemp <= 30.00)
    {
      SPEED1();
    }
   else if(roomTemp >= 30.01 && roomTemp <= 35.00)
    {
      SPEED2();
    }
   else
    {
      SPEED3();
    }
}
void remote()
{
     if(results.value == 0x1266897) 
     {
      SPEED1();
     }
     else if(results.value == 0x1269867)
     {
      SPEED2();
     }
     else if(results.value == 0x126E817)
     {
      SPEED3();
     }
     else if(results.value == 0x12618E7)
     {
     fan_off();
     }
     else if(results.value == 0x126926D)
     {
      tempSensor();
     }
}
void loop() {
  sensors.requestTemperatures();
  float roomTemp = sensors.getTempCByIndex(0);
  lcd.setCursor(0, 0);
  lcd.print("ROOM TEMP:");
  lcd.setCursor(10, 0);
  lcd.print(roomTemp);
  lcd.setCursor(14, 0);
  lcd.print("'C");
  // Serial.print("ROOM TEMP: ");
  // Serial.print("  ");
  //Serial.println(roomTemp);
if(irrecv.decode(&results)) 
  {
     irrecv.resume();
    //print the remote results in HEX codes
     //Serial.println(results.value, HEX);
  }
     if(results.value == 0x126926D)
     { 
        while((results.value == 0x126926D) ||((results.value != 0x1266897) && (results.value != 0x1269867) && (results.value != 0x126E817) && (results.value != 0x12618E7) && (results.value != 0x126926D)))
        tempSensor(); 
      }
       remote();
 delay(50);
}

Explanation of Arduino Code

The program for how to make an automatic remote controlled AC Fan project records and stores the IR signals as HEX Values and it used only Hexadecimal to display the actual Binary bytes of a Memory Dump rather than a huge number of ones and zeros! The second aspect is closely related: Whenever it is necessary to convert the Hex representation back into the actual Binary bits, the process is simple enough to be done. For example, FAD7 hex is 1111101011010111 (F=1111, A=1010, D=1101, 7=0111) in Binary.

Once the IR receiver was configured correctly as drawn in the circuit, and  was powered; using an old home TV remote as IR transmitter, specific button’s HEX codes were selected and mapped as commands into the MCU to control the fan speed controls.

For example, for Speed  1, 0x1266897 is used. But by inputting it in the if statement, it makes the MCU to know which remote button controls what speed and which function.

Conclusion

We have successfully designed and constructed the project, how to make an automatic remote controlled AC Fan. And we have been able to use a home TV remote to control an alternating current (AC) standing fan. Do you think you can replicate the same project design? Or better make it smarter than ours? Let us know in the comment section below if you did this project. We will like to see a photograph or video too!

Connect with us on Telegram, Instagram, Facebook page or WhatsApp.

The video below shows the workings of the project design. Watch, like, and subscribe. Thanks you.

FAQs on Automatic Remote Controlled AC Fan

Q1: Can I use a different temperature sensor? A1: Yes, you can use other temperature sensors like the DHT22 or LM35. You’ll need to adjust the code accordingly.

Q2: Is it safe to control an AC fan with Arduino? A2: Yes, as long as you use a relay module to handle the high voltage and follow proper safety precautions.

Q3: Can I add more speeds to the fan control? A3: Yes, you can modify the code to include more speed levels by adding additional relays and corresponding control logic.

Q4: What type of IR remote can I use? A4: You can use any standard IR remote, such as an old TV remote. You’ll need to record the remote’s button codes for programming.

Q5: Can I integrate this project with a smart home system? A5: Yes, with additional components like a WiFi module or Bluetooth, you can integrate the fan control into a broader smart home ecosystem.

Leave a Reply

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