Relay
Controlling Relay 4CH with Raspberry Pi
What is the Relay 4CH?
Relay 4CH practical reference
A 4-relay board sharing the same opto-isolated design as the single-channel version, ideal for home-automation projects controlling several devices.
Key specifications
- Control side: 5 V DC per channel, opto-isolated, ~15-20 mA each when energized
- Switching side: Up to 250V AC / 10A or 30V DC / 10A per channel on the common SRD-05VDC-SL-C relays used on most of these boards
- Trigger logic: Active LOW on most modules — a LOW signal closes that channel's relay
- Peak current: All 4 relays switching on together draw a brief combined inrush — size the 5V supply for that, don't rely on the MCU board's onboard regulator alone
Pinout and connection notes
Same mains-voltage isolation rules as the single-channel version, times four — keep the COM/NO/NC screw terminals physically separated from the 5V logic side of the board.
- VCC: Power, 5V DC, control side
- GND: Ground, control side
- IN1-IN4: Signal inputs, one per channel, from the MCU — active LOW on most modules
- COM 1-4: Common terminal, one per channel, switching side
- NO 1-4: Normally open, one per channel — connects to that channel's COM when energized
- NC 1-4: Normally closed, one per channel — connects to that channel's COM when de-energized
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up Relay 4CH with Raspberry Pi
Library
RPi.GPIO
Usually preinstalled on Raspberry Pi OS; otherwise: sudo apt install python3-rpi.gpio
Wiring
| Component pin | Raspberry Pi pin | Note |
|---|---|---|
| VCC | 5V (physical pin 2) | Use a separate 5V supply if switching all 4 channels together — relay coils can pull more than the Pi's own 5V rail comfortably supplies alongside everything else |
| GND | GND | |
| IN1, IN2, IN3, IN4 | GPIO23, GPIO24, GPIO25, GPIO8 |
Swipe sideways to see every column →
- Set every pin HIGH right after GPIO.setup(), before your main loop — the Pi's GPIOs can be in an undefined state briefly at boot, and you don't want that flickering a relay.
- Run a separate 5V supply for the relay board if you're switching all 4 channels together — don't assume the Pi's own 5V pin has current to spare on top of everything else it's powering.
- Same mains-safety caveat as the other boards: the COM/NO/NC side is genuinely dangerous if you're switching AC, and needs to stay isolated from the Pi's low-voltage side.
Related Components
Related Guides & Projects
Raspberry Pi Pico W and Pico 2 W: Install MicroPython with Thonny or UF2
Hold BOOTSEL, drag the correct UF2 file, open the REPL and blink the onboard LED. Includes the Pico vs Pico W vs Pico 2 W firmware differences and what to do when the drive does not appear.
Raspberry Pi Pico W Web Server in MicroPython: Control an LED and Read a Sensor
Connect the Pico W to WiFi, serve a responsive control page, switch an LED and display the onboard temperature or an external sensor, with timeouts and reconnect handling.
Raspberry Pi Pico Oscilloscope with MicroPython
Convert a Raspberry Pi Pico into a basic 500 kSPS oscilloscope using its 12-bit ADC and MicroPython. Displays waveforms on an SSD1306 OLED or streams samples over USB serial to a Python plotter on your PC.
Self-Hosted Nextcloud NAS on Raspberry Pi 4
Build a private, durable Nextcloud NAS on a Raspberry Pi 4 -- SSD boot instead of a failure-prone SD card, Docker Compose with Redis caching, Tailscale for remote access with zero ports forwarded, and an automated backup strategy that actually runs.