Tuesday, 27 March 2018

DIY HOME AUTOMATION PROJECT USING IR REMOTE


DIY HOME AUTOMATION PROJECT USING IR REMOTE

Introduction

-All this began this year(2018).Everyone has some curiosity about doing something.The 'something' here might mean something innovative for some person or something that gives their life,habits,choices,etc some meaning.
IR remotes have always been omnipresent for the recent generations - the millenials and the Generation Z.This project is quite easy to understand and implement.BUT WHY SHOULD YOU DO THIS FIRST? The answer is-because  its neither too difficult (like designing a PSLV for ISRO!),nor too meaningless/dumb.


#COMPONENTS:



Arduino Uno (this can be avoided by using avr microcontroller without Arduino. Soon we’ll be talking about that too..)+cable
12V 1c/o relay (x4)
Power supply for the relay (12V in this case) // we made our own!! Check it out on our channel.
1k resistor (x4)
BC547 transistor (x4)
1N4007 diode (x4)
IR remote
SM0038 or TSOP 4838(recommended)
Jumper wires

 

#THEORY WE MUST KNOW-

-Diode

 Fundamentals: I am expecting that you have at least heard of a simple diode and transistor(bjt). Better if NOT! The Diode is known to limit current in a single direction.As per some amazing site on the web"The most common function of a diode is to allow an electric current to pass in one direction(called the diode's forward direction),while blocking it in the opposite direction(reverse direction).As such,the diode can be viewed as an electronic version of a check valve.here,it is used just to check that the coils are actuated only when we desire.

     The circuit is shown for a single relay module.The same procedure can be repeated for any number of relays(or switches).The basic principle of using a relay is to get a switch(the one we see at our homes) but its being controlled by an IR(Infrared remote/transmitter : any remote you use to watch TV ) .

-Transistor

The transistor here is being used as a switch (as you can see the common emitter configuration ,its easy to see).


“Here ,to operate the transistor as a switch the transistor needs to be turned either fully “OFF” (cut-off) or fully “ON” (saturated). An ideal transistor switch would have infinite circuit resistance between the Collector(C) and Emitter(E) when turned “fully-OFF” resulting in zero current flowing through it and zero resistance between the Collector and Emitter when turned “fully-ON”, resulting in maximum current flow.”In other and simple words, when their is a sufficient voltage devloped between the B(base) and the common E(emitter),a conductive path is developed between the C and E,i.e we have a short connection.


-Relay


Here we have taken a 12 V relay of 5 pins. Relay make a separate connection of AC and DC on one circuit. It synchronizes between AC mains and DC supply so that we can control the ac switch with dc voltage. As this relay is of 12V so if we give 12 v to the relay then it will be activated and it will make connection between common and normally open pin of relay(i.e. NO pin)

-Capacitor

It is a basic circuit building element besides resistor and inductor. Besides providing circuit impedence (i.e obstruction to the current) it is helpful in making RC ,LC and RLC filters.In this we have used a RC filter(refer to the topic discussed below for the filter).These filters are used to filter/remove some component. In this circuit we have used it to remove the surrounding noise from the atmosphere that gives garbage values at the output of the IR sensor.

-Resistor

These are the least explained components.They are very handy in every electronic project.Mostly you'll see them connected near the Ground terminal to  reduce the current in the circuit. This is seen in the project when we are communicating with the Arduino microcontroller so that it doesn't get burnt.Remember that if you have a circuit and you add the resistor in between any point of the wire and the GND then it performs Voltage Divider and if it put in series with the wire, it reduces current in the circuit.

-IR sensor


The sensor we used was a cheap SM0038 instead of a more famous TSOP .Without going into its materialistic study, the only things we need to know are :how to get the readings out of the sensor and send to the Arduino.Just look at the Pin diagram.





#CIRCUIT SETUP-




-Connecting the Arduino to the sensor–



The simple circuit is shown adjacently .The 5V to the Vs can also be provided externally. This may be sufficient in case of a good quality sensor but for most of the cases there is some noise interference in the readings out of the OUT pin of the sensor.i.e the Arduino received continuous readings without even pressing any button on the IR remote(look for that in the video).This was one of the biggest troubles that wasn't discussed anywhere on the internet !





*Making the filter circuitEither this circuit or the circuit you see in the final circuit diagram .Although you will still get some garbage values at the serial monitor(maybe 1 or two, we got only one garbage value).




-Setting up the switch board (relay board)

This is basic circuit involving a single relay.The same process has been repeated for other 3 relays.Focus only on the switching part .i.e Avioding the Arduino portion.Lookingat the figure above,we must know that as Ie=Ib+Ic  and for this configuration i.e Common emitter, we need current in microamperes at the base, to make the transistor work as a switch.

  • When the switch at the base terminal is open, no current flows through the base so the transistor is in the cutoff state. Therefore, the circuit acts as open-circuit and the switch becomes OFF
  • When the switch is closed, base current starts flowing through the transistor and then drives into saturation results to switch becoming ON.
  • In inductive loads, particularly switching of motors and inductors(here referring to the relay coils), sudden removal of power can keep a high potential across the coil. This high voltage can cause considerable damage to the rest circuit. Therefore, we have to use the diode in parallel with inductive load to protect the circuit from induced voltages of the inductive load.
For further details ,refer to : this link

Setting up the Arduino program-

  • Connect the circuit to the Arduino board 
  • Attach the USB cable of the Board to your PC
  • Open Arduino IDE
  • Upload the code
  • Open the serial monitor and press button on the IR remote that you want to use
  • You will see the values on the serial monitor corresponding to each button you press
  • Copy the value to the variables code1,code2 and code3

Understanding the Code

The code file has been provided in the video description.Still give your skills a try-try writing a code yourself. We won't be discussing the basics of Arduino IDE here.Do tell us in the comment section for more assistance.


  • We have defined the pins(because we need to tell the Arduino what pins are we going to use for INPUT and OUTPUT)
  • INPUT:To take readings from the sensor into the microcontroller (Arduino UNO)
  • OUTPUT:To send HIGH signals (+5V) to the base(B) of the respective transistor to activate it
  • The function IRrecv helps us to set the receive Pin
  • irrecv.enableIRIn() in the void setup is to enable the sensor 
  • The function irrecv.decode() decodes the data sent by the SM0048 to the Arduino



#TESTING-

After making a +12V supply, we made it both : +Vcc for the relays as well as the power supply for Arduino board(as you can't go on powering it with your USB)
Then, we didn't have any problem until the noise interference occured.Then the filter circuit was added and YEAH! everything was on line.

#IMPORTANT- Do not forget to modify the values of  the variables code1,code2 and code3 by the steps mentioned above.


#RESULT ANALYSIS AND CONCLUSION-

The project got completed as expected (although there were many unexpected surprises like the power failures and noise interference) and that too sooner than someone would expect his maiden project to.Best of Luck for your attempt to not only complete it but also learn from it.



1 comment:

LDR based light controlled Home Automation system

LDR based light controlled Home Automation system Introduction: Automation is the thing we can see all around the globe in terms of...