Logo

Interfacing 4 Channel Relay with Arduino

4 Channel Relay Module

A 4 Channel Relay Module allows an Arduino to control four separate high-voltage devices simultaneously. It's a reliable component for smart home automation, industrial equipment management, and IoT applications requiring multiple outputs.

Working Principle of 4 Channel Relay

The 4 Channel Relay operates by receiving a low-voltage control signal from the Arduino, which energizes an internal electromagnetic coil. This activates a mechanical switch, allowing or interrupting the flow of current to the connected devices.

Types of Relay Modules

Electromechanical Relay (EMR)

  • Receives signal from Arduino digital pin.
  • Energizes internal coil to create magnetic field.
  • Closes the circuit to power connected device.

Solid State Relay (SSR)

  • Accepts input from microcontroller.
  • Switches load via optocoupler and semiconductor switches.
  • Ideal for applications requiring frequent switching.

Requirements

1. Arduino Board

2. 4 Channel Relay Module

3. Jumper Wires

4. 100 ohm resistors (optional for protection)

Pin Configuration of 4 Channel Relay

Relay Module Pins

  • VCC: Connect to +5V on Arduino.
  • GND: Connect to GND on Arduino.
  • IN1: Control input for Relay Channel 1.
  • IN2: Control input for Relay Channel 2.
  • IN3: Control input for Relay Channel 3.
  • IN4: Control input for Relay Channel 4.
  • COM: Common terminal (one per relay).
  • NO: Normally Open terminal (one per relay).
  • NC: Normally Closed terminal (one per relay).

Wiring the 4 Channel Relay to Arduino

Connect the relay module’s VCC and GND to the Arduino's 5V and GND. Then link IN1 to IN4 pins to digital output pins (like D2 to D5). Connect your devices to the COM and NO/NC terminals for each relay as per your application.

Algorithm

  1. Setup Connections

    • Connect VCC and GND of the relay module to 5V and GND on Arduino.
    • Connect IN1 to IN4 to digital pins (e.g., D2, D3, D4, D5).
  2. Write the Code

    • Define the relay pins as OUTPUT in the setup() function.
    • Control relays using digitalWrite() in the loop().
    • Add delay() or conditions as needed for switching logic.
  3. Attach Load Devices

    • Connect each external device to its corresponding relay terminals (COM and NO/NC).
    • Ensure safety when connecting AC-powered devices.
  4. Test the Setup

    • Upload the code to Arduino.
    • Observe the switching behavior of connected devices.
    • Verify control logic by toggling pin states.

Arduino Code

1// Define the relay control pins
2int relay1 = 4;  // IN1
3int relay2 = 5;  // IN2
4int relay3 = 6;  // IN3
5int relay4 = 7;  // IN4
6
7void setup() {
8  // Set all relay pins as OUTPUT
9  pinMode(relay1, OUTPUT);
10  pinMode(relay2, OUTPUT);
11  pinMode(relay3, OUTPUT);
12  pinMode(relay4, OUTPUT);
13
14  Serial.begin(9600);  // Start serial communication (optional)
15
16  // Initialize all relays as OFF
17  digitalWrite(relay1, LOW);  // LOW may be OFF or ON depending on relay type
18  digitalWrite(relay2, LOW);
19  digitalWrite(relay3, LOW);
20  digitalWrite(relay4, LOW);
21}
22
23void loop() {
24  // Relay 1 ON
25  digitalWrite(relay1, HIGH);
26  Serial.println("Relay 1 ON");
27  delay(1000);
28
29  // Relay 2 ON
30  digitalWrite(relay2, HIGH);
31  Serial.println("Relay 2 ON");
32  delay(1000);
33
34  // Relay 3 ON
35  digitalWrite(relay3, HIGH);
36  Serial.println("Relay 3 ON");
37  delay(1000);
38
39  // Relay 4 ON
40  digitalWrite(relay4, HIGH);
41  Serial.println("Relay 4 ON");
42  delay(1000);
43
44  // Turn all OFF after a while
45  digitalWrite(relay1, LOW);
46  digitalWrite(relay2, LOW);
47  digitalWrite(relay3, LOW);
48  digitalWrite(relay4, LOW);
49  Serial.println("All Relays OFF");
50  delay(2000);
51}
52

Applications of 4 Channel Relay Modules

  • Home automation (lights, fans, alarms)
  • Industrial automation systems
  • Smart agriculture control units
  • IoT-based power control
  • Multiple motor or actuator control
  • Smart switchboards

Conclusion

By interfacing a 4 Channel Relay Module with Arduino, you gain control over multiple high-power devices using simple digital signals. This makes it an essential part of any advanced automation or IoT project.