- โ Power supply considerations for multiple relays
- โ Daisy-chaining relay modules
- โ Managing heat dissipation
- โ Best practices for high-voltage wiring
- โ Troubleshooting multiple relay setups
Introduction
OceanRemote supports up to 5 relays per device. Using multiple relays allows you to control several devices from a single microcontroller, saving cost and space.
This tutorial covers high-voltage wiring (110V/230V AC). Always disconnect power before wiring. If you're not comfortable with high voltage, use low-voltage DC devices (12V, 24V) instead.
Power Supply Requirements
The most common issue with multiple relays is insufficient power. Each relay module draws current when activated.
Current Draw Per Relay
| Relay Type | Current per Relay | 5 Relays Total |
|---|---|---|
| 5V Mechanical Relay (standard) | ~70mA | ~350mA |
| 5V Mechanical Relay (high-quality) | ~50mA | ~250mA |
| 3.3V Relay | ~30mA | ~150mA |
| Solid State Relay (SSR) | ~15mA | ~75mA |
Power Supply Recommendations
| Number of Relays | Recommended Power Supply | Notes |
|---|---|---|
| 1-2 relays | USB port (500mA) | OK for testing |
| 3-5 relays | 5V 2A power supply | Recommended |
| 5+ relays (external module) | External 5V 5A supply | For multiple modules |
Always use a separate power supply for relays when using 3 or more. The microcontroller's USB port may not provide enough current, causing resets or erratic behavior.
Wiring Multiple Relay Modules
Option 1: Single Multi-Channel Relay Module (Recommended)
The easiest solution is to buy a pre-made multi-channel relay module (4-channel, 8-channel, etc.). These have common VCC and GND, making wiring simple.
4-Channel Relay Module Wiring: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ โ ESP8266 โ โ 4-Channel Relay โ โ โ โโโโโโโโโโโค โโโโโโโโโโโโโโโโโโโโโโโค โ โ โ 5V โโโโโโโโโโโโโโโโโโโโโโค VCC โ โ โ โ GND โโโโโโโโโโโโโโโโโโโโโโค GND โ โ โ โ D1 โโโโโโโโโโโโโโโโโโโโโโค IN1 โ โ โ โ D2 โโโโโโโโโโโโโโโโโโโโโโค IN2 โ โ โ โ D3 โโโโโโโโโโโโโโโโโโโโโโค IN3 โ โ โ โ D4 โโโโโโโโโโโโโโโโโโโโโโค IN4 โ โ โ โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โ Note: Some modules have JD-VCC (jumper) for separate โ โ power supply. Remove jumper for external power. โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Option 2: Daisy-Chaining Single Relay Modules
If you have multiple single-relay modules, you can connect their VCC and GND in parallel:
Daisy-Chaining Single Relay Modules: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ โ โ โ 5V โโโโโโค VCC โโโโโโค VCC โโโโโโค VCC โ โ โ โ GND โโโโโโค GND โโโโโโค GND โโโโโโค GND โ โ โ โ D1 โโโโโโค IN (R1) โ โ โ โ โ โ โ โ D2 โโโโโโค โโโโโโค IN (R2) โ โ โ โ โ โ D3 โโโโโโค โโโโโโค โโโโโโค IN (R3)โ โ โ โ D4 โโโโโโค โโโโโโค โโโโโโค โ โ โ โ D5 โโโโโโค โโโโโโค โโโโโโค โ โ โ โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโ โ โ โ โ Relay 1 Module Relay 2 Module Relay 3 Module โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
When daisy-chaining, ensure your power supply can handle the total current draw. A 5V 2A supply is recommended for up to 5 single relay modules.
Heat Dissipation
Multiple relays generate heat, especially when activated for long periods.
Heat Management Tips:
- Ventilation - Ensure airflow around relay modules
- Spacing - Leave space between relay modules
- Heat sinks - Some relay modules include heat sinks
- Enclosure - Use a ventilated enclosure with fans
- Duty cycle - Avoid leaving all relays ON continuously
Most relay modules are rated for 0-70ยฐC ambient temperature. If your enclosure feels hot (>50ยฐC), add ventilation or a small fan.
High-Voltage Wiring Best Practices
Wire Gauge Recommendations
| Load Current | Recommended Wire Gauge | Typical Use |
|---|---|---|
| Up to 2A | 22 AWG | LED lights, small fans |
| 2-5A | 18 AWG | Lamps, pumps |
| 5-10A | 16 AWG | Heaters, motors |
| 10-15A | 14 AWG | High-power devices |
Wiring Safety Rules:
- โ Use stranded wire for flexibility (not solid core)
- โ Use different colors for LINE (hot), NEUTRAL, and GROUND
- โ Use wire ferrules for screw terminals (prevents stray strands)
- โ Use cable ties to organize wires
- โ Keep low-voltage (3.3V/5V) and high-voltage wires separated
- โ Never work on live circuits - always disconnect power
- โ Don't exceed relay contact ratings (usually 10A for small relays)
Color Coding for AC Wiring (US Standard): โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ BLACK (or RED) โ LINE (Hot / L) โ โ WHITE โ NEUTRAL (N) โ โ GREEN (or BARE) โ GROUND (Earth / GND) โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Color Coding for AC Wiring (EU/International): โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ BROWN โ LINE (Hot / L) โ โ BLUE โ NEUTRAL (N) โ โ GREEN/YELLOW โ GROUND (Earth / GND) โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Common Wiring Configurations
Configuration 1: Lights (Multiple Rooms)
Relay 1 โ Living Room Light (150W) Relay 2 โ Kitchen Light (100W) Relay 3 โ Bedroom Light (60W) Relay 4 โ Bathroom Light (40W) Relay 5 โ Hallway Light (30W) Total load: ~380W (3.5A at 110V) - Safe
Configuration 2: Garden Automation
Relay 1 โ Water Pump (50W) Relay 2 โ Grow Lights (200W) Relay 3 โ Air Pump (20W) Relay 4 โ Heater (500W) โ Use external contactor if >10A Relay 5 โ UV Sterilizer (30W) Total load: ~800W (7.3A at 110V) - Near limit
Configuration 3: Workshop Tools
Relay 1 โ Dust Collector (1200W) โ Requires larger relay or contactor Relay 2 โ Air Compressor (1000W) โ Requires larger relay or contactor Relay 3 โ Shop Lights (100W) Relay 4 โ Fan (50W) Relay 5 โ Charger (100W) Note: High-power tools need external contactors or heavy-duty relays!
Standard 5V relay modules are typically rated for 10A at 250V AC (2500W). For loads above 1500W, use an external contactor or solid-state relay (SSR) for safety.
Using External Contactors for High Power
For loads above 1500W (e.g., heaters, motors, air conditioners), use the 5V relay to control a contactor:
High-Power Contactor Wiring: โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ โ โโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ โ โ ESP8266 โ โ 5V Relay โ โ Contactor โ โ โ โโโโโโโโโโโค โโโโโโโโโโโโโโโโค โโโโโโโโโโโโโโโโค โ โ โ 5V โโโโโโโโโโโค VCC โ โ Coil A1 โ โ โ โ GND โโโโโโโโโโโค GND โ โ Coil A2 โ โ โ โ D1 โโโโโโโโโโโค IN โ โ โ โ โ โโโโโโโโโโโ โโโโโโโโฌโโโโโโโโ โ โ โ โ โ โ โโโโโโโโโโโ โ โ โ NO โโโโโโโผโโโโโโโโโโโโโค โ LINE โ โ โ โ COM โโโโโโผโโโโโโโโโโโโโค โ LOAD โ โ โ โ โ โ โโโโโโโโโโโ โ โ โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโ โ โ โ โ The 5V relay switches the contactor coil (low current). โ โ The contactor switches the high-power load. โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Programming Multiple Relays
Sequential Control (Avoid Inrush Current)
When turning on multiple relays, especially with motors or pumps, turn them on sequentially with delays to avoid power spikes:
// In OceanRemote firmware, this is handled automatically // But for custom scripts, use delays: digitalWrite(relay1, HIGH); delay(500); // Wait 500ms digitalWrite(relay2, HIGH); delay(500); digitalWrite(relay3, HIGH);
Group Control (Turn All Relays On/Off)
OceanRemote doesn't have native group control, but you can use the API or create automation scripts:
// Example: Turn all relays OFF // Send individual commands or use packed format "s=00" https://www.oceanremote.net/api/device/state/?token=YOUR_TOKEN&s=00
The packed format "s=00" means all relays OFF. "s=1F" means all relays ON. Each bit represents a relay (bit 0 = relay1, bit 1 = relay2, etc.).
Troubleshooting Multiple Relays
Problem: Microcontroller resets when turning on multiple relays
- Cause: Power supply insufficient
- Fix: Use external 5V 2A+ power supply for relays
Problem: Relays don't activate in sequence
- Cause: WiFi interference or network delay
- Fix: Use packed format "s=XX" for simultaneous control
Problem: One relay works, others don't
- Check individual GPIO wiring
- Test each relay with a simple blink sketch
- Verify relay logic setting for each channel
Problem: Relays buzz or chatter
- Cause: Insufficient power or electrical noise
- Fix: Add a 100ยตF capacitor across VCC and GND of relay module
Add a 1000ยตF capacitor across the power supply near the relay module. This smooths voltage spikes when multiple relays activate simultaneously.
Best Practices Summary
- Power: Use external 5V 2A+ supply for 3+ relays
- Wiring: Daisy-chain VCC and GND, use separate GPIO for each IN
- Heat: Ensure ventilation, avoid running all relays continuously
- High Voltage: Use proper wire gauges, color coding, and safety procedures
- High Power: Use external contactors for loads >1500W
- Testing: Test each relay individually before testing multiple
- Documentation: Label your relays and wires for future reference
| Scenario | Power Supply | Notes |
|---|---|---|
| 1-2 relays | USB 500mA | OK for testing |
| 3-5 relays | 5V 2A | Recommended |
| 5+ relays | 5V 5A external | Use separate supply |
| High power (>1500W) | External contactor | Safety required |
Next Steps
Now that you understand multiple relay best practices, continue with:
- Tutorial 25: Common Connection Issues and Fixes
- Tutorial 21: Connecting Relays to Your Board (wiring guide)
- Tutorial 22: Understanding Positive vs Negative Logic
- Return to Tutorial 02: Generate firmware for your multi-relay setup!
You can now confidently wire and power multiple relays. Remember: proper power supply is the key to reliable multi-relay operation!