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. | Name | Function |
---|---|---|
1 | Anode (A) | LED Positive Terminal (Control Input) |
2 | Cathode (K) | LED Negative Terminal (Ground) |
3 | NC | No Connection |
4 | Triac Main Terminal 1 (MT1) | AC Output Terminal 1 |
5 | NC | No Connection |
6 | Triac 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 Pin | Arduino 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 MT1 | AC Neutral |
Triac MT2 | AC 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
Feature | MOC3021 | MOC3061 (Zero-Crossing) | PC817 (Transistor Output) |
---|---|---|---|
Isolation Voltage | 7.5kV | 7.5kV | 5kV |
Output Type | Triac Driver | Triac Driver with Zero-Crossing | Phototransistor |
Best For | AC Load Switching | AC Dimming, Low-EMI Switching | Microcontroller 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.