ESP32 C3 Super Mini - 4-Channel Relay Module

Learn how to control multiple high-voltage devices using an ESP32 C3 Super Mini and a 4-channel relay module. This beginner-friendly tutorial shows you how to control pumps, fans, lights, and other appliances with your ESP32.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - 4-Channel Relay Module

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×4-Channel Relay Module
1×Breadboard
1×Jumper Wires
1×Optionally, 5V Power Adapter for ESP32 C3 Super Mini

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of 4-Channel Relay Module

A 4-channel relay module is a control board that contains four independent relays for switching high-voltage devices.

  • Key Features:
    • Controls up to four separate high-voltage devices (AC or DC)
    • Each relay can handle loads up to 10A at 250VAC or 30VDC (typical)
    • Operates with 5V logic signals from microcontrollers
    • Onboard LED indicators show relay status
    • Optocoupler isolation protects your ESP32 C3 Super Mini
    • Configurable trigger modes (high/low) via jumpers
  • Why Use It:
    • Simplifies wiring compared to using four separate relay modules
    • Cost-effective solution for multi-device control
    • Perfect for home automation and IoT projects
    • Beginner-friendly with clear pin labels

    The 4-Channel Relay Module Pinout

    The pinout shows all connection points on the 4-channel relay module.

    4-Channel Relay Module pinout

    Power Pins:

    • DC+: Connect to 5V power supply (external adapter recommended)
    • DC-: Connect to GND of power supply and ESP32 C3 Super Mini GND

    Signal Pins (Control):

    • IN1: Control signal from ESP32 for relay 1
    • IN2: Control signal from ESP32 for relay 2
    • IN3: Control signal from ESP32 for relay 3
    • IN4: Control signal from ESP32 for relay 4

    Output Pins (High-Voltage Connections):

    • NC1, NO1, COM1: Relay 1 output (Normally Closed, Normally Open, Common)
    • NC2, NO2, COM2: Relay 2 output (Normally Closed, Normally Open, Common)
    • NC3, NO3, COM3: Relay 3 output (Normally Closed, Normally Open, Common)
    • NC4, NO4, COM4: Relay 4 output (Normally Closed, Normally Open, Common)

    To learn about connecting a relay to high-voltage devices and understanding the distinctions between normally closed and normally open, check out the ESP32 C3 Super Mini - Relay tutorial.

    Additionally, the tutorial covers the 4 jumpers available on the relay module, which enable you to individually select between low trigger and high trigger settings for each relay.

Wiring Diagram

Follow this wiring guide to connect your ESP32 C3 Super Mini to the 4-channel relay module.

  • Important Safety Notes:
    • Never power the 4-channel relay module directly from the ESP32 5V pin - it draws too much current
    • Always use an external 5V power supply for the relay module
    • Double-check all high-voltage connections before applying power
    • Keep high-voltage wiring separate from low-voltage control wiring

    Power Supply Configuration:

    You'll need multiple power sources for this project:

    • 5V power adapter for the ESP32 C3 Super Mini (via USB or power jack)
    • 5V power adapter for the 4-channel relay module
    • High-voltage power source (12VDC, 24VDC, 120VAC, 220VAC, etc.) for the controlled devices

    Wiring Diagram (Three Power Sources):

    The wiring diagram between ESP32 C3 Super Mini 4-channel relay module

    This image is created using Fritzing. Click to enlarge image

    4-Channel Relay Module ESP32 C3 Super Mini
    DC+ External 5V Power Supply (+)
    DC- External 5V Power Supply (-) AND ESP32 GND
    IN1 GPIO2
    IN2 GPIO3
    IN3 GPIO4
    IN4 GPIO5

    Simplified Wiring (Two Power Sources):

    You can reduce the number of adapters by using one 5V power source for both the ESP32 C3 Super Mini and the 4-channel relay module:

    The wiring diagram between ESP32 C3 Super Mini 4-channel relay module  two power source

    This image is created using Fritzing. Click to enlarge image

    ※ NOTE THAT:

    If the four devices that are managed by a 4-channel relay module have the same voltage, then one high-voltage power adapter can be used for all of them. However, if the voltage is different for each device, then separate high-voltage power adapters must be used.

How To Program For 4-Channel Relay Module

Programming the ESP32 C3 Super Mini to control a 4-channel relay module is straightforward and uses basic digital output commands.

The code performs these tasks:

  • Configures ESP32 pins as digital outputs for relay control
  • Turns all four relays ON and OFF in sequence
  • Provides serial feedback for monitoring relay states
  • Creates a 2-second delay between state changes

Set pins to output mode:

pinMode(PIN_RELAY_1, OUTPUT); pinMode(PIN_RELAY_2, OUTPUT); pinMode(PIN_RELAY_3, OUTPUT); pinMode(PIN_RELAY_4, OUTPUT);

Control relay states:

digitalWrite(PIN_RELAY_1, HIGH); digitalWrite(PIN_RELAY_2, HIGH); digitalWrite(PIN_RELAY_3, HIGH); digitalWrite(PIN_RELAY_4, HIGH);

ESP32 C3 Super Mini Code

/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-4-channel-relay-module */ #define PIN_RELAY_1 2 // The ESP32 C3 SuperMini pin GPIO2 connected to the IN1 pin of relay module #define PIN_RELAY_2 3 // The ESP32 C3 SuperMini pin GPIO3 connected to the IN2 pin of relay module #define PIN_RELAY_3 4 // The ESP32 C3 SuperMini pin GPIO4 connected to the IN3 pin of relay module #define PIN_RELAY_4 5 // The ESP32 C3 SuperMini pin GPIO5 connected to the IN4 pin of relay module // The setup function runs once on reset or power-up void setup() { Serial.begin(115200); // initialize digital pin as an output. pinMode(PIN_RELAY_1, OUTPUT); pinMode(PIN_RELAY_2, OUTPUT); pinMode(PIN_RELAY_3, OUTPUT); pinMode(PIN_RELAY_4, OUTPUT); } // The loop function repeats indefinitely void loop() { Serial.println("Turn on all"); digitalWrite(PIN_RELAY_1, HIGH); digitalWrite(PIN_RELAY_2, HIGH); digitalWrite(PIN_RELAY_3, HIGH); digitalWrite(PIN_RELAY_4, HIGH); delay(2000); Serial.println("Turn off all"); digitalWrite(PIN_RELAY_1, LOW); digitalWrite(PIN_RELAY_2, LOW); digitalWrite(PIN_RELAY_3, LOW); digitalWrite(PIN_RELAY_4, LOW); delay(2000); }

Detailed Instructions

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Check Environment Setup: If this is your first time using ESP32 C3 Super Mini, follow the software installation tutorial
  • Wire the Components: Connect the ESP32 C3 Super Mini and 4-channel relay module according to the wiring diagram above
  • Connect ESP32: Plug the ESP32 C3 Super Mini into your computer using a USB Type-C cable
  • Open Arduino IDE: Launch the Arduino IDE software on your computer
  • Select Board and Port: Choose ESP32 C3 Super Mini and select the correct COM port
  • Copy the Code: Copy the provided code and paste it into Arduino IDE
  • Upload the Code: Click the Upload button to transfer the code to your ESP32 C3 Super Mini
  • Listen for Clicks: You should hear the relays clicking as they switch ON and OFF
  • Check Serial Monitor: Open the Serial Monitor (baud rate 115200) to view the relay status messages
  • Pro Tip: Label each relay and its controlled device to avoid confusion when building larger projects

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Turn on all Turn off all Turn on all Turn off all Turn on all Turn off all Turn on all Turn off all Turn on all Turn off all
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Applications and Project Ideas

Use your ESP32 C3 Super Mini with a 4-channel relay module to build these practical projects:

  • Home Automation System: Control lights, fans, heaters, and appliances remotely
  • Greenhouse Controller: Automate irrigation pumps, grow lights, ventilation fans, and heating systems
  • Aquarium Manager: Control filter pumps, air pumps, lights, and heaters on schedules
  • Smart Garage: Operate door opener, lights, ventilation fan, and security system
  • Tutorial Automation: Control power tools, dust collection, lighting, and equipment
  • Energy Management: Schedule high-power devices to run during off-peak hours

Video Tutorial

Watch the video below for a visual walkthrough of this project.

Challenge Yourself

Take your ESP32 C3 Super Mini 4-channel relay skills to the next level with these challenges:

  • Easy: Modify the code to control each relay independently with different timing patterns
  • Easy: Add button inputs to manually control each relay channel
  • Medium: Create a web interface to control all four relays from your smartphone
  • Medium: Implement scheduled automation (turn relays ON/OFF at specific times)
  • Advanced: Build a voice-controlled system using MQTT and Alexa or Google Home integration
  • Advanced: Add current sensors to monitor power consumption of each controlled device

Function References

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!