Raspberry pi 3B with 5V 4 channel relay


I have been using raspberry pi boards since long. So far I have used these for applications such as media center, home cloud, pi-hole and some of my own written apps.
This time I thought to extend scope to control external electrical devices. To start with I have purchased a 5V 4 channel relay and bundle of connectors. This relay can operate appliances at 220V and 10A. So you can connect maximum load of 2200W on each channel of relay. But Considering heating upon continuous use I will suggest to use this relay with smaller appliances (~1000W or less).

After going through some raspberry GPIO documentation I narrowed down to very basic connection schema and a small python code to operate relay from raspberry pi.

Here is the connection diagram of setup to operate Input 1 of relay.

In same way you can connect rest 3 inputs as well on different GPIO pins of raspberry pi.

Here is the python code to switch it on for few seconds and then turn if off

#!/usr/bin/python3.5


import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
rpin1=8
GPIO.setup(rpin1, GPIO.OUT, initial=GPIO.HIGH)


GPIO.output(rpin1,GPIO.LOW)
print("On")
time.sleep(5)
GPIO.output(rpin1,GPIO.HIGH)
print("Off")
time.sleep(2)
GPIO.cleanup()
print("Exiting")

Here are some close up photos of setup for better clarity.