Hello guys, today we are going to make a remote-control universal switch on/off 3 channel circuit. Though this we can control any load like: fan, light, bulb, TV, charger or any other electrical appliances under 1000watts.
This circuit can be controlled using any IR (infrared) remote, it may be of Tv, A.C or any universal remote. We will build this circuit using very less and readily available components. This project is Sponsored By JLCPCB.
Basic Idea:First of all, we will decode our IR remote to get proper data (HEX numbers) Example “F887E790”. Then according to the Hex values, we will program Arduino to make ON/OFF function. And collect the output from digital pins of Arduino. After that we will build a controlling circuit using transistor and optocoupler as a switch. Through this circuit Relay is controlled and we can connect any type of load to ON/OFF.
Remote decoding tutorial: How to decode any IR remote using Arduino.
Breadboard schematics:1) SPDT relay x3
2) BC547 transistor x3
3) PC817 optocoupler x3
4) Atmega328p or Arduino
5) Crystal 16Mhz x1
6) 1k Resistor x 9
7) 10k resistor x1
8) 22pf capacitor x2
9) 100nf capacitor x1
10) Screw terminals x3
11) 5mm red led x3
12) 100ohm resistor x1
13) General purpose PCB x1
14) 9v battery
15) 1N4007 Diode x3
16) TSOP 1738- IR receiver x1
Circuit diagram:We will make this circuit in sections, so that circuit can be more understandable to us. First mount all the relays and screw terminals corresponding to it as shown in the PCB.
Taking idea from circuit diagram and PCB, mount all other components transistor, optocoupler, resistors, diodes and led. Using the same idea, we can increase relay channels from one to three and even more. Maximum relay channels that can be supported using this method is 12.
After controlling circuit, we will build microcontroller and power supply section, here we are using Atmega328p- 8bit Arduino’s popular microcontroller. This is more than enough for this type of project, Atmega328p works on 16Mhz crystal and also have EEPROM feature. EEPROM is helpful to keep last state of relays in mind when power goes off or disconnected.
In last we will connect TSOP-1738 and read Hex data values using Arduino digital input pin. Code is exactly turn ON/OFF the corresponding relay as stated in code.
A 9volt battery is enough to power the circuit properly. Our microcontroller and relays work on 5volts, that’s why using 9volt battery, a 5volt regulator (7805) is mandatory to use.
While working with general purpose PCB board, we should use pointed tip soldering iron, 63/37 solder wire and try to build this circuit using bridge soldering method.
Download all the required files, circuit diagram, schematics, Code and PCB Gerber files from here
Basically, we are dividing the circuit concept of this projects in some steps:
Step1: Decoding the IR remote, to decode any universal IR remote using Arduino just read our other project Article. So that it will be clearer to you. Follow this link here.
Step2: Make the circuit using schematics given above or you may use Our PCB Gerber file to directly order this project from JLCPCB.
Step3: Upload the given code in atmega328p microcontroller.
PCB single layer layout:Every button in IR remote has different hex number data, if we want to turn ON/OFF a device, we need two buttons of IR remote. One to switch ON and other one to switch OFF the same device.
Similarly, here we are making 3 channel relay controllers, that’s why we need 6 different buttons. Also, when we want to switch ON/OFF all the devices at same time, we need two more buttons. In total our IR remote should have 8 buttons.
When remote release IR hex data, it will be captured at receiver end and microcontroller decode the data, immediately turn ON/OFF the respective pin.
This code only controls the digital pins of Arduino. To switch ON/OFF any load we cannot directly mount relay on any microcontroller without controlling and switching circuit. That’s why here we are using a combination of optocoupler and NPN transistor as a switch to control the relay properly. Optocoupler is used to control transistor and further relay and mains load. Download the proper IR library from Here.
Code:
/* hello guys this code is designed by Sagar saini, youtube channel- sagar networks
* follow us on hackster using this link
* If the code not work, try to update IR libraries or download new and compatible library from my website.
* link: https://drive.google.com/file/d/14ooV9b64H_579zfkCLHSwh-WmZjaBadH/view?usp=sharing this code is 4 channel relay/ but work fine on this 3 channel relay pcb.
* To decode the data of any universal ir remote follow this link:
https://www.hackster.io/sainisagar7294/arduino-based-ir-remote-decoder-ac67c4
* I am always available on Instagram so please check out me there: saini_sagar_7294
*/
#include <IRremote.h>
const int RECV_PIN=8;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define Relay1 12 // Load1 Pin Out
#define Relay2 11 // Load2 Pin Out
#define Relay3 10 // Load3 Pin Out
#define Relay4 9 // Load4 Pin Out
int load1, load2, load3, load4, power;
void setup()
{
Serial.begin(9600);
pinMode(Relay1, OUTPUT); // declare as output for Load1 Pin Relay1
pinMode(Relay2, OUTPUT); // declare as output for Load2 Pin Relay2
pinMode(Relay3, OUTPUT); // declare as output for Load3 Pin Relay3
pinMode(Relay4, OUTPUT); // declare as output for Load4 Pin Relay4
digitalWrite(Relay1, 0); // Turn Off Load1
digitalWrite(Relay2, 1); // Turn Off Load2
digitalWrite(Relay3, 1); // Turn Off Load3
digitalWrite(Relay4, 1); // Turn Off Load4
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (IrReceiver.decode())
{
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
if(IrReceiver.decodedIRData.decodedRawData==0xED127F80){ // For Load1 ON ( change the hex value ED127F80 to your remote value)
load1 = 0;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xE51A7F80){ // For Load1 Off
load1 = 1;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xFE017F80){ // For Load2 On
load2 = 0;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xFD027F80){ // For Load2 Off
load2 = 1;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xFB047F80){ // For Load3 On
load3 = 0;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xFA057F80){ // For Load3 Off
load3 = 1;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xF8077F80){ // For Load4 On
load4 = 0;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xF7087F80){ // For Load4 Off
load4 = 1;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xE11E7F80){ // For Load4 Off
load1=0;
load2=0;
load3=0;
load4=0;
}
else if(IrReceiver.decodedIRData.decodedRawData==0xFC037F80){ // For Load4 Off
load1=1;
load2=1;
load3=1;
load4=1;
}
irrecv.resume(); // Receive the next value
delay(100);
}
if(power==1){
digitalWrite(Relay1, 1); // Turn Off Load1
digitalWrite(Relay2, 1); // Turn Off Load2
digitalWrite(Relay3, 1); // Turn Off Load3
digitalWrite(Relay4, 1); // Turn Off Load4
}else{
digitalWrite(Relay1, load1);
digitalWrite(Relay2, load2);
digitalWrite(Relay3, load3);
digitalWrite(Relay4, load4);
}
delay(500);
}
Implementation:We can put this circuit in our house mains electric board to control the electrical appliances. Here is the best example of this:
We can connect different loads to different channels and control this with TV remote, there is no need of any type of internet, Wi-Fi or Bluetooth connection.
About JLCPCB:JLCPCB is the one of the most popular PCB makers. Price is just $2 for 2layer PCB, $5 for 4-layer PCB. They just launched new purple solder mask and aluminum Pcb in very low cost. Pcb quality is not compromised at any cost. Check them out right now from Here.https://jlcpcb.com/IAT
In future updates we will make this circuit more compact and increase the microcontroller speed- just changing it with STM version. We will make an EEPROM function in code and maybe, will come back with new PCB design having Bluetooth or Wi-Fi connectivity.
Here is the remote decoder project using Arduino.
Try JLCPCB and order your first PCB prototype in just $2.
Till then check out our other projects and make sure to follow us on Instagram: saini_sagar_7294, Hackster and Hackaday.
Comments