0% found this document useful (0 votes)
26 views20 pages

4 Channel Relay

The document outlines the components and setup for a 4-channel IR remote relay switch project, detailing parts like the ATTINY85 microcontroller, TSOP1838 IR sensor, BC547 transistor, and various resistors and diodes. It provides a step-by-step guide for assembling the circuit, including wiring and programming instructions, as well as Arduino code for decoding IR signals and controlling the relays. The project enables wireless control of multiple devices through an IR remote, enhancing automation and convenience in home systems.

Uploaded by

sm9473743674
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views20 pages

4 Channel Relay

The document outlines the components and setup for a 4-channel IR remote relay switch project, detailing parts like the ATTINY85 microcontroller, TSOP1838 IR sensor, BC547 transistor, and various resistors and diodes. It provides a step-by-step guide for assembling the circuit, including wiring and programming instructions, as well as Arduino code for decoding IR signals and controlling the relays. The project enables wireless control of multiple devices through an IR remote, enhancing automation and convenience in home systems.

Uploaded by

sm9473743674
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Required Components:

Following is the list of all components used in this project-

 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:

The ATTINY85 is a powerful and compact 8-bit microcontroller


belonging to the AVR family, manufactured by Atmel (now part of
Microchip Technology). It is widely recognized for its versatility, low
power consumption, and ability to perform a wide range of
functions. The ATTINY85 features 8KB of programmable flash
memory, which allows users to store custom programs, along with
512B of SRAM for handling temporary data and 512B of EEPROM
for non-volatile storage, making it suitable for data logging and
applications requiring memory retention after power loss.

Operating at a clock frequency of up to 20 MHz, the ATTINY85 is


designed for efficient performance while maintaining a small
footprint. It includes 6 general-purpose I/O pins, allowing it to
interface with various sensors, actuators, and other peripherals.
Additionally, it supports PWM (Pulse Width Modulation), ADC
(Analog-to-Digital Conversion), and SPI (Serial Peripheral
Interface), enabling precise control in embedded systems.

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 TSOP1838 is a highly reliable infrared (IR) receiver module


designed to decode signals from IR remote controls. Operating at a
standard carrier frequency of 38kHz, it is compatible with most
commercially available remote controls, making it a popular choice
for home automation and embedded systems. This compact and
efficient module includes a built-in demodulator that filters and
processes the modulated IR signals, allowing the microcontroller
to directly interpret the decoded output.

The sensor’s design ensures high noise immunity, effectively


rejecting interference from ambient light, fluorescent lamps, and
other IR sources, making it highly reliable in various lighting
conditions. The TSOP1838 has three pins: Vcc, GND, and OUT,
with the output pin providing a digital signal corresponding to the
detected IR pulses. This enables seamless integration into
microcontroller-based projects like Arduino, Raspberry Pi, or
ATTINY85 systems.

The module is ideal for applications such as remote-controlled


devices, robotics, appliance automation, and IoT systems,
where decoding multiple command signals is required. Its low
power consumption, compact size, and wide compatibility make
the TSOP1838 a versatile choice for consumer electronics and DIY
projects.
BC547 Transistor:

The BC547 is a popular general-purpose NPN bipolar junction


transistor (BJT) widely used in low-power electronic circuits. It is
known for its versatility, reliability, and ease of use. This transistor
is designed to handle collector currents up to 100mA and can
operate at a maximum voltage of 45V between the collector and
emitter, making it suitable for a variety of small-signal
amplification and switching applications.

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.

Its small TO-92 package ensures compact integration into circuits,


while its affordability and widespread availability make the BC547
a favorite among professionals and hobbyists alike.
Relay Module:

The Relay Module is a crucial component in the 4-Channel IR


Relay Module project, serving as an interface between low-power
control systems, such as the ATTINY85 microcontroller, and high-
power devices like motors, lights, and appliances. Each channel of
the relay module acts as an electronically operated switch that
isolates the microcontroller from the high-power circuit, ensuring
safety and reliability.

The module typically supports both AC (up to 250V) and DC (up


to 30V) loads, with each relay capable of handling up to 10A of
current. It uses an electromagnetic coil to mechanically toggle
between the normally open (NO) and normally closed (NC)
terminals, allowing precise control over connected devices.

In the project, the relay module enables the microcontroller to


switch up to four electrical appliances via IR remote signals
decoded by the TSOP1838 sensor. Its design ensures efficient
operation, electrical isolation, and robust handling of high-current
devices, making it essential for home automation and remote-
controlled systems.
1N4148 Diode:

The 1N4148 is a fast-switching silicon diode commonly used in


electronic circuits, including the 4-Channel IR Relay Module
project. It is a small-signal diode known for its high switching
speed of up to 4ns, making it ideal for high-frequency applications.
In the relay module, the 1N4148 diode is used as a flyback diode,
placed across the relay coil to prevent voltage spikes generated
during the switching process.

When the relay coil is de-energized, it generates a back


electromotive force (EMF) that could damage other components in
the circuit. The 1N4148 diode protects the microcontroller and
other sensitive parts by safely dissipating this energy. Its compact
size, low forward voltage drop (~0.7V), and ability to handle up to
300mA of current make it an essential component for ensuring
circuit safety and stability.
100Ω & 10KΩ Resistors:

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:

In a 4-channel IR relay module project, the Remote Controller is


responsible for sending modulated infrared (IR) signals to the
TSOP1838 IR sensor. When a button on the remote is pressed, it
triggers the IR LED to emit signals modulated at a specific
frequency (typically 38 kHz).

The TSOP1838 sensor detects these modulated signals and


converts them into electrical pulses, which are then sent to a
microcontroller (such as an Arduino). The microcontroller decodes
the pulses to determine which button was pressed. Based on the
decoded command, the microcontroller activates the
corresponding relay on the 4-channel IR relay module,
controlling external devices like lights or fans.

This system enables wireless control of appliances through the


remote, providing convenience and automation. The range and
accuracy of the system depend on the power of the remote and the
sensor’s ability to detect the signals.
LED:

An LED (Light Emitting Diode) is a semiconductor device that


emits light when an electric current passes through it. Unlike
traditional incandescent bulbs, LEDs are energy-efficient, durable,
and long-lasting. They produce light through electroluminescence,
where electrons recombine with holes within the semiconductor,
releasing energy in the form of photons.

LEDs are available in a variety of colors and can be used in


applications ranging from indicator lights and displays to general
lighting and automotive lights. Their compact size, low power
consumption, and environmental friendliness make them popular
in modern electronics and lighting solutions.

2 Pin Terminal Blocks:

A 2-pin terminal block is a simple electrical connector used to


join two wires securely. It consists of two terminals that clamp the
wires in place, usually via screws, providing a reliable electrical
connection. These terminal blocks are commonly used in low-
voltage electrical systems, such as in circuits or for connecting
components like sensors, relays, or motors. The two pins allow for
easy insertion of wires, making the setup both quick and safe.
Circuit Diagram:

Project Picture:
Explanation of 4-Channel IR Remote Relay Switch:

To build a 4-channel IR remote relay switch, the following steps


guide you through assembling the components, wiring the circuit,
and configuring it for relay control via an IR remote. Here's the
breakdown of each step:

1. Power Supply and Microcontroller Setup


 ATTINY85 Microcontroller: The ATTINY85 is a small, low-
power microcontroller that will be used to control the relay
switches.
 Power Supply: Start by connecting the ATTINY85
microcontroller to a 5V power supply using a 2-pole
terminal block.
o Pin-8 of the microcontroller should be connected to
+5V.
o Pin-4 of the microcontroller should be connected to
ground.

2. IR Receiver (TSOP1838) Setup


 TSOP1838 IR Receiver: This sensor is used to receive
modulated infrared signals from an IR remote. It decodes
these signals and sends them to the microcontroller.
 Wiring the IR Receiver:
o Pin-1 of the TSOP1838 connects to Pin-3 of the
microcontroller (this is used for the signal input).
o Pin-2 of the TSOP1838 connects to ground.
o Pin-3 of the TSOP1838 connects to +5V.

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.

4. Relay and Transistor Setup


 BC547 Transistor: The BC547 is an NPN transistor used as
a switch to control the relay. The transistor amplifies the
signal from the microcontroller to trigger the relay.
 Relay: A 5V relay is used to control external devices (like
lights, fans, etc.). The relay has a coil that is energized to
close the switch, activating the connected load.
 Wiring the Transistor and Relay:
o Pin-3 (Collector) of the BC547 transistor connects to
ground.
o Pin-1 (Emitter) of the BC547 connects to coil pin-2 of
the 5V relay.
o Coil pin-1 of the relay connects to +5V.

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.

7. Relay Terminal Block


 2-pole Terminal Block: This component allows you to
connect external devices to the relay.
o One pin of the terminal block connects to the Normally
Open (NO) pin of the relay.
o The other pin of the terminal block connects to the
Common (COM) pin of the relay.

8. Repeat for Additional Channels


 Steps 4 through 7 need to be repeated for each of the
additional channels. For a 4-channel system, repeat the
following steps three more times:
o Set up a transistor, relay, diode, LED, and terminal
block for each of the three remaining channels.
o Each channel operates independently to control a
different load.

9. Connecting Transistor Pins to Microcontroller


 Now, focus on the Pin-2 of each BC547 transistor, which is
not yet connected.
 10kΩ resistors are connected to Pin-2 of each BC547
transistor.
o The first resistor connects to Pin-2 of the
microcontroller.
o The second resistor connects to Pin-7 of the
microcontroller.
o The third resistor connects to Pin-6 of the
microcontroller.
o The fourth resistor connects to Pin-5 of the
microcontroller.

These resistors act as pull-ups, ensuring proper signal levels to


drive the transistors effectively. The microcontroller pin number
assignments allow each transistor to be activated individually for
each relay channel.

Once you’ve completed these steps, you’ll have a fully functional


4-channel IR remote relay switch. The IR remote sends signals to
the TSOP1838 IR Receiver, which decodes them and sends
commands to the ATTINY85 microcontroller. The
microcontroller, in turn, activates the corresponding BC547
transistor, triggering the relay to control the connected external
devices. The LED serves as an indicator, showing the status of
the relay. This setup provides a compact and efficient way to
control multiple devices remotely via IR signals.
Arduino Code for Decoding IR Codes:

#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:

const int irPin = 4;


const int Relay1 = 0;
const int Relay2 = 1;
const int Relay3 = 2;
const int Relay4 = 3;
boolean Relay1State = false;
boolean Relay2State = false;
boolean Relay3State = false;
boolean Relay4State = false;
void setup() {

//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:

 Successful Design and Implementation: The 4-channel IR


relay module for home automation was successfully
developed using an ATTINY85 microcontroller, TSOP1838
IR receiver, and BC547 transistors.
 Reliable Performance: The system reliably controlled up to
four devices simultaneously, such as lights and fans,
through an IR remote.
 Signal Processing: The TSOP1838 IR receiver successfully
decoded signals from the IR remote, which were then
processed by the ATTINY85 microcontroller.
 Relay Control: Each relay was triggered by the respective
button on the IR remote, activating or deactivating
connected appliances.
 Transistor Functionality: The BC547 transistors acted
efficiently as switches, enabling the relays to control higher-
power devices.
 Flyback Diodes: 1N4148 diodes effectively protected the
relays from voltage spikes when turning off the relay coils.
 LED Indicators: LEDs served as status indicators,
providing visual feedback about the relay’s state (on/off).
 Optimal Range: The system worked within the expected IR
range of 5-10 meters, without significant interference or
malfunctions.

 Challenges: Initial setup required fine-tuning of the


microcontroller’s signal decoding to ensure accurate relay
control.
Conclusion:

 Cost-Effective and Reliable Solution:


The 4-channel IR relay module offers an affordable, reliable,
and efficient method for home automation.
 Microcontroller Efficiency:
The ATTINY85 microcontroller successfully processes IR
signals and controls multiple relays without issues.
 Flexible Control:
The system provides the ability to control up to four
different appliances via a single IR remote, with the
potential to expand for more devices.
 Future Improvements:
Future enhancements could include adding more relay
channels or integrating sensors (e.g., motion, temperature)
for advanced automation.
 Foundation for Smart Homes:
This project lays the groundwork for small-scale home
automation systems and can be adapted for larger, more
complex smart home applications.

The system can be expanded further by adding more relay


channels or integrating additional sensors for advanced
automation functions, such as motion detection or environmental
control (temperature, humidity, etc.). This project serves as a
solid foundation for further development and refinement in the
area of home automation, offering a glimpse into the future of
smart homes.
Scope of the Project:

1. Home Automation Control:


The 4-channel IR relay module is designed to offer wireless
control of home appliances, such as lights, fans, and other
household devices, via an IR remote. The project scope
includes controlling up to four devices independently
through simple button presses on the remote.
2. Expandability:
The system is scalable, meaning additional relays and
channels can be added in the future to control more devices.
This makes it adaptable to larger home automation setups.
3. Ease of Integration:
The relay module can be integrated with existing home
electrical systems, and it is compatible with common
appliances that can be turned on or off remotely. It can be
connected to various appliances using a 2-pole terminal
block for easy wiring.
4. Safety Features:
The project incorporates flyback diodes to protect relay
coils from voltage spikes, ensuring safe and reliable
operation in the home environment.
5. Potential for Future Upgrades:
The project can be expanded by incorporating other sensors
like motion sensors, temperature sensors, or integrating it
with more advanced systems like Wi-Fi or Bluetooth for
remote control via smartphones or other devices.
6. Educational Tool:
This project serves as an educational platform for learning
about microcontrollers, relay control, IR communication,
and basic home automation principles. It can be used for
academic purposes, DIY enthusiasts, or hobbyists looking to
explore electronics and automation.

You might also like