Dual Channel Relay Module Raspberry Pi

Dual Channel Relay Module Raspberry Pi

1. Introduction

A dual channel relay module allows the Raspberry Pi to control two high-voltage devices independently. It is widely used in home automation, IoT, and industrial control systems where multiple loads need switching.


2. Components

  • Raspberry Pi 4 Model B
  • Dual Channel Relay Module
  • Jumper wires
  • Breadboard (optional)
  • Loads (Bulb, Fan, etc.)

3. Circuit and Connections

Raspberry Pi Connection
Raspberry Pi Pinout Diagram
Dual Channel Relay Module Pinout Diagram
Dual Channel Relay Module Pinout Diagram

Relay Module to Raspberry Pi

Relay PinRaspberry Pi
VCC5V
GNDGND
IN1GPIO17
IN2GPIO27

Relay Output Connections

Relay ChannelTerminals   Connection
Relay 1COM, NO, NC     NC Device 1
Relay 2COM, NO, NC     NC Device 2

4. Detailed Step By Step Circuit Working

  1. Raspberry Pi sends control signals to IN1 and IN2.
  2. Each relay has its own electromagnetic coil.
  3. When activated, the relay switches from NO to COM.
  4. Two devices can be controlled independently.
  5. Provides electrical isolation for safety.

5. Libraries to be Included

pip3 install RPi.GPIO

6. Code (Python)

import RPi.GPIO as GPIO
import time

relay1 = 17
relay2 = 27

GPIO.setmode(GPIO.BCM)
GPIO.setup(relay1, GPIO.OUT)
GPIO.setup(relay2, GPIO.OUT)

try:
while True:
GPIO.output(relay1, GPIO.HIGH)
GPIO.output(relay2, GPIO.LOW)
print("Relay1 ON, Relay2 OFF")
time.sleep(2)

GPIO.output(relay1, GPIO.LOW)
GPIO.output(relay2, GPIO.HIGH)
print("Relay1 OFF, Relay2 ON")
time.sleep(2)

except KeyboardInterrupt:
GPIO.cleanup()

7. Detailed Step By Step Code Working

  • GPIO.setup() → Configures relay pins as output
  • GPIO.output(relay1, HIGH) → Turns ON relay 1
  • GPIO.output(relay2, HIGH) → Turns ON relay 2
  • Each relay works independently
  • Loop alternates switching

⚠️ Note: Some modules are active LOW (reverse logic)


8. Tips

  • Always check relay logic (LOW trigger / HIGH trigger)
  • Use separate power if relay causes Pi reset
  • Avoid loose AC wiring
  • Use opto-isolated relay modules for safety
  • Label connections clearly

9. Uses

  • Home automation (2 devices control)
  • Smart lighting systems
  • Industrial automation
  • IoT switching systems
  • Appliance control

10. Conclusion

Dual channel relay modules are perfect for controlling multiple high-power devices using Raspberry Pi. They are easy to use, reliable, and essential for automation projects. 

തുടക്കക്കാർക്കായുള്ള ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.