Relay Logic: Switching Power with Signals

2026-04-23

A relay is an electrically operated switch. A small control signal energizes a coil, which generates a magnetic field that physically moves a contact to open or close a higher-power circuit. This is the fundamental mechanism that lets a 3.3V microcontroller pin switch a 240V pump — complete galvanic isolation between control and load.

Anatomy of a relay: A coil (electromagnet), an armature (the moving part), a spring (returns the armature when de-energized), and contacts. Contacts come in three configurations:

Key specifications to check before selecting a relay:

Real-world example: You're building a greenhouse controller. A Raspberry Pi reads a soil moisture sensor and needs to switch a 120VAC solenoid irrigation valve rated at 0.5A. You select a 5V coil SPDT relay rated for 10A @ 120VAC. The Pi's GPIO drives a 2N2222 transistor, which drives the relay coil. A flyback diode (1N4007) across the coil is mandatory — when the coil de-energizes, the collapsing magnetic field generates a voltage spike that will destroy your transistor without it.

Quick calculation: Coil resistance is 70Ω at 5V. Coil current = V/R = 5/70 = 71 mA. A 2N2222 can handle up to 800 mA, so it's well within limits. Base resistor for the transistor: assume hFE of 100 and a 3.3V GPIO. R_base = (3.3V − 0.7V) / (71mA / 100) = 2.6V / 0.71mA ≈ 3.6kΩ. Use a 3.3kΩ resistor to ensure saturation.

Solid-state relays (SSRs) replace the mechanical contact with a semiconductor (typically a triac for AC, MOSFET for DC). No moving parts means no contact bounce, no wear, and silent operation — but they generate heat under load and can't handle the same inrush currents as mechanical relays. Use SSRs for frequent switching (PWM heater control); use mechanical relays for high-inrush loads (motor starting).

See it in action: Check out Mastering Relay Logic: A Beginner’s Guide to Electrical Controls by ELECTRICAL LAD to see this theory applied.
Key Takeaway: A relay lets a low-power signal control a high-power circuit with full electrical isolation — but always protect the driving circuit with a flyback diode and never trust a relay's AC rating for DC loads.

All newsletters