8-Channel Optocoupler Relay board interfacing with Arduino

This blog is intended to help beginners start with interfacing optocoupler relay boards with microcontrollers. We will describe the hardware interfacing of such relay boards with the popular platform Arduino. Sample code is also given below for reference.


Optocoupled relay board can be purchased from our online store at ElementzOnline.com

Why are optocoupled relays used?

There are mostly two reasons

  • In a situation where the controller is far away from the relay board, then there is no need of the ground of the controller to be connected to the relay board or in another sense make the ground common.
  • Using the optoisolator means the control signal is used purely as a differential signal between VCC and the control signal, both sourced from the controller circuit; ground potential differences won’t affect the operation.
  • The relay coil voltage is not necessarily the same as the controller’s Vcc. It could even be generated by an off-line (unisolated) supply. The optoisolator then provides isolation between the potentially unisolated Relay VCC supply and the controller circuits.


  • Optically Isolated relays to protect your microcontroller from damage if the equipment being controlled fails
  • Coil Voltage : DC 5V
  • Pole Number : 8 Channel
  • four screw holes, hole diameter 3.1mm
  • relay status indicator light indicates the relay ON/OFF
  • Relay Maximum output: DC 30V/10A, AC 250V/10A

Representation of control logic:

The below shows the control logic circuit used in the optocoupled relay board. The circuit is designed to be compatible with most microcontrollers including AVR/8051/PIC/ARM and boards such as Arduino, Raspberry PI etc.


Arduino Interfacing

Interfacing of Arduino UNO with the optocoupler board is given below


Connection Description:

VCC: The optocoupler’s input power supply

RVCC: Unisolated Relay working voltage

GND: Ground(0V) potential for relay circuitry

IN1-7: control input for the respective relay to be turned On/Off.

Note: There is no need to connect the Controller’s ground signal to the optocoupler board. Only relay supply ground to be connected to the optocoupler board.

Important Note: The control signal is active high(logic Low) relay is turned ON and vice versa.

Sample code:


Created by: Dhanish Vijayan
Company: Elementz Engineers Guild Pvt Ltd ( http://www.elementzonline.com )

This code demosntrate the interfacing and control of 8-Channel optocoupled relay board

Product Link: http://elementzonline.com/8-channel-relay-board-with-optocoupler-254

Las Modified Date: 17/07/2016

int RelayControlPin1 = 2;
int RelayControlPin2 = 3;
int RelayControlPin3 = 4;
int RelayControlPin4 = 5;
int RelayControlPin5 = 6;
int RelayControlPin6 = 7;
int RelayControlPin7 = 8;
int RelayControlPin8 = 9;

void setup() {
// put your setup code here, to run once:
pinMode(RelayControlPin1, OUTPUT);
pinMode(RelayControlPin2, OUTPUT);
pinMode(RelayControlPin3, OUTPUT);
pinMode(RelayControlPin4, OUTPUT);
pinMode(RelayControlPin5, OUTPUT);
pinMode(RelayControlPin6, OUTPUT);
pinMode(RelayControlPin7, OUTPUT);
pinMode(RelayControlPin8, OUTPUT);

void loop() {
* Turn ON all relays
* Note: The control logic should be LOW for the optocoupler relay to be turned on

digitalWrite(RelayControlPin1, LOW);
digitalWrite(RelayControlPin2, LOW);
digitalWrite(RelayControlPin3, LOW);
digitalWrite(RelayControlPin4, LOW);
digitalWrite(RelayControlPin5, LOW);
digitalWrite(RelayControlPin6, LOW);
digitalWrite(RelayControlPin7, LOW);
digitalWrite(RelayControlPin8, LOW);

delay(10000); /* 10 seconds delay */

* Turn OFF all relays
* Note: The control logic should be HIGH for the optocoupler relay to be turned off

digitalWrite(RelayControlPin1, HIGH);
digitalWrite(RelayControlPin2, HIGH);
digitalWrite(RelayControlPin3, HIGH);
digitalWrite(RelayControlPin4, HIGH);
digitalWrite(RelayControlPin5, HIGH);
digitalWrite(RelayControlPin6, HIGH);
digitalWrite(RelayControlPin7, HIGH);
digitalWrite(RelayControlPin8, HIGH);

delay(10000); /* 10 seconds delay */


Purchase link: http://elementzonline.com/8-channel-relay-board-with-optocoupler-254

Sample Code: github.com/elementzonline/Arduino-Sample-Codes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s