Arduino Nano - 4-Channel Relay Module
When we need to control 4 high-voltage devices such as pumps, fans, actuators... We have the option of using multiple relay modules. Alternatively, there is a simpler solution: a 4-channel relay module. This is a single board that contains 4 relays.
A 4-channel relay module compared to 4 x 1-channel relay modules:
- Its wiring is simpler.
- It takes up less space.
- It is more cost-effective.
- The programming remains the same.
Hardware Preparation
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables.
Overview of 4-Channel Relay Module
The 4-Channel Relay Module Pinout
A 4-channel relay module has the following pins:
- Power pins for relay boards
- DC+: connect this pin to 5V pin of power supply
- DC-: connect this pin to the GND pin of the power supply and also to the GND pin of the Arduino Nano
- Signal pins:
- IN1: this pin receives the control signal from Arduino Nano to control relay 1 on the module
- IN2: this pin receives the control signal from Arduino Nano to control relay 2 on the module
- IN3: this pin receives the control signal from Arduino Nano to control relay 3 on the module
- IN4: this pin receives the control signal from Arduino Nano to control relay 4 on the module
- Output pins: NCx (normally closed pin), NOx (normally open pin), COMx (common pin),
- NC1, NO1, COM1: These pins link to a high-voltage device that is controlled by relay 1
- NC2, NO2, COM2: These pins link to a high-voltage device that is controlled by relay 2
- NC3, NO3, COM3: These pins link to a high-voltage device that is controlled by relay 3
- NC4, NO4, COM4: These pins link to a high-voltage device that is controlled by relay 4
For information on connecting a relay to high-voltage, as well as the differences between a normally closed and a normally open relay, please refer to Arduino Nano - Relay tutorial.
It also has 4 jumpers, which can be used to choose between the low trigger and the high trigger for each relay.
Wiring Diagram
The 4-channel relay module requires a significant amount of energy, so it should NOT be powered directly from the 5V pin of the Arduino Nano. An external 5V power source must be used instead.
Therefore, we must use three power sources:
- A 5V power adapter for the Arduino Nano
- A 5V power adapter for the 4-channel relay module
- A higher-voltage power adapter (12VDC, 24VDC, 48VDC, 220AC...) for items that are managed by the 4-channel relay module
- A wiring diagram with the three power sources. The Arduino Nano can be powered either through a USB cable or a power jack, which is not shown in the image.
This image is created using Fritzing. Click to enlarge image
- We can lessen the amount of power adapters by utilizing a single 5V power source for both the Arduino Nano and the 4-channel relay module.
This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
If the four devices that are operated by a 4-channel relay module have the same voltage requirement, then we can use a single high-voltage power adapter to provide power to all of them. However, if the voltage requirements of these devices differ, then we will need to use different high-voltage power adapters for each device.
How To Program For 4-Channel Relay Module
- Sets the Arduino Nano pin to digital output mode by utilizing the pinMode() function.
- Manage the relay's condition by utilizing the digitalWrite() function.
Arduino Nano Code
Detailed Instructions
- Copy the code and open it with the Arduino IDE.
- Click the Upload button on the Arduino IDE to compile and upload the code to the Arduino Nano.
- Listen for the click sound of the relays.
- Check the Serial Monitor for the result.