IR Remote Controlled Home Automation using Arduino
IR Remote Controlled Home Automation using Arduino
Previously we have covered many types of Home automations using different technologies like DTMF Based Home Automation, P ontrolled Home Automation using Arduino, Bluetooth ontrolled Home Automation! "n this pro#ect, we are using "$ %ased wireless communication for controlling home appliances! "n this pro#ect, Arduino is used for controlling whole the process! &e send some commands to the controlling system %y using "$ T'(D'D(MP) remote for controlling A home appliances! After receiving signal from "$ remote, Arduino sends related signal to relays which are responsi%le for switching *+ or *FF of the home appliances through a relay driver!
Working Explanation:
&orking of this pro#ect is easily understanda%le! &hen we press any %utton of IR Remote then remote sends a code in form of train of encoded pulses using )-h. modulating fre/uency! These pulses are received %y TSOP1738 sensor and read %y Arduino and then Arduino decodes
received train of pulse into a he0 value and compares that decoded value with the predefined he0 value of the pressed %utton! "f any match occurs then Arduino perform relative operation and the corresponding result is also displayed on 1203 4D %y using appropriate commands! Here in this pro#ect we have used ) %ul%s of different colors, for demonstration which indicates Fan, 4ight and T'!
There are many types of "$ $emote are availa%le for different device %ut most of them are worked on around )-H. Fre/uency signal! Here in this pro#ect we control home appliances using "$ T' remote! For detecting "$ remote signal, we use T5*P16) "$ $eceiver! This T5*P16) sensor can sense )-h. Fre/uency signal! The working of "$ remote and the T5*P16) can %e covered in detail in this article7 "$ Transmitter and $eceiver
Components: •
Arduino UNO
•
TSOP!"#
•
IR T$%&$& Remote
•
U'N())"
•
Rela*s + ,olt
•
-ul. /it0 0older
•
Conne1ting /ires
•
-read .oard
•
2x( 'C&
•
Po/er suppl*
•
P$T
•
IC !#)+
Here in this pro#ect we have used 6, and 8 num%er %utton of "$ remote, for controlling Fan, 4ight and T' respectively and *+(*FF %utton 9Power %utton: is used for turning *+ and *FF all the appliances simultaneously!
Here we have used toggle ;<'<+ *DD= method for *+ and *FF the single home appliance! Toggle methodis nothing %ut to get that whether the %utton is pressed even no of times or the odd no of times! This is found %y getting the reminder after dividing it %y 3 9i>3:, if there is some reminder then device will %e turned *+ and if reminder is ? then it will %e turned *FF! 5uppose -ey 6 is pressed on the remote then remote sends a signal to Arduino through T5*P "$ $eceiver! Then Arduino decode it and store the decoded value into the results varia%le! +ow results varia%le has a he0 value ?01F?FF, after matching it with the predefined he0 value of key 6 9see a%ove image:, Arduino turns *+ the Fan! +ow when we press the same key 9key 6: again then "$ sends the same code! Arduino gets same code and matched with same code like %efore %ut this time Fan turned *FF %ecause of toggling the %it ;<'<+ *DD= 9i>3:!
&e1oding IR Remote Control Signals using Arduino: Here is a list of a D'D +< type $emote decoded output codes7
"f you don@t know the Decoded output for your "$ remote, it can %e easily found, #ust follow these steps7 3 &o/nload t0e IR remote li.rar* 4rom 0ere 0ttps:%%git0u.31om%5"t)%Arduino6 IRremote3 (3 Un5ip it7 and pla1e it in *our Arduino 8'i.raries9 4older3 T0en rename t0e extra1ted 4older to IRremote3 "3 Run t0e .elo/ program 4rom *our Arduino and open t0e Serial onitor /indo/ in Arduino I&E3 No/ press an* IR Remote .utton and see t0e 1orresponding de1oded 0ex output in Serial onitor /indo/3 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv * An IR detector/demodulator must be connected to the input RECV!I"#
* Version $#% &ul'( )$$ * Cop'right )$$ +en ,hirri * http://arcn#com */ .include IRremote#h0 int RECV!I" 1 %%2 IRrecv irrecv3RECV!I"42 decoderesults results2 void setup34 5 ,erial#begin36$$42 irrecv#enableIRIn342 // ,tart the receiver 7 void loop34 5 i 3irrecv#decode38results44 5 ,erial#println3results#value( 9E42 irrecv#resume342 // Receive the ne;t value 7 dela'3%$$42 7
The a%ove program is taken from "$remote li%rary@s e0amples@ folder, you can check out more e0amples to learn more a%out using the "$ remote! 5o that@s how we decoded the "$ remote output!
Cir1uit &es1ription: onnections of this circuit is very simple here a li/uid crystal display is used for displaying status of home appliances which is directly connected to arduino in C%it mode! Data pins of 4D namely $5, <+, D, D, D2, D6 are connected to arduino digital pin num%er 2, 6, , 8, 1?, 11! And output pin of T5*P16) is directly connected at digital pin num%er 1 9A: of Arduino! And 'cc pin is connected a E volt and +D pin connected at round terminal of circuit! A relay driver namely G4+3??) is also used for driving relays! volt 5PDT ) relays are used for controlling 4"HT, FA+ and T'! And relays are connected to arduino pin num%er ), and through relay driver G4+3??) for controlling 4"HT, FA+ and T' respectively!
Code &es1ription: "n programming part of this pro#ect First of all in programming we includes li%rary for "$ remote which is easily availa%le at oogle! And define pin and declare varia%les! .include IRremote#h0 const int RECV!I"1%<2 IRrecv irrecv3RECV!I"42 decoderesults results2
And then include a header for li/uid crystal display and then we defines data and control pins for 4D and home appliances! .include=i>uidCr'stal#h0 =i>uidCr'stal lcd36(?(@((%$(%%42
.deine an B .deine =ight < .deine V
After it we need to initiali.e the 4D and give direction of pin that are used for fan , light and T'! void setup34 5 ,erial#begin36$$42 lcd#begin3%6()42 pinode3an( FG!G42 pinode3=ight( FG!G42 pinode3V( FG!G42
As already e0plained, %elow part of the code is used to compare the received he0 value to already defined he0 code of that %utton! "f it matched then a relative operation is performed %y using appropriate functions that are given in code! void loop34 5 i 3irrecv#decode38results44 5 ,erial#println3results#value(9E42 dela'3%$$42 lcd#setCursor3$($42 lcd#print3Han =ight VH42 i3results#value11$;%E$$4 5 i2 int ;1iJ)2 digitalKrite3an( ;42
Code:
includeI4i/uidrystal!hJ include I"$remote!hJ const int $<'KP"+L1 "$recv irrecv9$<'KP"+: decodeKresults results includeI4i/uidrystal!hJ 4i/uidrystal lcd92,6,,8,1?,11: define Fan ) define 4ight define T' int iL?,#L?,kL?,nL? void setup9: N 5erial!%egin982??:
lcd!%egin912,3: pinMode9Fan, *GTPGT: pinMode94ight, *GTPGT: pinMode9T', *GTPGT: ((digital&rite91),H"H: lcd!print9O$emote ontrolledO: lcd!setursor9?,1: lcd!print9OHome AutomationO: delay93???: lcd!clear9: lcd!print9Oircuit DigestO: lcd!setursor9?,1: delay91???: lcd!print9O5ystem $eady!!!O: delay91???: irrecv!ena%le"$"n9: (( 5tart the receiver irrecv!%link1)9true: lcd!clear9: lcd!setursor9?,?: lcd!print9OFan 4ight T' O: lcd!setursor9?,1: lcd!print9O*FF *FF *FFO: void loop9: N if 9irrecv!decode9Qresults:: N 5erial!println9results!value,H3 digital&rite9Fan, 0: lcd!setursor9?,1: if90: lcd!print9O*+ O: else lcd!print9O*FF O: (( delay93??:
else if9results!valueLL?01F3 digital&rite94ight, 0: lcd!setursor92,1: if90: lcd!print9O*+ O: else lcd!print9O*FF O: (( delay93??: if9results!valueLL?01F<826: N kEE int 0Lk>3 digital&rite9T', 0: lcd!setursor91),1: if90: lcd!print9O*+ O: else lcd!print9O*FFO: (( delay93??: if9results!valueLL?01F<B6: N nEE int 0Ln>3 digital&rite9T', 0: digital&rite9Fan,0: digital&rite94ight,0: lcd!setursor9?,1: if90: lcd!print9O*+ *+ *+ O: else lcd!print9O*FF *FF *FFO: ((delay93??:
(( key 1
irrecv!resume9: (( $eceive the ne0t value ((delay91??: $ideo: