5V 2 Channel SSR Module Documentation
The 5V 2 Channel SSR Module is a solid-state relay (SSR) module that allows you to control two AC loads using a microcontroller or other digital signal source. This module is suitable for a wide range of applications, including home automation, industrial control, and IoT projects.
2-channel relay module
Operating voltage: 5V
Relay type: Solid-state relay (SSR)
Load voltage: Up to 250V AC
Load current: Up to 2A per channel
TTL compatible input
optically isolated input
Built-in freewheeling diode for inductive loads
VCC: 5V power supply
GND: Ground
IN1: Input 1 (TTL compatible)
IN2: Input 2 (TTL compatible)
OUT1: Relay output 1 (AC load)
OUT2: Relay output 2 (AC load)
### Example 1: Basic ON/OFF Control using Arduino
In this example, we will use an Arduino board to control the 2-channel SSR module.
Arduino Uno board
5V 2 Channel SSR Module
2 x AC loads (e.g., LED bulbs)
Breadboard and jumper wires
Sketch
```c++
const int relayPin1 = 2; // Pin for relay channel 1
const int relayPin2 = 3; // Pin for relay channel 2
void setup() {
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
}
void loop() {
digitalWrite(relayPin1, HIGH); // Turn on relay channel 1
delay(1000);
digitalWrite(relayPin1, LOW); // Turn off relay channel 1
delay(1000);
digitalWrite(relayPin2, HIGH); // Turn on relay channel 2
delay(1000);
digitalWrite(relayPin2, LOW); // Turn off relay channel 2
delay(1000);
}
```
### Example 2: PWM Dimming using Raspberry Pi
In this example, we will use a Raspberry Pi to control the brightness of two AC loads using the 2-channel SSR module.
Raspberry Pi board
5V 2 Channel SSR Module
2 x AC loads (e.g., LED bulbs)
Breadboard and jumper wires
Code
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO pins
GPIO.setmode(GPIO.BCM)
relayPin1 = 17
relayPin2 = 23
GPIO.setup(relayPin1, GPIO.OUT)
GPIO.setup(relayPin2, GPIO.OUT)
# Define PWM frequencies
pwm_freq1 = 100
pwm_freq2 = 50
# Create PWM objects
pwm1 = GPIO.PWM(relayPin1, pwm_freq1)
pwm2 = GPIO.PWM(relayPin2, pwm_freq2)
try:
while True:
# Dimming cycle for relay channel 1
for dc in range(0, 101, 10):
pwm1.ChangeDutyCycle(dc)
time.sleep(0.1)
# Dimming cycle for relay channel 2
for dc in range(0, 101, 20):
pwm2.ChangeDutyCycle(dc)
time.sleep(0.1)
except KeyboardInterrupt:
pass
# Clean up
pwm1.stop()
pwm2.stop()
GPIO.cleanup()
```
### Example 3: Home Automation using ESP8266
In this example, we will use an ESP8266 board to control the 2-channel SSR module over Wi-Fi.
ESP8266 board (e.g., NodeMCU)
5V 2 Channel SSR Module
2 x AC loads (e.g., LED bulbs)
Breadboard and jumper wires
Wi-Fi router
Code
```c++
#include <WiFi.h>
#include <ESP8266WiFi.h>
const char ssid = "your_wifi_ssid";
const char password = "your_wifi_password";
const int relayPin1 = D1;
const int relayPin2 = D2;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
server.begin();
pinMode(relayPin1, OUTPUT);
pinMode(relayPin2, OUTPUT);
}
void loop() {
WiFiClient client = server.available();
if (client) {
String request = client.readStringUntil('
');
if (request.indexOf("/relay1/on") != -1) {
digitalWrite(relayPin1, HIGH);
} else if (request.indexOf("/relay1/off") != -1) {
digitalWrite(relayPin1, LOW);
} else if (request.indexOf("/relay2/on") != -1) {
digitalWrite(relayPin2, HIGH);
} else if (request.indexOf("/relay2/off") != -1) {
digitalWrite(relayPin2, LOW);
}
client.stop();
}
}
```
Note: The above code examples are for illustration purposes only. You may need to modify them to suit your specific requirements and hardware configurations. Always follow safety guidelines when working with electrical circuits.