MOC3021: Optocoupler with Triac Output for AC Switching

The MOC3021 is an opto-isolated Triac driver designed for safe AC switching. It is commonly used in solid-state relays (SSR), dimmers, motor speed control, and microcontroller-based AC control circuits.


πŸ”Ή 1. What is the MOC3021?

  • The MOC3021 is an optocoupler with an infrared LED and a zero-crossing Triac driver.
  • It provides electrical isolation between a low-voltage microcontroller (Arduino, ESP32, STM32, etc.) and high-voltage AC loads.
  • When the internal LED is activated, the Triac driver switches ON, triggering an external Triac to control AC power.

πŸ“Œ Key Features:

  • Electrical isolation up to 7.5kV.
  • Can switch AC loads up to 400V.
  • No direct electrical connection between control and AC circuits.
  • Eliminates switching noise and protects microcontrollers from high voltage spikes.
  • Zero-Crossing Version (MOC3061, MOC3063) is also available for lower EMI (Electromagnetic Interference).

πŸ“Œ Why use it?

  • Safe AC load switching using low-voltage logic signals.
  • Microcontroller protection from high-voltage AC circuits.
  • Silent solid-state switching (no mechanical relay noise).

πŸ”Ή 2. MOC3021 Pinout & Functions

The MOC3021 comes in a 6-pin DIP package.

Pin No.NameFunction
1Anode (A)LED Positive Terminal (Control Input)
2Cathode (K)LED Negative Terminal (Ground)
3NCNo Connection
4Triac Main Terminal 1 (MT1)AC Output Terminal 1
5NCNo Connection
6Triac Main Terminal 2 (MT2)AC Output Terminal 2

πŸ“Œ How it works:

  • Pins 1 & 2 β†’ Control the internal LED.
  • When the LED is ON, the Triac driver switches ON (Pins 4 & 6).
  • The external Triac gets triggered, switching AC power to the load.

πŸ”Ή 3. How MOC3021 Works

  • A microcontroller sends a signal to the internal LED (Pins 1 & 2).
  • The LED activates the phototriac driver.
  • The Triac output (Pins 4 & 6) triggers an external Triac.
  • The external Triac allows AC current to flow, turning ON the connected lamp, motor, heater, or any AC load.

πŸ“Œ Unlike mechanical relays, MOC3021 allows for fast and noise-free switching.


πŸ”Ή 4. Using MOC3021 to Control an AC Load

πŸ›  Required Components

  • 1x MOC3021 Optocoupler
  • 1x External TRIAC (e.g., BT136, BT138)
  • 1x 330Ξ© Resistor (LED Current Limit)
  • 1x 470Ξ© Resistor (Gate Resistor for Triac)
  • 1x 10kΞ© Resistor (Pull-down for Triac)
  • 1x AC Load (e.g., Bulb, Fan, Heater)
  • 1x Arduino or ESP32
  • AC Power Source (110V / 220V)

πŸ›  Wiring Diagram

MOC3021 PinArduino Pin / External Circuit
Anode (Pin 1)D7 (Arduino Output Pin)
Cathode (Pin 2)GND (Arduino Ground)
MT1 (Pin 4)AC Load (One Terminal)
MT2 (Pin 6)Gate of Triac (via 470Ξ© Resistor)
Triac MT1AC Neutral
Triac MT2AC Live to Load

πŸ“Œ ⚠ WARNING:

  • Never work with live AC circuits without proper isolation and safety precautions.
  • Use a fuse for protection.

πŸ”Ή 5. Arduino Code for MOC3021

#define OPTOCOUPLER 7  // Connects to MOC3021 Anode (Pin 1)

void setup() {
    pinMode(OPTOCOUPLER, OUTPUT);
}

void loop() {
    digitalWrite(OPTOCOUPLER, HIGH);  // Turn ON AC Load
    delay(5000);  // Wait 5 seconds
    digitalWrite(OPTOCOUPLER, LOW);   // Turn OFF AC Load
    delay(5000);
}

πŸ“Œ What happens?

  • The Arduino turns ON/OFF the MOC3021 LED.
  • The LED triggers the internal Triac driver.
  • The external Triac switches ON the AC load.

πŸ”Ή 6. Using MOC3021 for AC Light Dimming

πŸ“Œ AC dimming is possible using phase-angle control (PWM + Zero-Crossing Detection).

For AC dimming, use:

  • MOC3021 + External TRIAC + Zero-Crossing Detector (H11AA1).
  • Adjust phase delay using PWM signals from Arduino.

πŸ“Œ For better dimming, use MOC3061/MOC3063, which have zero-crossing detection built-in.


πŸ”Ή 7. Applications of MOC3021

βœ… Microcontroller-Based AC Switching – Controls lamps, motors, heaters.
βœ… Solid-State Relays (SSR) – Used in silent, fast-switching AC relays.
βœ… AC Motor Speed Control – Used in fan speed regulators.
βœ… Dimmer Circuits – Controls light brightness using phase-angle control.
βœ… Industrial Automation – Isolates low-voltage control systems from AC power.


πŸ”Ή 8. MOC3021 vs Other Optocouplers

FeatureMOC3021MOC3061 (Zero-Crossing)PC817 (Transistor Output)
Isolation Voltage7.5kV7.5kV5kV
Output TypeTriac DriverTriac Driver with Zero-CrossingPhototransistor
Best ForAC Load SwitchingAC Dimming, Low-EMI SwitchingMicrocontroller Isolation

πŸ“Œ Verdict:

  • MOC3021 is best for general AC switching.
  • MOC3061 is better for noise-free AC dimming (zero-crossing switching).
  • PC817 is for low-power DC signal isolation.

🎯 Conclusion

  • MOC3021 is an optocoupler with a built-in Triac driver, designed for safe AC switching.
  • Used in solid-state relays, motor control, dimmers, and industrial automation.
  • Requires an external Triac (e.g., BT136, BT138) to control high-power AC loads.
  • Safer and more reliable than mechanical relays.
πŸ“‘Broadcast the signal β€” amplify the connection.

Leave a Reply