- ✓ 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!