Codey OnlineArduino & ESP32 component library › 8-Channel Relay Module
8-Channel Relay Module
Output

8-Channel Relay Module

An 8-channel relay module that lets a microcontroller switch eight separate loads using digital control signals. It has power and ground connections plus IN1-IN8 control inputs, and relay contacts for each channel with NO/COM/NC terminals to route the external circuit.

Width: 128.1 mm

Pinout — 8-Channel Relay Module

Pin Signal Description
GND ground Logic ground reference for MCU control inputs and VCC supply
IN1 digital Active-low control input for relay 1 — drive low to energize
VCC power Logic-side supply for optocouplers/input circuitry, typically 5V
IN2 digital Active-low control input for relay 2 — drive low to energize
IN3 digital Active-low control input for relay 3 — drive low to energize
IN4 digital Active-low control input for relay 4 — drive low to energize
IN5 digital Active-low control input for relay 5 — drive low to energize
IN6 digital Active-low control input for relay 6 — drive low to energize
IN7 digital Active-low control input for relay 7 — drive low to energize
IN8 digital Active-low control input for relay 8 — drive low to energize
K1_NC digital Normally-closed load contact for relay 1 — connected to COM when relay is off
K1_COM digital Common switched load terminal for relay 1
K1_NO digital Normally-open load contact for relay 1 — connected to COM when relay energizes
K2_NC digital Normally-closed load contact for relay 2 — connected to COM when relay is off
K2_COM digital Common switched load terminal for relay 2
K2_NO digital Normally-open load contact for relay 2 — connected to COM when relay energizes
K3_NC digital Normally-closed load contact for relay 3 — connected to COM when relay is off
K3_COM digital Common switched load terminal for relay 3
K3_NO digital Normally-open load contact for relay 3 — connected to COM when relay energizes
K4_NC digital Normally-closed load contact for relay 4 — connected to COM when relay is off
K4_COM digital Common switched load terminal for relay 4
K4_NO digital Normally-open load contact for relay 4 — connected to COM when relay energizes
K5_NC digital Normally-closed load contact for relay 5 — connected to COM when relay is off
K5_COM digital Common switched load terminal for relay 5
K5_NO digital Normally-open load contact for relay 5 — connected to COM when relay energizes
K6_NC digital Normally-closed load contact for relay 6 — connected to COM when relay is off
K6_COM digital Common switched load terminal for relay 6
K6_NO digital Normally-open load contact for relay 6 — connected to COM when relay energizes
K7_NC digital Normally-closed load contact for relay 7 — connected to COM when relay is off
K7_COM digital Common switched load terminal for relay 7
K7_NO digital Normally-open load contact for relay 7 — connected to COM when relay energizes
K8_NC digital Normally-closed load contact for relay 8 — connected to COM when relay is off
K8_COM digital Common switched load terminal for relay 8
K8_NO digital Normally-open load contact for relay 8 — connected to COM when relay energizes

Example wiring diagram — 8-Channel Relay Module

From To Wire
board:GND x1:GND black
board:5V x1:VCC red
board:D2 x1:IN1 green
board:D3 x1:IN2 blue
board:D4 x1:IN3 yellow
board:D5 x1:IN4 purple
board:D6 x1:IN5 cyan
board:D7 x1:IN6 magenta
board:D8 x1:IN7 brown
board:D9 x1:IN8 pink

Example Arduino code — 8-Channel Relay Module

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Canonical example for an 8-channel relay module on Arduino Uno
// The relay inputs are active-low: LOW energizes the relay, HIGH turns it off.

const uint8_t relayPins[8] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }

  Serial.println("8-Channel Relay Module demo starting...");

  // Set all relay control pins to OFF first.
  for (uint8_t i = 0; i < 8; i++) {
    pinMode(relayPins[i], OUTPUT);
    digitalWrite(relayPins[i], HIGH); // active-low relay OFF
  }

  Serial.println("All relays OFF.");
}

void loop() {
  // Turn each relay on one at a time, then off again.
  for (uint8_t i = 0; i < 8; i++) {
    Serial.print("Turning relay ");
    Serial.print(i + 1);
    Serial.println(" ON");

    digitalWrite(relayPins[i], LOW); // active-low relay ON
    delay(500);

    Serial.print("Turning relay ");
    Serial.print(i + 1);
    Serial.println(" OFF");

    digitalWrite(relayPins[i], HIGH); // active-low relay OFF
    delay(250);
  }

  Serial.println("--- Cycle complete ---");
  delay(1000);
}

Related components

18650 3.7V Li-Ion Battery

18650 3.7V Li-Ion Battery

3-Channel 5V Relay Module

3-Channel 5V Relay Module

3W amplifier MAX98357A I2S DAC

3W amplifier MAX98357A I2S DAC

Active Buzzer Module

Active Buzzer Module

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free