📦 Starter Kit & Plans (from 50€)
📱
Screenshots & UI
📦
Starter Kit & Plans
📊
Live Telemetry
⚡
Ecosystem Features
🚪
Security
🎙️
Integrations
☁️
Custom Backend
📚
Guides
❓
FAQ
🤝
Partners
📖
API Docs
🛡️
Privacy Policy
Get Started (from 50 EUR) Get App on Google Play
← All guides
📚 UpaSmartHome Guide

Raspberry Pi 4 & 5 8-Channel Relay Board Complete Wiring & GPIO Pinout Guide

Step-by-step wiring diagram, GPIO pinout mapping, optocoupler isolation, and safety instructions to connect an 8-channel relay board to a Raspberry Pi 4 or 5.

An 8-channel relay board (such as the popular Waveshare 8-channel HAT or standard optocoupler-isolated relay boards) is the heart of physical home automation. It enables your Raspberry Pi 4 or Raspberry Pi 5 to switch high-power circuits — such as hydronic heating zone valves, circulation pumps, garage doors, motorized gates, and high-voltage lighting circuits — safely and reliably.

GPIO Pinout & Connection Mapping

Standard Raspberry Pi 40-pin header assignments recommended for 8-channel relay automation:

Relay Channel Raspberry Pi GPIO (BCM) Physical Header Pin Default Logic State
VCC (Logic Power)5V DC PowerPin 2 or Pin 4Continuous +5V
GND (Ground)GroundPin 6, 9, 14, 20, 25, 30, 34, 39Ground Reference
IN1 (Relay 1)GPIO 5Pin 29Active Low / High
IN2 (Relay 2)GPIO 6Pin 31Active Low / High
IN3 (Relay 3)GPIO 13Pin 33Active Low / High
IN4 (Relay 4)GPIO 16Pin 36Active Low / High
IN5 (Relay 5)GPIO 19Pin 35Active Low / High
IN6 (Relay 6)GPIO 20Pin 38Active Low / High
IN7 (Relay 7)GPIO 21Pin 40Active Low / High
IN8 (Relay 8)GPIO 26Pin 37Active Low / High

Optocoupler Electrical Isolation & Power Jumper (JD-VCC)

Most quality 8-channel relay boards feature optical isolation (EL817 optocouplers) and a 3-pin jumper labeled JD-VCC / VCC / GND:

  • With the Jumper Installed (Shared Power): The relay coils are driven directly from the Raspberry Pi's 5V rail. This is fine for testing 1 or 2 relays, but when all 8 relays energize simultaneously, coil current exceeds 600mA, which can induce brownouts, SD card corruption, or spontaneous reboots.
  • With the Jumper Removed (Isolated External Power): Remove the blue jumper between JD-VCC and VCC. Connect an external 5V 2A DC power supply's positive lead directly to JD-VCC, and external GND to relay GND. Connect the Raspberry Pi's 3.3V or 5V to the board's logic VCC. The Raspberry Pi's CPU is now 100% optically isolated from coil voltage spikes and inductive kickback.

Understanding Terminal Contacts: NO, NC, and COM

Each channel has three screw terminals on the high-voltage side:

  • COM (Common): Feed your incoming line voltage (or low-voltage signal) here.
  • NO (Normally Open): Disconnected when the relay is unpowered. When the relay triggers, COM connects to NO. Use this for standard lights, irrigation valves, and exhaust fans so they remain OFF when power is cut.
  • NC (Normally Closed): Connected when the relay is unpowered. When triggered, the circuit opens. Ideal for fail-safe heating valves that must open if control power is lost.

Instant Testing from Raspberry Pi Terminal

On modern Raspberry Pi OS Bookworm (or Raspberry Pi 5 using RP1 I/O controller):

# Turn Relay 1 ON (GPIO 5 active low)
pinctrl set 5 op dl

# Turn Relay 1 OFF
pinctrl set 5 op dh

Zero-Code Setup with UpaSmartHome

With UpaSmartHome, you do not need to write custom Python scripts or manage background cron tasks. The platform natively detects the 8 GPIO channels, exposes them as interactive toggles in the mobile app, connects them with automated thermostat schedules, and makes all 8 switches voice-controllable via Apple HomeKit and Google Home.