2-Ch 5V Relay Board
2-Ch 5V Relay Board
The 2-Ch 5V Relay Board is a compact, low-cost, and widely used Internet of Things (IoT) component designed to control and switch high-current devices using a low-voltage signal. This relay board is capable of switching two independent channels, making it an ideal solution for various applications, including home automation, industrial control, and robotics.
The 2-Ch 5V Relay Board acts as an electronic switch that can turn On/Off devices connected to it, such as lights, fans, motors, and solenoids. The relay board operates by using a low-voltage signal (5V) to control the flow of high-voltage current (up to 250V AC or 30V DC) to the connected devices. This allows for safe and efficient control of devices that require higher voltage and current than what microcontrollers or other low-voltage devices can provide.
| ### Relay Specifications |
2
Electromagnetic Relay (EMR)
10A/250V AC, 10A/30V DC
5V DC
10mA (max)
| ### Board Specifications |
5V DC
Digital (0-5V)
-40C to 85C
45mm x 35mm x 20mm (L x W x H)
| ### Other Features |
Each channel has a built-in LED indicator to show the relay's On/Off status
Provides electrical isolation between the input control signal and the relay coil
High-quality FR4 glass epoxy material
4 x 3mm mounting holes for secure installation
| The 2-Ch 5V Relay Board is suitable for a wide range of applications, including |
Home automation systems
Industrial control systems
Robotics and mechatronics
IoT projects
DIY electronics projects
| The relay board has a simple digital input interface, which can be connected to a microcontroller, Arduino, Raspberry Pi, or any other digital output device. The board has two 3-pin headers for each relay channel, with the following connections |
5V power supply
Ground
Digital input signal (0-5V)
Please ensure proper wiring and installation to avoid damage to the relay board or connected devices. Follow the manufacturer's instructions and guidelines for safe and reliable operation.
| When working with the 2-Ch 5V Relay Board, please observe the following safety precautions |
Handle the board with care to avoid damage to the components
Ensure proper isolation between the relay board and external devices
Use a suitable power supply voltage and current rating
Avoid overheating or excessive mechanical stress on the relay board
By following the guidelines and specifications outlined in this documentation, you can effectively integrate the 2-Ch 5V Relay Board into your IoT project or application.
2-Ch 5V Relay Board DocumentationOverviewThe 2-Ch 5V relay board is a compact and versatile module that allows users to control high-current devices with a low-current signal from a microcontroller or other digital interface. The board features two relays, each capable of switching up to 10A of current at 250V AC or 30V DC. The relays are controlled by digital inputs and are optically isolated from the load, ensuring safe and reliable operation.Pinout| Pin | Function |
| --- | --- |
| VCC | Power supply (5V) |
| GND | Ground |
| IN1 | Digital input for relay 1 |
| IN2 | Digital input for relay 2 |
| Relay 1 | Normally Open (NO) contact |
| Relay 1 | Normally Closed (NC) contact |
| Relay 1 | Common (COM) contact |
| Relay 2 | Normally Open (NO) contact |
| Relay 2 | Normally Closed (NC) contact |
| Relay 2 | Common (COM) contact |Example 1: Basic Relay Control with ArduinoIn this example, we'll use an Arduino Uno to control the relay board. We'll toggle the relays on and off at 1-second intervals.Hardware RequirementsArduino Uno
2-Ch 5V relay board
Breadboard and jumper wires
LED or other load deviceSoftware RequirementsArduino IDE (version 1.8 or later)Code
```c
const int relay1Pin = 2; // Digital pin 2 for relay 1
const int relay2Pin = 3; // Digital pin 3 for relay 2void setup() {
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
}void loop() {
digitalWrite(relay1Pin, HIGH); // Turn relay 1 on
digitalWrite(relay2Pin, LOW); // Turn relay 2 off
delay(1000);digitalWrite(relay1Pin, LOW); // Turn relay 1 off
digitalWrite(relay2Pin, HIGH); // Turn relay 2 on
delay(1000);
}
```
Example 2: Home Automation with Raspberry Pi and PythonIn this example, we'll use a Raspberry Pi to control the relay board and turn on/off a lamp using a web interface.Hardware RequirementsRaspberry Pi (any model)
2-Ch 5V relay board
Breadboard and jumper wires
LED or other load device
RPi-compatible web framework (e.g., Flask or Django)Software RequirementsRaspbian OS (version 10 or later)
Python 3.x
Web framework of choice (e.g., Flask or Django)Code
```python
import RPi.GPIO as GPIO
from flask import Flask, requestapp = Flask(__name__)# Set up GPIO pins for relay control
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT) # Relay 1
GPIO.setup(23, GPIO.OUT) # Relay 2@app.route('/relay/1/on', methods=['GET'])
def relay1_on():
GPIO.output(17, GPIO.HIGH)
return 'Relay 1 turned on'@app.route('/relay/1/off', methods=['GET'])
def relay1_off():
GPIO.output(17, GPIO.LOW)
return 'Relay 1 turned off'@app.route('/relay/2/on', methods=['GET'])
def relay2_on():
GPIO.output(23, GPIO.HIGH)
return 'Relay 2 turned on'@app.route('/relay/2/off', methods=['GET'])
def relay2_off():
GPIO.output(23, GPIO.LOW)
return 'Relay 2 turned off'if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
```
Example 3: Automation with ESP32 and MicroPythonIn this example, we'll use an ESP32 board to control the relay board and send notifications via Wi-Fi.Hardware RequirementsESP32 board (e.g., ESP32 DevKitC)
2-Ch 5V relay board
Breadboard and jumper wires
LED or other load device
Wi-Fi routerSoftware RequirementsMicroPython firmware (version 1.12 or later)
Wi-Fi library (e.g., `wlan`)Code
```python
import machine
import wifi# Set up Wi-Fi connection
wifi.connect('your_wifi_ssid', 'your_wifi_password')# Set up GPIO pins for relay control
relay1_pin = machine.Pin(18, machine.Pin.OUT)
relay2_pin = machine.Pin(19, machine.Pin.OUT)def send_notification(state):
# Send notification via Wi-Fi (e.g., using HTTP or MQTT)
print(f'Relay state changed to {state}')def toggle_relay1(state):
relay1_pin.value(state)
send_notification(state)def toggle_relay2(state):
relay2_pin.value(state)
send_notification(state)# Toggle relays on and off at 1-second intervals
while True:
toggle_relay1(1)
toggle_relay2(0)
machine.sleep(1)
toggle_relay1(0)
toggle_relay2(1)
machine.sleep(1)
```
Notes and PrecautionsEnsure the relay board is powered from a stable 5V source.
Use appropriate load devices and follow safety guidelines when working with high-voltage or high-current applications.
Verify the pinout and wiring before powering on the relay board.
Consult the datasheet for the specific relay model used on the board for detailed specifications and guidelines.