OC
OceanRemote
Low-code IoT platform
Home > Buyer's Guides > Relay Modules for ESP32

Best Relay Modules for ESP32 & ESP8266 – Complete Buying Guide 2026

📅 Updated: April 2026 ⏱️ 12 min read 🏷️ Buying Guide, Relays, Home Automation

A relay module lets your ESP32 control high-voltage devices like lights, fans, pumps, and appliances. It's the essential component for any home automation project.

But with so many options (1-channel to 16-channel, optocoupler vs standard, 3.3V vs 5V), how do you choose? This guide covers everything you need to know to pick the perfect relay for your project.

🔌 What is a Relay Module?

A relay is an electrically operated switch. It uses a small voltage (3.3V or 5V from your ESP32) to control a much larger voltage (120V/230V AC or 12V/24V DC).

💡 Why you need a relay: Your ESP32 can't directly control high-voltage devices. Connecting a 120V light directly to an ESP32 pin would destroy the board and could cause a fire. A relay acts as a safe bridge.

How a Relay Module Works:

ESP32 GPIO (3.3V) → Optocoupler → Transistor → Relay Coil → Switch Closes → Device Turns ON
     (5mA)              (Isolates)     (Amplifies)   (80mA)      (Contacts)     (Lamp/Fan)
                

📊 Types of Relay Modules

1-Channel Relay

$3-6

Controls 1 device. Perfect for simple projects like a single light or fan.

Best for: Beginners

2-Channel Relay

$5-8

Controls 2 devices. Great for controlling a light and fan together.

Best for: Small projects

4-Channel Relay

$8-12

Controls 4 devices. Ideal for room automation (lights, fan, TV, AC).

Best for: Room automation

8-Channel Relay

$12-18

Controls 8 devices. Perfect for whole-home automation or industrial control.

Best for: Whole home

16-Channel Relay

$20-30

Controls 16 devices. For large installations and professional systems.

Best for: Professional

Solid State Relay (SSR)

$8-15

No moving parts, silent operation, faster switching. Best for lights and heating elements.

Best for: Silent operation

📋 Relay Module Comparison

Feature 1-Channel 2-Channel 4-Channel 8-Channel SSR
Price$3-6$5-8$8-12$12-18$8-15
GPIO Pins Needed12481
Max Switching10A 250V10A 250V10A 250V10A 250V2A 250V
Optocoupler✓ Yes✓ Yes✓ Yes✓ Yes✓ Built-in
NoiseClickClickClickClickSilent
Switching Speed10ms10ms10ms10ms1ms
Best For1 device2 devicesRoomHouseLights/Heaters

🏆 Top Relay Module Picks by Use Case

💰 BEST BUDGET

Songhe 1-Channel Relay Module

$2.99 on Amazon / $1.50 on AliExpress
  • ✓ Cheapest reliable option
  • ✓ Optocoupler isolation
  • ✓ 10A 250V AC rating
  • ✓ Great for learning
Best for: Beginners, single-device projects
⚡ BEST FOR ESP32

KEYES 8-Channel 5V Relay Module

$15.99 on Amazon / $12 on AliExpress
  • ✓ Works perfectly with 3.3V logic (ESP32)
  • ✓ Active LOW triggers (ESP32-friendly)
  • ✓ Individual LED indicators
  • ✓ Screw terminals for easy wiring
Best for: ESP32 multi-device control
🔇 BEST SILENT

FOTEK Solid State Relay (SSR-25DA)

$12-15
  • ✓ No clicking sound
  • ✓ Faster switching (1ms vs 10ms)
  • ✓ Longer lifespan (no mechanical wear)
  • ✓ 25A 380V AC rating
Best for: Bedroom lights, music studios, frequent switching
🏭 BEST INDUSTRIAL

SainSmart 16-Channel Relay Module

$28-35
  • ✓ 16 channels for large installations
  • ✓ Advanced-grade components
  • ✓ 30A rating per channel
  • ✓ RS232/485 option available
Best for: Commercial/industrial control panels

✅ How to Choose the Right Relay Module

1️⃣ How many devices do you want to control?

  • 1 device → 1-channel relay
  • 2-4 devices → 2 or 4-channel relay
  • 5-8 devices → 8-channel relay
  • 9+ devices → 16-channel or multiple modules

2️⃣ What voltage are you switching?

  • 120V/230V AC (household) → Standard mechanical relay (10A rating)
  • 12V/24V DC (automotive) → DC relay or standard relay
  • Low voltage signals → Reed relay or optocoupler

3️⃣ Do you need silent operation?

  • Yes (bedroom, studio) → Solid State Relay (SSR)
  • No (garage, workshop) → Mechanical relay (cheaper)

4️⃣ What's your ESP32's logic voltage?

  • ESP32 (3.3V) → Look for "active LOW" or "3.3V compatible"
  • ESP8266 (3.3V) → Same as ESP32, use active LOW
  • Arduino Uno (5V) → Any 5V relay works
⚠️ IMPORTANT: Many relay modules are designed for 5V logic. ESP32 uses 3.3V. Buy modules labeled "3.3V compatible" or use "active LOW" mode.

🔧 Wiring Guide for ESP32/ESP8266

Basic Wiring (1-Channel Relay)

Relay Module          ESP32/ESP8266
============          =============
VCC (5V)      →       5V or VIN pin
GND           →       GND
IN (Signal)   →       GPIO pin (e.g., GPIO 18)

High Voltage Side (AC):
COM           →       Live wire IN
NO (Normally Open)  → Live wire to device
NC (Normally Closed) → Not used (or for reverse logic)

ESP32-Specific Wiring Tips:

  • Use GPIO 18, 19, 21, 22, 23, 25, 26, 27 for relays (avoid GPIO 0, 2, 12, 15 - they have boot functions)
  • Some relays need external 5V power if ESP32's 5V pin can't supply enough current for multiple relays
  • For 8+ channels, use a separate 5V power supply (2A or more)

Sample Code (OceanRemote - 4-Channel)

#include <OceanRemote.h>

const char* token = "YOUR_DEVICE_TOKEN";
OceanRemote device(token);

// Relay pins
const int RELAY1 = 18;
const int RELAY2 = 19;
const int RELAY3 = 21;
const int RELAY4 = 22;

void setup() {
    pinMode(RELAY1, OUTPUT);
    pinMode(RELAY2, OUTPUT);
    pinMode(RELAY3, OUTPUT);
    pinMode(RELAY4, OUTPUT);
    
    // Start with all relays OFF
    digitalWrite(RELAY1, LOW);
    digitalWrite(RELAY2, LOW);
    digitalWrite(RELAY3, LOW);
    digitalWrite(RELAY4, LOW);
    
    device.begin();
}

void loop() {
    device.update();
    
    digitalWrite(RELAY1, device.relay1() ? HIGH : LOW);
    digitalWrite(RELAY2, device.relay2() ? HIGH : LOW);
    digitalWrite(RELAY3, device.relay3() ? HIGH : LOW);
    digitalWrite(RELAY4, device.relay4() ? HIGH : LOW);
}

⚠️ Safety First! Critical Guidelines

Before you start:

  • 🔴 Always disconnect power before wiring AC devices
  • 🔴 Use insulated tools when working with 120V/230V
  • 🔴 Keep relay modules in enclosed boxes - no exposed live terminals
  • 🔴 Use correct wire gauge (18 AWG for 10A, 14 AWG for 15A)
  • 🔴 Add a fuse (5A or 10A) on the live wire for protection
  • 🔴 Never exceed the relay's current rating (usually 10A)
  • 🔴 For motors/pumps, add a snubber circuit or use a relay with higher rating
⚠️ WARNING: Working with household AC (120V/230V) is DANGEROUS. If you're not experienced, use pre-certified smart plugs instead. OceanRemote works with many commercial smart plugs!

🛒 Where to Buy Relay Modules

Amazon (Fastest)

2-5 day delivery

Best for: Speed

AliExpress (Cheapest)

2-4 week delivery

  • 1-channel: $1.50-3
  • 4-channel: $5-8
  • 8-channel: $10-14
Best for: Bulk orders

eBay (Good balance)

1-3 week delivery

  • Similar prices to AliExpress
  • Often US/UK sellers available
Best for: Budget + faster than AliExpress

❓ Frequently Asked Questions

Can I use a 5V relay with ESP32's 3.3V output?

Yes, but with caution! Most 5V relays will work with ESP32's 3.3V if you use active LOW mode. Set the relay pin to LOW to activate instead of HIGH. For reliable operation, buy relays labeled "3.3V compatible" or use a logic level shifter.

What's the difference between NO and NC?

NO (Normally Open) - Relay is OFF by default, closes when activated. Use for most applications (lights, fans).
NC (Normally Closed) - Relay is ON by default, opens when activated. Use for safety systems (e.g., pump that should run unless ESP32 says stop).

How many relays can an ESP32 control?

The ESP32 has ~25 usable GPIO pins. You can theoretically control 25 relays. However, power becomes an issue - each relay draws ~80mA when active. Use external 5V power for 4+ relays.

Do I need optocoupler isolation?

YES! Always buy optocoupler-isolated relays. They protect your ESP32 from voltage spikes and back-EMF from inductive loads (motors, pumps, solenoids). Non-isolated relays are dangerous and not recommended.

Can I use a relay to control a 3.3V device?

Yes, relays work with any voltage up to their rating. You can control 5V, 12V, 24V DC devices as easily as 120V AC lights. Just wire the DC voltage through the relay contacts.

How do I know if my relay is active HIGH or LOW?

Most relays have a jumper or switch. Check the module - "HIGH" or "1" means active HIGH (send 3.3V/5V to activate). "LOW" or "0" means active LOW (send 0V to activate). For ESP32, active LOW is more reliable.

Ready to Start Your Project?

Generate ESP32 firmware with relay control in minutes - no coding required!