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