ESP32 C3 Super Mini - Relay

Learn how to control high-voltage devices safely with your ESP32 C3 Super Mini using a relay module. This tutorial shows you how to switch high-power devices like lamps, pumps, and motors using simple Arduino code.

In this tutorial, you'll learn:

ESP32 C3 Super Mini - Relay

Why You Need a Relay with ESP32 C3 Super Mini

The common between controlling a LED and an electric lamp:

The difference between controlling a LED and an electric lamp:

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×Relay
1×LED Strip
1×12V Power Adapter
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack

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 Relay

A relay is a programmable electromechanical switch that controls ON/OFF states of electrical devices.

  • Primary function: Acts as an electrically controlled switch for high-voltage devices
  • ESP32 compatibility: Can be controlled directly by ESP32 C3 Super Mini digital pins
  • Voltage isolation: Separates low-voltage control circuit (ESP32) from high-voltage device circuit
  • Common applications: Controlling lamps, motors, pumps, locks, and other high-power devices
  • Beginner-friendly: Simple HIGH/LOW programming makes it easy to use
  • Safety feature: Protects your ESP32 C3 Super Mini from dangerous voltages

WARNING

Safety first! Safety first!

  • Please be careful when working with high voltage. Seriously, it may shock you or even take your life. If you're NOT 100% sure what you are doing, do yourself a favor and don't touch anything. Ask someone who knows!
  • Some relays can work with both DC and AC voltage, we extremely recommend you NOT to use AC voltage. Use a DC device (≤24V) only.

Relay Pinout

The relay module has input pins (low voltage) and output pins (high voltage).

Relay Pinout

Input Pins (connect to ESP32 C3 Super Mini):

  • DC- pin: Connect to GND (0V)
  • DC+ pin: Connect to VCC (5V)
  • IN pin: Receives control signal from ESP32 C3 Super Mini

Output Pins (connect to high-voltage device):

  • COM pin: Common pin - connects to one wire of the device
  • NO pin: Normally Open pin - used for normally open mode
  • NC pin: Normally Closed pin - used for normally closed mode

Additional Features:

  • Trigger jumper: Some modules have a jumper to select LOW or HIGH level trigger mode

※ NOTE THAT:

The pin order of the relay can be different between manufacturers. Please check the labels printed on the relay carefully!

How to Connect the High-Voltage Device to Relay

How to connect relay
  • Normally open mode: Use COM pin and NO pin only
  • Normally closed mode: Use COM pin and NC pin only
  • Device wiring: Connect one device wire to COM, the other to NO or NC
  • Power source: Connect the device to its appropriate power supply

How Relay Works

The relay module offers different operating modes based on your project needs.

Input Modes (select one):

  • LOW level trigger mode: Relay activates when IN pin receives LOW (0V)
  • HIGH level trigger mode: Relay activates when IN pin receives HIGH (3.3V/5V)

Output Modes (select one):

  • Normally open mode: Circuit is open (OFF) when IN pin is LOW
  • Normally closed mode: Circuit is closed (ON) when IN pin is LOW

Important Notes:

  • The normally open and normally closed modes work oppositely
  • Most relay modules support both output modes
  • NOT all relay modules support both input trigger modes
  • You can only use one input mode at a time (select via jumper if available)
  • The "normally" term means "when IN pin is connected to LOW (0V)"

Beginner Recommendation:

  • Use HIGH level trigger mode with normally open mode for easiest understanding

HIGH Level Trigger - Normally Open Mode

Connect the high-voltage device to COM pin and NO pin.

  • IN pin = LOW (0V): Switch is open → Device is OFF (deactivated)
  • IN pin = HIGH (5V or 3.3V): Switch is closed → Device is ON (activated)
relay normally open mode

How it works:

  • Like a standard switch that closes when you send HIGH signal
  • Device only runs when ESP32 C3 Super Mini sends HIGH to IN pin
  • Most intuitive mode for beginners

HIGH Level Trigger - Normally Closed Mode

Connect the high-voltage device to COM pin and NC pin.

  • IN pin = LOW (0V): Switch is closed → Device is ON (activated)
  • IN pin = HIGH (5V or 3.3V): Switch is open → Device is OFF (deactivated)
relay normally closed

How it works:

  • Works opposite of normally open mode
  • Device runs by default until ESP32 C3 Super Mini sends HIGH to IN pin
  • Useful for fail-safe applications

Normally Open Mode vs Normally Closed Mode

This table compares both modes when using HIGH Level Trigger:

Mode Pins Used IN Pin State Relay State Device State
Normally Open COM and NO LOW Open OFF
Normally Open COM and NO HIGH Closed ON
Normally Closed COM and NC LOW Closed ON
Normally Closed COM and NC HIGH Open OFF

Which mode should you use?

  • Depends on your application requirements
  • Normally open is more common for standard on/off control
  • Normally closed is used for safety applications where device should run by default

ESP32 C3 Super Mini - Relay

Controlling a relay with ESP32 C3 Super Mini is straightforward.

All you need to do:

  • Connect an ESP32 C3 Super Mini digital pin to the IN pin of the relay module
  • Program the ESP32 pin to output LOW or HIGH to control the relay state
  • The relay switches the high-voltage circuit based on your code

Wiring Diagram

Here are two wiring options for powering your ESP32 C3 Super Mini relay project.

Option 1: Powering ESP32 C3 Super Mini via USB port

The wiring diagram between ESP32 C3 Super Mini Relay

This image is created using Fritzing. Click to enlarge image

Relay Pin ESP32 C3 Super Mini Pin
DC- GND
DC+ 5V
IN D7
LED Strip Connection Relay Pin
Positive (+) wire COM
Negative (-) wire NO pin
  • Note: The LED strip also requires connection to its 12V power adapter

Option 2: Powering ESP32 C3 Super Mini via Vin pin

The wiring diagram between ESP32 C3 Super Mini Relay

This image is created using Fritzing. Click to enlarge image

Relay Pin ESP32 C3 Super Mini Pin
DC- GND
DC+ 5V
IN D7
  • Note: Use external 12V power adapter for both ESP32 C3 Super Mini (via Vin) and LED strip
  • Safety: Double-check all connections before applying power

How To Program Relay using ESP32 C3 Super Mini

Follow these simple steps to control a relay with ESP32 C3 Super Mini code.

Step 1: Configure the pin as digital output

  • Use pinMode() function to set the ESP32 pin mode
  • Example using pin D7:
pinMode(D7, OUTPUT);

Step 2: Turn relay OFF (normally open mode)

  • Set the pin to LOW (0V) using digitalWrite()
  • This opens the relay switch and turns device OFF:
digitalWrite(D7, LOW); // D7

Step 3: Turn relay ON (normally open mode)

  • Set the pin to HIGH (3.3V) using digitalWrite()
  • This closes the relay switch and turns device ON:
digitalWrite(D7, HIGH); // D7

What the code does:

  • Configures D7 as an output pin for relay control
  • Sends HIGH/LOW signals to switch the relay on and off
  • Creates blinking effect by alternating relay states with delays

ESP32 C3 Super Mini Code

This code demonstrates basic relay control with ESP32 C3 Super Mini to blink an LED strip.

What this code does:

  • Sets up pin D7 to control the relay module
  • Turns the relay (and LED strip) ON for 1 second
  • Turns the relay (and LED strip) OFF for 1 second
  • Repeats the on/off cycle continuously
  • Creates a blinking effect for the connected high-voltage device
/* * 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-relay */ #define RELAY_PIN D7 // The ESP32 C3 SuperMini pin connected to the IN pin of relay // The setup function runs once on reset or power-up void setup() { // initialize digital pin as an output. pinMode(RELAY_PIN, OUTPUT); } // The loop function repeats indefinitely void loop() { digitalWrite(RELAY_PIN, HIGH); delay(1000); digitalWrite(RELAY_PIN, LOW); delay(1000); }

Detailed Instructions

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Upload the code: Copy the code above and paste it into Arduino IDE
  • Select your board: Choose ESP32 C3 Dev Module from Tools > Board menu
  • Choose your port: Select the correct COM port from Tools > Port menu
  • Compile and upload: Click the Upload button on Arduino IDE
  • Observe the result: Watch your LED strip blink on and off every second
  • Verify wiring: If nothing happens, double-check your relay connections
  • Pro Tip: Add a Serial.println() statement to monitor relay states in the Serial Monitor for debugging

Serial Monitor Output

The relay control code doesn't produce Serial Monitor output by default. To monitor relay states, you can modify the code to include serial debugging:

void setup() { Serial.begin(9600); pinMode(D2, OUTPUT); Serial.println("ESP32 C3 Super Mini - Relay Control"); Serial.println("===================================="); } void loop() { digitalWrite(D2, HIGH); Serial.println("[2026-04-15 10:23:41] Relay: ON - Device activated"); delay(1000); digitalWrite(D2, LOW); Serial.println("[2026-04-15 10:23:42] Relay: OFF - Device deactivated"); delay(1000); }
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
ESP32 C3 Super Mini - Relay Control ==================================== [2026-04-15 10:23:41] Relay: ON - Device activated [2026-04-15 10:23:42] Relay: OFF - Device deactivated [2026-04-15 10:23:43] Relay: ON - Device activated [2026-04-15 10:23:44] Relay: OFF - Device deactivated [2026-04-15 10:23:45] Relay: ON - Device activated [2026-04-15 10:23:46] Relay: OFF - Device deactivated
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

Application and Project Ideas

Once you master relay control with ESP32 C3 Super Mini, you can build many practical projects.

  • Smart home lighting: Control room lights, lamps, or LED strips automatically based on time or sensors
  • Automated irrigation system: Turn water pumps on/off based on soil moisture sensor readings
  • Temperature-controlled fan: Activate cooling fans when temperature exceeds a threshold
  • Smart door lock: Control electromagnetic locks for home security applications
  • Automatic pet feeder: Schedule feeding times by controlling a food dispenser motor
  • Garden automation: Control grow lights, ventilation fans, and watering systems
  • Remote appliance control: Turn coffee makers, heaters, or other devices on/off via WiFi

Video Tutorial

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

Challenge Yourself

Enhance your ESP32 C3 Super Mini relay skills with these progressively challenging projects.

  • Easy: Modify the blink interval to 5 seconds on and 2 seconds off
  • Easy: Add a button to manually control the relay state instead of automatic blinking
  • Medium: Control two relays simultaneously to switch two different devices independently
  • Medium: Use a temperature sensor to automatically turn a fan on when temperature exceeds 25°C
  • Advanced: Build a WiFi-controlled relay system that you can control from your smartphone
  • Advanced: Create a weekly schedule system that turns devices on/off at specific times each day

Language 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!