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.