4 Channel Relay
4 Channel Relay
1 X ATTINY85
1x TSOP1838 IR Sensor
1X BC547 Transistor
4X 1N4148 Diodes
5X LED
5X 100 Ohm Resistors
5X 10K Resistors
4X 5V Relays
2x 2 Pin Terminal Blocks
Remote Control
1X PERF BOARD
Components Detail:
ATTINY85:
With its compact size and ability to run on low voltage (2.7V–5.5V),
the ATTINY85 is ideal for applications such as IoT devices,
wearables, automation systems, and DIY electronics projects.
Its simplicity in programming using Arduino IDE and compatibility
with bootloaders further enhance its usability, making it a
preferred choice for both professionals and hobbyists.
TSOP1838 IR Sensor:
The BC547 has three terminals: Emitter (E), Base (B), and
Collector (C). When a small current is applied to the base, it allows
a larger current to flow from the collector to the emitter, effectively
amplifying the input signal. This property makes it ideal for signal
amplification in audio circuits, sensors, and low-power devices.
The transistor has a gain value (hFE) ranging between 110 and
800, enabling efficient signal amplification. It operates in three
regions: the cut-off region (acting as an open switch), the
saturation region (acting as a closed switch), and the active
region (amplifying signals). The BC547 is widely used in
applications like LED drivers, relay drivers, oscillators, and
timing circuits.
100Ω Resistor
The 100Ω resistor is used in the 4-Channel IR Relay Module
project to limit current flow and protect sensitive components like
LEDs. When connected in series with an LED, the resistor ensures
that the LED operates within its safe current range, preventing
damage caused by excessive current. For example, with a 5V power
supply, the 100Ω resistor drops the voltage and limits the current
flowing through the LED to approximately 20mA. This makes it a
critical component for safe and efficient LED operation.
10KΩ Resistor
The 10KΩ resistor plays a crucial role in the circuit by acting as a
pull-up or pull-down resistor for the base pins of the transistors
(e.g., BC547) and input pins of the ATTINY85 microcontroller. It
ensures stable operation by preventing floating inputs, which
could cause erratic switching behavior. In this project, the 10KΩ
resistor is also used to maintain a high or low state on the input
signal lines, ensuring the proper triggering of transistors and
smooth relay operation. Its high resistance ensures minimal
current consumption, contributing to the overall efficiency of the
circuit
Remote Controller:
Project Picture:
Explanation of 4-Channel IR Remote Relay Switch:
3. Pull-up Resistor
Place a 10kΩ resistor between Pin-1 of the microcontroller
and +5V. This serves as a pull-up resistor, ensuring proper
signal levels for the microcontroller to detect the IR signal.
5. Flyback Diode
1N4148 Diode: This diode protects the relay from voltage
spikes generated when the relay coil is de-energized.
o The cathode of the diode connects to coil pin-1 (the
+5V side of the relay).
o The anode of the diode connects to coil pin-2 (the side
of the relay connected to the transistor).
6. LED Indicator
LED: An LED is used as an indicator to show when the relay
is activated.
o The cathode of the LED connects to pin-1 of the
BC547 transistor.
o The anode of the LED connects to one side of a 100Ω
resistor.
o The other side of the 100Ω resistor connects to +5V.
#include <IRremote.h>
int IRpin = 2;
IRrecv irrecv(IRpin);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC);
irrecv.resume();
}
}
Arduino Code for Programming ATTINY85:
//Serial.begin(115200);
pinMode(irPin, INPUT);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
}
void loop() {
int key = getIrKey();
if(key == 1 ){
Relay1State = !Relay1State;
if(Relay1State == true)
digitalWrite(Relay1, HIGH);
else
digitalWrite(Relay1, LOW);
}
if(key == 2 ){
Relay2State = !Relay2State;
if(Relay2State == true)
digitalWrite(Relay2, HIGH);
else
digitalWrite(Relay2, LOW);
}
if(key == 3 ){
Relay3State = !Relay3State;
if(Relay3State == true)
digitalWrite(Relay3, HIGH);
else
digitalWrite(Relay3, LOW);
}
if(key == 4 ){
Relay4State = !Relay4State;
if(Relay4State == true)
digitalWrite(Relay4, HIGH);
else
digitalWrite(Relay4, LOW);
}
}
int getIrKey(){
int len = pulseIn(irPin,LOW);
int key, temp;
key = 0;
//Serial.print("len=");
//Serial.println(len);
if(len > 5000) {
for(int i=1;i<=32;i++){
temp = pulseIn(irPin,HIGH);
if(temp > 1000)
key = key + (1<<(i-17));
}
}
if(key < 0 )
key = -key;
//if(key)
//Serial.println(key);
delay(250);
return key;
}
Result & Discussion: