ESP32 S3 UNO - 2-Channel Relay Module
This ESP32 S3 Uno 2-channel relay module tutorial shows you how to switch two high-voltage loads from one ESP32 S3 Uno form board. You will see the two-channel relay pinout, a safe wiring and power setup, and a short Arduino IDE sketch. When you are done, both relays click on and off under the control of your code.
In this tutorial, you will:
- Learn the pinout of a two-channel relay module
- Wire the relay module to the board with a safe power setup
- Write Arduino code that turns two relays on and off with digitalWrite()
- Check the relay states in the Serial Monitor

Imagine you want to control two loads at once, such as a pump and a fan, or two actuators. Two single relay modules would work. A 2-channel relay module is the neater choice, though. It needs fewer wires, takes less space and costs less. The code stays the same as for two single relays, so you lose nothing.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of 2-Channel Relay Module
Knowing each pin of the module saves you from wiring mistakes. The pins fall into three groups: power, signal and output. The sections below walk through each group.
Pinout

Power pins
The DC+ pin takes 5V from a power supply. The DC- pin goes to the GND of that supply, and it must also connect to a GND pin of the ESP32 S3 Uno so both sides share the same ground.
Signal pins
The IN1 pin receives the control signal for relay 1 from the ESP32 S3 Uno. The IN2 pin does the same job for relay 2.
Output pins
Every relay has three output pins: NCx (normally closed), NOx (normally open) and COMx (common). Your first high-voltage device goes on NC1, NO1 and COM1, which relay 1 switches. Your second device goes on NC2, NO2 and COM2, which relay 2 switches.
Trigger jumpers
You will also find 2 jumpers on the board. Each one sets its relay to a low-level trigger or a high-level trigger. Because each relay has its own jumper, the two relays can use different trigger modes.
If relays are new to you, read the ESP32 S3 Uno - Relay tutorial first. It covers how to connect a relay to a high-voltage device, what normally closed and normally open mean, what low-level trigger and high-level trigger mean, and how the ESP32 S3 Uno controls a relay.
ESP32 S3 Uno Pinout
The image below shows the pinout diagram of the ESP32 S3 Uno form board. Use it to find the D2 and D3 headers and their GPIO numbers when you wire the relay module.

Wiring Diagram
Careful wiring keeps your project safe and stable. The two signal wires are easy: IN1 goes to D2 (GPIO18) and IN2 goes to D3 (GPIO17). For a quick test, the module takes its power from the 5V pin of the board.
| Relay Module Pin | ESP32 S3 Uno Pin |
|---|---|
| DC+ | 5V |
| DC- | GND |
| IN1 | D2 (GPIO18) |
| IN2 | D3 (GPIO17) |

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
Most 2-channel relay modules have 5V coils, so DC+ needs 5V. The IN1 and IN2 pins only receive the 3.3V signal from the ESP32 S3 Uno, and most modules with an optocoupler or transistor input switch fine with it. Never send a 5V signal back into an ESP32 S3 Uno pin, because the ESP32 S3 Uno pins are NOT 5V tolerant.
When the board's 5V pin also feeds other parts, the relay module may not get enough current. Two relay coils switching together can pull the voltage down. In that case, power the module from its own 5V adapter, and join its GND to the GND of the ESP32 S3 Uno.
※ NOTE THAT:
When both loads use the same voltage, a single high-voltage power adapter can supply them both. When they need different voltages, give each load its own high-voltage power adapter.
How To Program For 2-Channel Relay Module
Two relays need very little code. You use two functions, and you call each one once for every relay.
- Make each relay pin a digital output with the pinMode() function:
- Switch each relay with the digitalWrite() function. On the ESP32 S3 Uno, HIGH means 3.3V:
ESP32 S3 Uno Code
This sketch switches both relays on, waits 2 seconds, switches them off, and waits another 2 seconds, forever. PIN_RELAY_1 is GPIO18 (D2) and PIN_RELAY_2 is GPIO17 (D3). After every change, it prints a line to the Serial Monitor so you can follow what happens.
Detailed Instructions
- New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
- Wire it up as shown in the diagram.
- Connect the board to your computer with a USB Type-C cable.
- Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
- Copy the code above and paste it into the Arduino IDE.
- Upload the code by clicking the Upload button.
- Listen for both relays to click every 2 seconds.
- Open the Serial Monitor, set it to 9600 baud, and check the output.
- Tip: Test the relays without any high-voltage load first. Once the clicks and messages look right, switch off all power, and only then connect your loads.
Video Tutorial
Watch the video below to see this ESP32 S3 Uno project step by step.
Function References
Application Examples
With two relays working, you are one step away from a real project. You can switch the two loads by a sensor, by a button or by time.
Plant watering system
Add a soil moisture sensor. Let the ESP32 S3 Uno run a pump on relay 1 when the soil is dry, and turn on a grow light with relay 2 at night.
Fan and heater controller
Read a DHT22 temperature sensor. Switch a fan with one relay when it is hot, and a heater with the other relay when it is cold.
Two-gang switch
Add two push buttons, one for each relay. The ESP32 S3 Uno reads each button and toggles its own relay, like a two-gang light switch.
Phone control
The ESP32 S3 Uno has built-in WiFi. Run a small web server on it and switch each relay from a web page on your phone.
Simple timer
Use millis() to run relay 1 for 10 minutes every hour, and relay 2 on a different schedule.
FAQ
Can the ESP32 S3 Uno control each relay on its own?
Yes. Each relay has its own pin, so you can call digitalWrite() on PIN_RELAY_1 and PIN_RELAY_2 at different times. For example, relay 1 can be on while relay 2 stays off.
Can a 3.3V ESP32 S3 Uno pin drive a 5V 2-channel relay module?
In most cases, yes. Power DC+ from 5V and connect IN1 and IN2 to D2 (GPIO18) and D3 (GPIO17). A 3.3V HIGH is enough for most modules with an optocoupler or transistor input. If the relay LED lights but the relay does not click, use a 3V relay module.
Why does my relay turn ON when the code says LOW?
Your module is set to low-level trigger. In that mode, LOW turns the relay on and HIGH turns it off. Move the trigger jumper to the high-level position, or swap HIGH and LOW in your code.
Why does the code use 18 and 17 instead of 2 and 3 like on the UNO R4?
On the ESP32 S3 Uno, the header label and the GPIO number are different. D2 is GPIO18 and D3 is GPIO17, and the code must use the GPIO number. If you write 2 or 3, the code drives the wrong pins and the relays stay silent.
What if my project needs more relays than the Uno headers give?
The ESP32 S3 Uno has two extra rows of holes with more GPIOs. GPIO15 and GPIO16 are I/O, PWM and analog. GPIO45 and GPIO35 to GPIO42 are I/O and PWM. GPIO47 and GPIO48 are output only, with PWM. Solder pin headers to use them and write the GPIO number in code. For extra relays, GPIO35 to GPIO42 are a good choice. Watch out for two things. First, GPIO47 and GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Second, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.
Do I need a separate power supply for the relay module?
It is the safer choice. Two relay coils together draw more current than a small project should take from the board's 5V pin. A separate 5V supply stops the ESP32 S3 Uno from resetting when the relays switch.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port shows up in the Arduino IDE | USB driver is missing, the cable is charge-only, or the board is not in upload mode | Install the CP210x or CH340 driver, try a USB Type-C data cable, or hold BOOT while pressing RESET |
| Relays do not click at all | DC+ and DC- are not powered or the GND is not shared | Check the 5V supply to the module and connect DC- to a GND pin of the ESP32 S3 Uno |
| Relay LED lights but the relay does not click | The 3.3V signal is too weak for this module | Use a 3V relay module or one with a transistor or optocoupler input |
| Relays stay silent after upload | The code uses header numbers instead of GPIO numbers | Use 18 for D2 and 17 for D3 |
| Relay works in the opposite way | The trigger jumper is set to low-level trigger | Move the jumper to high-level trigger or swap HIGH and LOW in the code |
| Only one relay switches | The IN wire for the other relay is loose or on the wrong pin | Make sure IN1 goes to D2 (GPIO18) and IN2 goes to D3 (GPIO17) |
| The board resets when the relays switch | The relay coils draw too much current from the board | Power the relay module from a separate 5V supply |
| The relay clicks but the load does not turn on | The load is wired to NC instead of NO or COM is not connected | Wire the load through COM and NO and check the load power supply |
| Serial Monitor shows nothing or strange text | Wrong baud rate or wrong COM port | Set the baud rate to 9600 and choose the COM port of the ESP32 S3 Uno |