Step-by-Step Guide: Interface 2 Channel Relay Channels With Arduino

by AKP in Circuits > Arduino

308 Views, 4 Favorites, 0 Comments

Step-by-Step Guide: Interface 2 Channel Relay Channels With Arduino

two-channel-relay-module-arduino-tutorial-1.jpg

In your upcoming project, you may need to use your Arduino to control a high-voltage device, such as a lamp, fan, or household appliance. However, the Arduino, operating at 5 volts, cannot directly control these high-voltage appliances.

To address this issue, 2 relay module come into play. These self-contained modules are affordable, easy to connect, and ideal for DIY projects that require switching moderate amounts of AC or DC power. The only drawback is that, being electro-mechanical devices, they are more susceptible to wear and tear over time.

This tutorial will guide you through the process of setting up the relay module to control a lamp or another device. But before that, let’s have a quick introduction to relays.

How Do Relays Work?

relay-working-animation.gif

At the core of a relay is an electromagnet, which is a wire coil that becomes a temporary magnet when electricity passes through it. The working principle of a relay can be likened to that of an electric lever: when a relatively small current flows through the coil, it activates the electromagnet, which in turn switches on or off another device that requires a much larger current.

Relays operate based on the principle of electromagnetic induction. When an electric current flows through the coil, it generates a magnetic field around the coil, which attracts or repels a movable contact within the relay arduino. This contact is connected to one or more electrical terminals, allowing it to either make or break an electrical connection.

Relay Operation

relay-pinout.png

There are two main types of relays: normally open (NO) and normally closed (NC). In the default state, a NO relay’s contact is open, meaning no electrical connection exists between its terminals. When the coil is energized, the contact moves and establishes a connection. On the other hand, in the default state of an NC relay, the contact is closed, creating an electrical connection between its terminals. When the coil is energized, the contact moves away, breaking the connection.

Relays are widely used in various applications, especially where low-power control signals need to control high-power devices. They act as switches, allowing the control of devices that operate on different voltage levels or types of current, such as controlling household appliances, motors, lights, or industrial machinery.

Relays play a crucial role in many electronic and electrical systems, providing a safe and efficient means of controlling high-voltage and high-current loads using low-voltage and low-current control signals.

Two Channel Relay Module Hardware Overview

Two-Channel-Relay-Module-Relays.jpg

The 2 channel relay module is designed to allow your Arduino to control two high-powered devices. It has two relay arduino, each with a maximum current rating of 10A at 250VAC or 30VDC.

Modules with one, four, and eight channels are also available. You can choose the one that best meets your needs.

Output Terminal Blocks

two-channel-relay-module-output-terminal-blocks.jpg

The output terminal blocks on the 2 Channel Relay Module are the points where the high voltage terminals of each relay are connected. These terminal blocks typically consist of screw terminals that allow easy and secure connections for the devices you want to control.

Each relay has three output terminals: NC (Normally Closed), COM (Common), and NO (Normally Open). These terminals are used to interface the high-voltage devices or loads that you want to switch on or off using the relay.

When the relay is in its resting or deactivated state, the connection is established between the COM and NC terminals, creating a normally closed circuit. When the relay is activated or energized, the connection is shifted from COM to NO terminals, creating a normally open circuit.

You can connect your high-voltage devices, such as lamps, fans, solenoids, or other appliances, to these output terminal blocks for control using the relay. Always ensure proper isolation and safety measures when dealing with high-voltage devices to prevent accidents and damage.

Module Control

two-channel-relay-module-control-pins.jpg

Module control refers to the process of controlling the operation of the relay module to switch the high-voltage devices connected to it. In the context of the 2 Channel Relay Module, the module control involves activating or deactivating the relays to turn on or off the high-voltage devices.

The Two Channel Relay Module can be controlled through the input pins (IN1 and IN2) of the relay module. These input pins are driven by a microcontroller, such as an Arduino, or any other logic device capable of providing a digital signal.

The module operates on a 5V logic level, and when a logic LOW signal (0V) is applied to the input pins, the relay is activated, and the high-voltage devices connected to the output terminal blocks are turned on. Conversely, when a logic HIGH signal (5V) is applied to the input pins, the relay is deactivated, and the high-voltage devices are turned off.

The control of the relay module can be programmed using suitable code on the microcontroller, and it can be used in various applications, such as home automation, robotics, and industrial control, to switch and control different electrical appliances and devices remotely and automatically. Proper safety measures and isolation should be ensured when dealing with high-voltage devices to prevent potential hazards.

Built-in Optocouplers

Two-Channel-Relay-Module-Optocouplers.jpg

The 2 Channel Relay Module is equipped with built-in optocouplers, which are electronic components that provide electrical isolation between the input control signal and the relay circuit. Optocouplers are used to protect the controlling device (such as an Arduino or microcontroller) from potential electrical faults or voltage spikes that may occur in the relay circuit or high-voltage devices being controlled.

The optocouplers work by using an infrared LED and a phototransistor sealed in a light-tight housing. When a control signal is applied to the input pins of the 2 relay module, the infrared LED is activated, emitting light. This light is detected by the phototransistor, which in turn conducts current in the output circuit of the optocoupler. This creates a galvanic isolation between the input and output sides, allowing the control signal to be safely transmitted without direct electrical connection.

By incorporating optocouplers in the relay module, any potential high-voltage disturbances or voltage transients that occur in the relay circuit will be isolated from the control circuit, preventing damage to the controlling device. This additional layer of protection makes the relay module more reliable and safer to use in various applications, especially when dealing with high-voltage loads or critical electronic components.

Power Supply Selection Jumper

two-channel-relay-module-power-supply-selection-jumper.jpg
relay-module-power-selection-jumper-setting.png

The 2 Channel Relay Module includes a power supply selection jumper that allows you to choose how the relay module is powered.

When the jumper is in place, it connects the header pins labeled JD-VCC and VCC. In this configuration, the relay module is powered directly from the same power supply as the controlling device (such as an Arduino or microcontroller). This means that the relay’s electromagnet is energized using the same 5V power supply that powers the controlling device. In this case, the relay module and the controlling device are not physically isolated from each other.

On the other hand, if you remove the jumper, the relay module becomes physically isolated from the controlling device. This means that you need to provide a separate 5V power supply voltage to the JD-VCC and GND pins on the relay module. In this configuration, the controlling device and the relay module operate independently with their own power sources.

The power supply selection jumper provides flexibility in how you power the relay module based on your specific application requirements. If you prefer a simpler setup and want to power both the controlling device and the relay module with the same power supply, you can keep the jumper in place. However, if you need electrical isolation between the controlling device and the relay module or if you want to use different power sources for each, you can remove the jumper and supply power separately to the 2 relay module.

Arduino Example Code

wiring-relay-module-with-arduino.png
wiring-relay-module-with-arduino-and-external-supply.png
int RelayPin = 6;

void setup() {
// Set RelayPin as an output pin
pinMode(RelayPin, OUTPUT);
}

void loop() {
// Let's turn on the relay...
digitalWrite(RelayPin, LOW);
delay(3000);

// Let's turn off the relay...
digitalWrite(RelayPin, HIGH);
delay(3000);
}

See Full Article Here