Automatic Switching Between Fan and AC Depending on the Temperature

by Souhbarnika V in Circuits > Arduino

395 Views, 4 Favorites, 0 Comments

Automatic Switching Between Fan and AC Depending on the Temperature

Automation-1592488811781.png

This DIY helps us to switch between Fan and Air-conditioner depending on the temperature.

Components required

  • Arduino UNO - 1
  • DC Motor -2
  • Temperature Sensor [TMP36]

In case if you work with hardware components you need power supply (to drive the Arduino UNO) and Laptop (for dumping program)

If you go with virtual simulation you can use TinkerCAD platform.

Interfacing the Sensor

images.png
Screenshot (286).png

The temperature sensor consists of three terminals namely Vcc (power pin), ground and data pin.

Connect the Vcc and ground terminals of TMP36 to 5 volts and ground pin of Arduino UNO respectively. As the TMP36 is an analog sensor, it records data continuously, so it should be connected to one of the analog pins of Arduino UNO ranging from A0 to A5.

Here I have connected the terminal to pin A1.

Interfacing DC Motors

download.jpg
Screenshot (292).png

Arduino UNO consists of mainly two types of pins

  • Analog
  • Digital

There are some pins in digital that are special purpose pins, such as

  • Transformer Tx (Pin 0)
  • Receiver Rx (Pin 1)
  • PWM pins (Pins 3,5,6,9,10,11)

Due to the fact that we will control the speed of the AC and fan based on room temperature, we will connect the DC motor with Arduino Uno using PWM pins. DC motors are two-terminal devices. You connect one terminal to the ground and the other terminal to an Arduino PWM pin.

Here, I have used pins 3 and 6 to drive DC motors with an Arduino.

Coding

Screenshot (289).png
Screenshot (290).png

Arduino is programmed using embedded C.

Programming includes three blocks of code:

Initializing pins and variables.

Determining whether the pin is input or output (void setup() ).

Actual piece of instruction to be executed( void loop() ).

You can see in the image that I have first initialized all the pins I used to interface DC motors(Pin 3, 6) and a temperature sensor(Pin A1).

In void setup I have determined the Pin A1 (TMP36) as input while the DC motors (Pin 3,6) as output.

In void loop part,

  1. Firstly we read the analog voltage from the pin A1.
  2. We next converted this analog voltage into degrees Celsius.
  3. In this case, we use a conditional statement (if) to check if the temperature is lower than the given value.
  4. The fan will only power on when the temperature sensor data is less than the threshold and the fan speed will depend on the data from the sensor.
  5. The above criteria can be met by using a map function in which the motor speed is automatically controlled based on temperature by altering the voltage level.
  6. As soon as the temperature exceeds the specified value, the fan is turned off and the air conditioner is turned on.

Accordingly, the code activates the fan and air conditioner automatically based on the temperature.