The optimal discrete AC solid state relay circuit for 3.3V microcontrollers uses a zero-crossing opto-TRIAC (like the MOC3063) to drive a snubber-protected power TRIAC (like the BTA16-600B). For a standard 120VAC, 60Hz system driven by an ESP32 or Raspberry Pi Pico, you need a 220Ω input current-limiting resistor, a 330Ω gate resistor, and a 39Ω/0.01µF snubber network. This topology provides galvanic isolation, handles up to 16A, and costs under $2 in components compared to $20+ for a panel-mount module.

The Discrete AC Solid State Relay Circuit Topology

A discrete SSR replaces the mechanical contacts of a standard relay with a semiconductor switch (a TRIAC for AC loads) and replaces the physical coil with an opto-isolator. This specific topology is divided into a low-voltage DC control side and a high-voltage AC load side, separated by an optical gap.

Node Labels & Signal Path:

  • DC Control Side: MCU_GPIO (3.3V) → R_LIMITOPTO_ANODE (Pin 1) → Internal LED → OPTO_CATHODE (Pin 2) → GND.
  • AC Load Side: AC_LINE (Hot) → LOADTRIAC_MT2. Current returns via TRIAC_MT1AC_NEUTRAL.
  • Gate Drive Path: AC_LINE (tapped before load) → OPTO_TRIAC (Pins 6 & 4) → R_GATETRIAC_GATE.
  • Snubber Network: Placed in parallel across TRIAC_MT1 and TRIAC_MT2 to suppress voltage transients.

Why This Topology Over Mechanical or Black-Box SSRs?

You have three main options for switching AC loads: mechanical relays, panel-mount SSRs (like the Omron G3NA), and discrete opto-TRIAC circuits. Here is why the discrete topology wins for custom PCB and high-density breadboard prototyping.

CriteriaMechanical Relay (e.g., SRD-05VDC)Panel-Mount SSR (e.g., Omron G3NA-210B)Discrete SSR (MOC3063 + BTA16)
BOM Cost$1.50 - $3.00$15.00 - $25.00$1.20 - $1.80
Lifespan (Cycles)~100,00010,000,000+Infinite (Solid State)
Switching Speed5ms - 10ms (Bounce)1/2 AC Cycle (Zero-cross)1/2 AC Cycle (Zero-cross)
FootprintMediumMassive (Requires panel mount)Compact (TO-220 + DIP-6)
Heat ManagementNoneIntegrated baseplateRequires external heatsink

The Verdict: Choose the discrete topology when you are designing a custom PCB, need to keep BOM costs under $2, and have the space to mount a TO-220 heatsink. Defer to panel-mount SSRs only when you need UL-listed, pre-packaged isolation for industrial enclosures.

Component Selection & Design Walkthrough

Let's design this circuit for a 120VAC, 60Hz mains supply driving a 5A inductive load (like a small AC motor or solenoid), controlled by a 3.3V ESP32 GPIO pin.

1. The Opto-Isolator (Zero-Crossing)

We select the ON Semi MOC3063M. Unlike the MOC3021 (random-phase), the MOC3063 features an internal zero-crossing detector. It will only trigger the TRIAC when the AC sine wave is within ~20V of zero. This eliminates massive inrush currents and prevents electromagnetic interference (EMI) that would otherwise reset your microcontroller.

2. Input Current-Limiting Resistor (R_LIMIT)

The MOC3063 internal LED has a forward voltage ($V_f$) of 1.2V and requires a trigger current ($I_F$) of 10mA (maximum 15mA).
$R = (V_{GPIO} - V_f) / I_F = (3.3V - 1.2V) / 0.010A = 210\Omega$.
Concrete Pick: 220Ω 1/4W resistor. This yields ~9.5mA, safely within the trigger threshold while minimizing GPIO stress.

3. Gate Drive Resistor (R_GATE)

This resistor limits the current flowing from the AC line, through the opto-TRIAC, into the power TRIAC's gate. The STMicro BTA16-600B requires a maximum gate trigger current ($I_{GT}$) of 50mA. The peak AC voltage is $120V \times \sqrt{2} = 170V$.
$R = 170V / 0.050A = 3400\Omega$. However, to ensure hard triggering across temperature extremes, we overdrive the gate slightly. The MOC3063 can handle 1A peak surge.
Concrete Pick: 330Ω 1/2W resistor. This provides ~500mA peak gate current for a fraction of a millisecond, guaranteeing the BTA16 latches instantly.

4. The Snubber Network

When switching inductive loads, the voltage across the TRIAC can spike rapidly when current crosses zero (commutating $dv/dt$). If this spike exceeds the BTA16's $dv/dt$ rating (typically 500V/µs), the TRIAC will falsely trigger and stay ON. A series RC snubber clamps this rate of rise.
Concrete Pick: 39Ω 1/2W resistor in series with a 0.01µF 250VAC X2-rated film capacitor. The X2 safety rating is mandatory here; if the capacitor fails short, it will not cause a fire or shock hazard.

Pro-Tip: Always place the snubber as physically close to the TRIAC's MT1 and MT2 pins as possible. Long PCB traces add parasitic inductance, which defeats the high-frequency clamping purpose of the snubber.

Behavior Matrix & Failure Extremes

Understanding how this circuit fails is critical for troubleshooting. Here is what happens when individual elements drift or fail at the extremes.

ElementChange / ExtremeResulting BehaviorFailure Mode / Hazard
R_LIMIT (220Ω)Open / Too High (>1kΩ)Opto LED doesn't fire.Load never turns ON. Safe.
Snubber Cap (0.01µF)Missing / OpenHigh $dv/dt$ spikes pass to TRIAC.Load turns ON randomly when switched off (inductive kickback).
Snubber Resistor (39Ω)ShortedCapacitor dumps raw current into TRIAC gate upon turn-on.Destroys MOC3063 output TRIAC; potential short circuit.
R_GATE (330Ω)OpenNo gate current reaches BTA16.Load never turns ON. Safe.
MOC3063 OutputShorted (MT1 to MT2)Gate receives continuous AC voltage.Load stays ON permanently. MCU loses control.
BTA16 Power TRIACShorted (MT1 to MT2)AC line connects directly to load.Load stays ON permanently. Requires physical breaker reset.

Breadboard & Bench Testing Protocol

MAINS VOLTAGE WARNING: Never breadboard or probe the AC side of an SSR circuit with live 120VAC/230VAC. Always validate the topology using a low-voltage AC source first. When transitioning to mains, use a GFCI-protected outlet, verify dead with a CAT III multimeter, and ensure your TRIAC is mounted to a properly grounded heat sink.

Follow these numbered steps to validate your solid state relay circuit safely on the bench:

  1. Isolate the DC Side: Build only the MCU, R_LIMIT, and MOC3063 LED section. Power the ESP32 via USB. Write a simple blink sketch (1Hz).
  2. Verify Opto Trigger: Set your multimeter to DC voltage. Probe across the MOC3063 LED (Pins 1 and 2). You should see ~1.2V when the GPIO is HIGH, and 0V when LOW. If you see 3.3V, your LED is dead or R_LIMIT is open.
  3. Introduce Low-Voltage AC: Connect a 12VAC, 1A wall transformer to the AC_LINE and AC_NEUTRAL nodes. Connect a 12V incandescent bulb or LED indicator (with rectifier) as the LOAD.
  4. Test the Gate Drive: Set your multimeter to AC voltage. Probe across the BTA16 MT1 and MT2. When the MCU GPIO goes HIGH, the voltage across MT1/MT2 should drop to near 0V (the TRIAC is conducting). When LOW, it should read ~12VAC.
  5. Validate Zero-Crossing: If you have an oscilloscope, probe the load. You should see clean, full sine waves starting exactly at the zero-crossing point. If the sine wave is 'chopped' at random phase angles, your MOC3063 is either faulty or you accidentally bought a random-phase opto (like the MOC3021).
  6. Mains Transition: Only after the 12VAC test passes, move the circuit to a perfboard or PCB. Wire the 120VAC mains using 14 AWG THHN wire, secure all connections with proper lugs, and test behind a closed enclosure.

Decision Tree: Zero-Cross vs. Random Phase vs. DC MOSFET

Not every load requires a zero-crossing AC TRIAC. Use this decision path to select the exact topology for your application.

If Your Application Is...Then Choose This TopologyConcrete Part Numbers (Default Pick)
Resistive AC loads (heaters, incandescent bulbs) where EMI must be minimized.Zero-Crossing Opto-TRIAC + Power TRIACMOC3063 + BTA16-600B
Phase-angle dimming (dimmable LED drivers, universal motors) requiring mid-cycle switching.Random-Phase Opto-TRIAC + Power TRIACMOC3021 + BTA16-600B
High-current DC loads (12V/24V motors, solenoids, heating elements).Opto-isolated N-Channel MOSFETTLP250 + IRFB4110PbF
Low-current DC loads (<2A) like 12V LED strips or small fans.Direct Logic-Level MOSFET (No opto needed if sharing ground)AO3400 (SOT-23) or IRLZ44N

Default Recommendation: For 90% of maker and IoT home-automation projects involving AC mains (smart plugs, automated blinds, coffee makers), the MOC3063 + BTA16-600B zero-crossing topology is the definitive choice. It protects your microcontroller from EMI resets, eliminates inrush current stress on your power supply, and requires only four passive components to implement safely.