Arduino UNO R4 - 2-Channel Relay Module
This Arduino UNO R4 2-channel relay module guide shows you how to switch two high-voltage devices from one board. You get the pinout, the wiring with the right power setup, and a short sketch for the Arduino IDE. When you finish, both relays click on and off under your code's control.
In this tutorial, you will:
- Learn the pinout of a 2-channel relay module.
- Wire the relay module to the Arduino UNO R4 with a safe power setup.
- Write code that turns both relays on and off.
- Check the result in the Serial Monitor.

Say you want to control two loads, like a pump and a fan, or two actuators. You could buy two single relay modules. But a 2-channel relay module is easier:
- The wiring is simpler.
- It takes less space.
- It costs less.
- The code is the same as for two single relay modules.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables STEM V4 IoT Starter Kit (Arduino included) | |
| 1 | × | DIYables STEM V4B IoT Starter Kit (Arduino included) | |
| 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
Before you wire anything, it helps to know what each pin on the module does. The module has three groups of pins: power, signal and output.
Pinout

Power pins
- DC+: goes to the 5V pin of the power supply.
- DC-: goes to the GND pin of the power supply. Also connect it to a GND pin of the Arduino UNO R4.
Signal pins
- IN1: gets the control signal from the Arduino UNO R4 for relay 1.
- IN2: gets the control signal from the Arduino UNO R4 for relay 2.
Output pins
Each relay has three output pins: NCx (normally closed), NOx (normally open) and COMx (common).
- NC1, NO1, COM1: connect the high-voltage device that relay 1 controls.
- NC2, NO2, COM2: connect the high-voltage device that relay 2 controls.
Trigger jumpers
The board also has 2 jumpers. Each jumper sets one relay to a low-level trigger or a high-level trigger, so you can set the two relays differently.
New to relays? Read the Arduino UNO R4 - Relay tutorial first. It explains:
- 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
- How to control a relay with the Arduino UNO R4
Wiring Diagram
Good wiring keeps your project safe and stable. The two control wires are simple: IN1 goes to D2 and IN2 goes to D3. For a quick test, the module takes its power from the 5V pin of the board.
| Relay Module Pin | Arduino UNO R4 Pin |
|---|---|
| DC+ | 5V |
| DC- | GND |
| IN1 | D2 |
| IN2 | D3 |

This image is created using Fritzing. Click to enlarge image
See The best way to supply power to the Arduino Uno R4 and other components.
If the 5V pin of the board also powers other parts, the relay module may not get enough current. In that case, power the module from its own 5V adapter, and connect its GND to the GND of the Arduino UNO R4.
※ NOTE THAT:
If both loads run at the same voltage, one high-voltage power adapter can feed both of them. If they need different voltages, give each load its own high-voltage power adapter.
How To Program For 2-Channel Relay Module
The code for two relays is short. You only need two functions, and you call each one once per relay.
- Set each relay pin as a digital output with the pinMode() function.
- Switch each relay with the digitalWrite() function.
Arduino UNO R4 Code
The sketch below turns both relays on, waits 2 seconds, turns them off, and waits 2 more seconds. It repeats this forever. Each time, it also prints a message to the Serial Monitor so you can follow along.
Detailed Instructions
- New to the Arduino UNO R4? Follow setting up the environment for Arduino UNO R4 WiFi/Minima in the Arduino IDE 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 correct Arduino UNO R4 board (for example, Arduino UNO R4 WiFi) 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 the click of the relays every 2 seconds.
- Open the Serial Monitor and check the output.
Tip: Test the relays with no high-voltage load first. When the clicks and the messages look right, turn off all power and then connect your loads.
Video Tutorial
Function References
FAQ
Can I 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, you can turn relay 1 on while relay 2 stays off.
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.
Does this code work on both the Arduino UNO R4 WiFi and the Arduino UNO R4 Minima?
Yes. Both boards have the same pins and the same 5V logic. Just select the right board in the Arduino IDE before you upload.
Can I use code from the classic Arduino UNO with the Arduino UNO R4?
Mostly, yes. The pin numbers are the same, and functions like pinMode(), digitalWrite() and Serial work the same way. Only code that writes to AVR registers directly will not compile on the Arduino UNO R4.
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 pull from the board's 5V pin. A separate 5V supply keeps the Arduino UNO R4 from resetting when the relays switch.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No COM port shows up in the Arduino IDE | The USB Type-C cable is charge-only or the board is not in bootloader mode | Try another USB Type-C data cable, then double-press the RESET button to enter bootloader mode |
| 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 Arduino UNO R4 |
| 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 and IN2 goes to D3 |
| 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 load does not turn on but the relay clicks | 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 Arduino UNO R4 |
Application Examples
Once two relays are working, you can turn this into a real project that controls two loads by sensor, by button or by time.
- Build a plant watering system. Add a soil moisture sensor, and let the Arduino UNO R4 turn a pump on relay 1 when the soil is dry and a grow light on relay 2 at night.
- Make a smart fan and heater controller. Read a DHT22 temperature sensor, then switch a fan with one relay when it is hot and a heater with the other when it is cold.
- Add two push buttons, one for each relay. The Arduino UNO R4 reads each button and toggles its own relay, like a two-gang light switch.
- Control the relays from your phone. On the Arduino UNO R4 WiFi, run a small web server and switch each relay from a web page.
- Create a simple timer. Use millis() on the Arduino UNO R4 to run relay 1 for 10 minutes every hour and relay 2 on a different schedule.