The 2-Channel 5V Relay Module with Optocoupler Isolation is a versatile switching board that lets you control high-voltage or high-current devices — such as lamps, fans, heaters, solenoid locks, and motors — from a low-voltage microcontroller like an Arduino, ESP32, or Raspberry Pi. Each channel uses an SPDT (Single Pole Double Throw) relay rated for up to 250V AC / 10A or 30V DC / 10A, and the onboard optocouplers electrically isolate the relay coil circuit from your microcontroller for added safety and noise protection.
This version of the module features a 4-pin input header (GND, IN1, IN2, VCC) and a JD-VCC jumper that controls whether the relay coil power is shared with or isolated from the logic input power. The relays are active-LOW — meaning they turn ON when the input signal is pulled LOW.
⚠️ Important: This module can switch mains voltage (up to 250V AC). High-voltage wiring is dangerous and can cause serious injury or death. If you are not experienced with mains wiring, consult a qualified electrician. Always disconnect mains power before making any wiring changes to the relay output terminals.
⭐ Key Features
- 2 independent relay channels — each with its own optocoupler-isolated input
- SPDT relay contacts — each relay provides COM (Common), NO (Normally Open), and NC (Normally Closed) terminals
- Relay contact rating — 250V AC / 10A or 30V DC / 10A per channel
- Optocoupler isolation — electrically separates the microcontroller from the relay coil circuit, preventing ground loops and protecting sensitive electronics
- JD-VCC jumper — allows you to power the relay coils from a separate 5V supply for full electrical isolation, or share power with the logic side for simpler wiring
- Active-LOW trigger — relay activates when the input pin is pulled LOW (15–20 mA drive current per channel)
- LED status indicators — one LED per channel shows relay activation state
- 4-pin input header — GND, IN1, IN2, VCC (2.54mm pitch) for easy connection to microcontrollers
- Screw terminals — for secure high-voltage / high-current output connections
- Compatible with 5V and 3.3V logic — 3.3V logic supported when JD-VCC jumper is removed and relay coils are powered separately
📋 How It Works
A relay is an electrically operated switch. Inside each relay on this module, there is an electromagnetic coil and a set of mechanical contacts. Here's the basic operating principle:
- When the relay coil is not energized (input is HIGH or floating), the internal spring holds the moving contact against the NC (Normally Closed) terminal. Current flows between COM and NC.
- When you pull the input pin LOW, current flows through the optocoupler LED, which triggers the optocoupler's phototransistor on the relay side.
- The phototransistor activates a transistor driver that energizes the relay coil, creating an electromagnetic field.
- The electromagnetic field pulls the armature (moving contact) away from NC and connects it to the NO (Normally Open) terminal. Current now flows between COM and NO.
- When the input goes HIGH again, the coil de-energizes, the spring returns the contact to NC, and the relay "clicks" back to its resting state.
The optocoupler is the key safety feature of this module. It uses an internal LED and phototransistor pair to transmit the signal optically — meaning there is no direct electrical connection between your microcontroller and the relay coil circuit. This prevents voltage spikes from the relay coil from damaging your microcontroller, and eliminates ground loop issues in complex systems.
📌 Pinout Reference
Input Header (4-Pin, Low-Voltage Side)
| Pin | Function | Description |
|---|---|---|
| GND | Ground | Connect to microcontroller GND |
| IN1 | Relay 1 Input | Active-LOW trigger — pull LOW to activate Relay 1 |
| IN2 | Relay 2 Input | Active-LOW trigger — pull LOW to activate Relay 2 |
| VCC | Logic Power | Connect to 5V (or 3.3V if JD-VCC jumper is removed) |
JD-VCC Jumper (Between Input Header and Relay Power)
| Jumper State | Behavior |
|---|---|
| Jumper ON (default) | VCC and JD-VCC are connected — relay coils and optocoupler inputs share the same 5V supply. Simpler wiring but no electrical isolation between logic and relay sides. |
| Jumper OFF | VCC and JD-VCC are separated — you must provide a separate 5V supply to JD-VCC and GND (relay side). The optocoupler input side (VCC) can then run at 3.3V or 5V from your microcontroller. This provides full electrical isolation. |
Relay Output Terminals (High-Voltage Side) — Per Channel
| Terminal | Name | Description |
|---|---|---|
| COM | Common | The shared terminal — connect your load's power line here |
| NO | Normally Open | Disconnected from COM when relay is OFF; connected when relay is ON |
| NC | Normally Closed | Connected to COM when relay is OFF; disconnected when relay is ON |
💡 Tip: Use NO (Normally Open) when you want the device to be OFF by default and turn ON when the relay activates. Use NC (Normally Closed) when you want the device to be ON by default and turn OFF when the relay activates.
🔧 Understanding the JD-VCC Jumper
The JD-VCC jumper is what makes this module more versatile than basic relay boards without optocouplers. Understanding it is key to getting the most out of this module.
Mode 1: Jumper ON (Non-Isolated, Simple Wiring)
With the jumper in place, the relay coils and the optocoupler input LEDs share the same 5V power supply. This is the simplest configuration — just connect VCC to your Arduino's 5V pin and GND to GND.
- ✅ Easy to wire — only 4 connections needed
- ❌ No electrical isolation — the relay coil circuit shares ground with your microcontroller
- ❌ Requires 5V logic — will not work reliably with 3.3V signals
- ⚠️ The relay coils draw significant current (~70 mA each) from your microcontroller's 5V rail, which may be a concern if powering other devices
Mode 2: Jumper OFF (Fully Isolated)
With the jumper removed, you must provide a separate 5V power supply to the JD-VCC pin and the relay-side GND. The VCC pin on the input header now only powers the optocoupler input LEDs and can be connected to 3.3V or 5V from your microcontroller.
- ✅ Full electrical isolation between microcontroller and relay coils
- ✅ Works with 3.3V logic (ESP32, Raspberry Pi, STM32, etc.)
- ✅ Relay coil current does not load your microcontroller's power supply
- ❌ Requires a separate 5V power supply for the relay side
💡 Tip: If you're using a 3.3V microcontroller like an ESP32 or Raspberry Pi, you must remove the JD-VCC jumper and provide a separate 5V supply to JD-VCC. Connect VCC on the input header to your board's 3.3V output. Some users have reported that certain relay modules may need the optocoupler input resistor (R1) changed from 1 kΩ to 220 Ω for reliable 3.3V operation.
🔌 Wiring to Arduino (Basic Setup — Jumper ON)
This is the simplest wiring configuration using the default jumper position. The relay coils are powered from the Arduino's 5V pin.
| Relay Module Pin | Arduino Pin |
|---|---|
| GND | GND |
| IN1 | Digital Pin 4 |
| IN2 | Digital Pin 5 |
| VCC | 5V |
⚠️ Important: Each relay coil draws approximately 70 mA. With both relays active, the module draws about 140 mA from the 5V rail — plus the optocoupler and LED current. If you are powering the Arduino via USB, this is generally fine. If you are powering other high-current devices from the same 5V rail, consider using Mode 2 (jumper OFF) with a separate 5V supply for the relays.
🔌 Wiring to ESP32 or Raspberry Pi (Isolated Setup — Jumper OFF)
For 3.3V microcontrollers, remove the JD-VCC jumper and provide a separate 5V supply for the relay coils.
| Relay Module Pin | Connection |
|---|---|
| GND (input header) | Microcontroller GND |
| IN1 | GPIO pin (e.g., GPIO 4) |
| IN2 | GPIO pin (e.g., GPIO 5) |
| VCC (input header) | Microcontroller 3.3V output |
| JD-VCC | External 5V power supply (+) |
| GND (relay side) | External 5V power supply (−) |
⚠️ Important: In isolated mode, the relay-side GND and the microcontroller GND should not be connected together — that's the whole point of isolation. If you connect them, you lose the isolation benefit. However, if you don't need full isolation and just want 3.3V compatibility, you can share the ground.
💻 Sample Arduino Code
This sketch alternates Relay 1 and Relay 2 on and off every 2 seconds. Remember, the relays are active-LOW — writing LOW turns the relay ON, and writing HIGH turns it OFF.
// 2-Channel Relay Module — Basic Toggle Example
// Relays are ACTIVE-LOW: LOW = ON, HIGH = OFF
const int relay1 = 4; // IN1 connected to digital pin 4
const int relay2 = 5; // IN2 connected to digital pin 5
void setup() {
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
// Start with both relays OFF (HIGH = OFF for active-low)
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
Serial.begin(9600);
Serial.println("2-Channel Relay Module Test");
}
void loop() {
// Turn Relay 1 ON
digitalWrite(relay1, LOW);
Serial.println("Relay 1: ON");
delay(2000);
// Turn Relay 1 OFF
digitalWrite(relay1, HIGH);
Serial.println("Relay 1: OFF");
delay(1000);
// Turn Relay 2 ON
digitalWrite(relay2, LOW);
Serial.println("Relay 2: ON");
delay(2000);
// Turn Relay 2 OFF
digitalWrite(relay2, HIGH);
Serial.println("Relay 2: OFF");
delay(1000);
// Turn both relays ON
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
Serial.println("Both Relays: ON");
delay(2000);
// Turn both relays OFF
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
Serial.println("Both Relays: OFF");
delay(2000);
}
💡 Tip: You'll hear a distinct "click" each time a relay activates or deactivates — that's the mechanical armature moving inside the relay. The corresponding LED on the module will also light up when the relay is active. If you don't hear the click or see the LED, double-check your wiring and make sure the input pin is being pulled LOW.
📊 Specifications
| Specification | Details |
|---|---|
| Number of Channels | 2 |
| Relay Type | SPDT (Single Pole Double Throw) |
| Relay Contact Rating (AC) | 250V AC / 10A |
| Relay Contact Rating (DC) | 30V DC / 10A |
| Coil Voltage | 5V DC |
| Coil Current (per relay) | Approx. 70 mA |
| Trigger Level | Active-LOW (LOW = relay ON) |
| Input Drive Current | 15–20 mA per channel |
| Isolation | Optocoupler (optical isolation between input and relay) |
| Input Connector | 1×4 pin header (2.54mm pitch): GND, IN1, IN2, VCC |
| Relay Power Jumper | JD-VCC jumper (connects/disconnects VCC from relay coil power) |
| Output Terminals | Screw terminals — COM, NO, NC per channel |
| Status Indicators | 1 LED per channel (lights when relay is active) |
| Logic Compatibility | 5V direct; 3.3V with JD-VCC jumper removed |
| Board Dimensions | Approx. 51 × 38 × 18 mm (2.0 x 1.5 x 0.7 inches) L × W × H |
| Mounting Holes | 4 (M3) |
🎯 Typical Applications
- Home automation — control lights, fans, appliances, and door locks from a microcontroller or smart home system
- IoT projects — remote switching via Wi-Fi (ESP32/ESP8266) or Bluetooth
- 3D printers & CNC machines — control heated beds, spindles, or cooling fans
- Robotics — switch motors, solenoids, and pneumatic valves
- Automotive — control 12V accessories like LED light bars, horns, or auxiliary equipment
- Industrial control — interface PLCs or microcontrollers with AC-powered equipment
- Aquarium / greenhouse automation — timed control of pumps, lights, heaters, and ventilation
🛠️ Troubleshooting
Relay doesn't click / LED doesn't light
- Verify the input pin is being driven LOW (not HIGH) — this is an active-LOW module
- Check that VCC is connected to 5V (or 3.3V with jumper removed) and GND is connected
- If the JD-VCC jumper is removed, make sure you have a separate 5V supply connected to JD-VCC and the relay-side GND
- Ensure your microcontroller pin can source/sink at least 15–20 mA
Relay clicks but the load doesn't switch
- Check your high-voltage wiring — make sure the load is connected between COM and NO (or COM and NC, depending on your desired behavior)
- Verify the load's power supply is connected and working
- Check the screw terminal connections — loose wires are a common issue
Relay activates on power-up / reset
- During microcontroller boot, GPIO pins may briefly float LOW, which activates the relay. To prevent this, add a 10 kΩ pull-up resistor from each input pin (IN1, IN2) to VCC. This keeps the inputs HIGH (relay OFF) until your code explicitly drives them LOW.
- In your
setup()function, set the relay pins HIGH before setting them as outputs:digitalWrite(relay1, HIGH); // Set HIGH first pinMode(relay1, OUTPUT); // Then set as output
Erratic behavior or microcontroller resets when relay switches
- This is usually caused by electrical noise from the relay coil. Remove the JD-VCC jumper and use a separate 5V power supply for the relay coils (Mode 2) to fully isolate the relay circuit from your microcontroller.
- Add a decoupling capacitor (100 µF electrolytic + 100 nF ceramic) across your microcontroller's power pins
3.3V microcontroller can't reliably trigger the relay
- Make sure the JD-VCC jumper is removed and a separate 5V supply powers JD-VCC
- Connect VCC on the input header to your microcontroller's 3.3V output
- If the relay still doesn't trigger reliably, the onboard optocoupler input resistor (typically 1 kΩ) may need to be replaced with a lower value (e.g., 220 Ω) to allow enough current through the optocoupler LED at 3.3V
⚠️ Important Safety Notes
- Mains voltage is dangerous. If you are switching AC mains (110V/220V), ensure all high-voltage wiring is properly insulated and enclosed. Never touch exposed terminals or wires when the circuit is energized.
- Do not exceed the relay's rated current. The relays are rated for 10A, but for continuous loads, it's good practice to derate to 7–8A to extend relay life and reduce heat buildup.
- Inductive loads (motors, solenoids, transformers) generate voltage spikes when switched. Consider adding a flyback diode (for DC loads) or a snubber circuit (for AC loads) across the load to protect the relay contacts.
- Do not switch the relay rapidly. Mechanical relays have a limited switching life (typically 100,000 cycles). For high-frequency switching, consider a solid-state relay (SSR) instead.
- Keep high-voltage and low-voltage wiring separated on your project board to prevent accidental contact.
- This module is not UL/CE certified for use in permanent mains installations. It is intended for prototyping, hobby, and educational use.
🏪 Where to Buy the 2-Channel 5V Relay Module with Optocoupler
This 2-Channel 5V Relay Module with Optocoupler can be purchased at the Envistia Mall website:
Buy the 2-Channel 5V Relay Module with Optocoupler →
- 📦 Fast US Shipping
- 🔄 Hassle-Free Returns
- 📧 Responsive Customer Support
📚 Resources & Downloads
- Arduino Language Reference: digitalWrite() Reference
This guide is provided by Envistia Mall for educational and technical reference purposes. The manufacturer and Envistia LLC (dba Envistia Mall) are not responsible for any damages or losses resulting from the use of this product. Always follow proper electrical safety practices when working with electronic components. This module switches high-voltage loads — exercise extreme caution when wiring AC mains circuits. Specifications are based on manufacturer data and are subject to change without notice.