MOC3021

Photo of author

By Jackson Taylor

As an Amazon Associate we earn from qualifying purchases.

The MOC3021 is an opto-isolated TRIAC driver. A small infrared LED on the input side switches a light-sensitive TRIAC on the output side, so a low-voltage circuit can control an AC load without any electrical connection to the mains. This page covers the forward characteristics of the input LED, tested at a 5V supply with a BT136 TRIAC switching a 100W lamp, and shows how to pick the series resistor.

MOC3021 forward characteristics test

The test looks at what happens on the input side as the series resistor changes. For each resistor value, it records the voltage across the LED, the current through it, and whether the lamp turned on.

Test conditions

  • Input voltage = 5V
  • Output connected to TRIAC BT136
  • Load: 100W lamp

Symbols used in the table

  • R – series resistor on the input side
  • V – voltage across the input LED of the opto-coupler
  • I – input current through the LED
  • O/P – output state of the 100W lamp load
MOC3021 test table of series resistor, LED voltage, input current and lamp output state

The image above holds the measured table for these conditions. The sections below explain how to read it and why the numbers come out the way they do.

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video

What the MOC3021 does

The MOC3021 comes in a 6-pin DIP package. Inside are a gallium arsenide infrared LED and a photo-TRIAC. When enough current flows through the LED, the photo-TRIAC conducts and can trigger the gate of a larger TRIAC such as the BT136.

It is a random-phase driver, which means it has no zero-crossing detection. It can turn on at any point in the AC cycle. That is fine for simple on/off switching of a lamp or heater, but it is the wrong choice if you want a clean, low-noise switch at the zero crossing.

The photo-TRIAC inside is small. It is only meant to trigger a power TRIAC, not to carry the lamp current itself. That is why the BT136 is in the circuit.

See also
3 *4 KEYPAD INTERFACING WITH ARDUINO

The input side: LED voltage and series resistor

The input LED behaves like any other LED. Its forward voltage stays fairly constant at around 1.2V to 1.5V once it conducts, and the current is set by the resistor in series with it. Ohm’s law gives the resistor value:

R = (Vin – V) / I

With a 5V input and an LED voltage of about 1.2V, the resistor drops roughly 3.8V. The table below shows the LED current this gives for common resistor values. These are calculated estimates that assume a 1.2V LED drop, not measurements, so your own readings will differ a little.

  • 100 ohm: about 38 mA
  • 150 ohm: about 25 mA
  • 220 ohm: about 17 mA
  • 330 ohm: about 11.5 mA
  • 470 ohm: about 8 mA
  • 1 kohm: about 4 mA

Why the current matters

Each MOC302x part has a trigger current, shown on the datasheet as IFT. This is the minimum LED current that reliably switches the output on. The MOC3021 is rated for a maximum trigger current of 15 mA, so the LED needs at least that much to fire. In practice, aim a little above it.

At the same time, the LED has a maximum continuous current, so you should not push it much beyond the datasheet limit. A resistor of around 220 ohm at 5V sits comfortably between the two. Values such as 470 ohm or 1 kohm leave too little current, and the lamp may not switch on, or may flicker.

This also explains the pattern in the test table. At low resistor values the lamp is ON, and as the resistor grows the LED current drops below the trigger level and the output stays OFF.

The output side: driving a BT136 and a 100W lamp

A 100W lamp draws about 0.43 A on a 230V supply, or about 0.83 A on 120V. The BT136 is a 4A TRIAC, so a single lamp of this size is well inside its rating.

Sustainable Tech

Keep Toxic E-Waste Out of Landfills

Don't throw away your failing laptop, phone, or car batteries. Learn how to recondition them at home in just a few hours. It's better for the planet—and your wallet.

Learn How It Works
See also
Embedded Controlled High Efficiency Improved Boost Converter for Solar Installation System

The usual connection looks like this:

  1. Pin 1 (LED anode) goes to the 5V supply through the series resistor.
  2. Pin 2 (LED cathode) goes to ground, or to a switching transistor or microcontroller pin that sinks the current.
  3. Pin 6 connects to the mains line through a current-limiting resistor.
  4. Pin 4 connects to the gate of the BT136.
  5. The lamp is wired in series with the BT136 across the AC supply.

Pin 3 is not connected, and pin 5 is an internal substrate pin that should be left unconnected. Check the pinout of your exact part against its datasheet before wiring. The value of the resistor between the mains and the optocoupler depends on the supply voltage and on the peak current rating of the photo-TRIAC, so take it from the datasheet circuit rather than guessing.

Practical tips

  • Check the source current. A microcontroller pin may only be able to supply around 20 mA or less. If your resistor is set for 15 to 20 mA, a small transistor between the pin and the LED is safer.
  • Use a snubber for inductive loads. A lamp is a resistive load and is easy. Motors and transformers need an RC snubber across the TRIAC, because the voltage and current are out of phase when the TRIAC turns off.
  • Add a heatsink if needed. A 100W lamp produces little heat in the BT136, but heavier loads will need one.
  • Test at low risk first. Try the input side alone with a multimeter before connecting the output to the mains.

Safety

The input side of this circuit is low voltage, but the output side connects to the mains. Do not touch the circuit while it is powered, use proper insulation and an enclosure, and keep the low-voltage and mains wiring well apart on the board. If you are not experienced with mains wiring, use a pre-built, certified module instead.

FAQ

What is the MOC3021 used for?

It isolates a low-voltage control circuit, such as a microcontroller, from an AC load, and triggers a TRIAC to switch that load on and off.

See also
MSP430 - GCC

Can the MOC3021 drive a lamp directly?

Only very small loads, within its low output current rating. For a 100W lamp, use it to trigger a power TRIAC such as the BT136, as in this test.

What series resistor should I use at 5V?

A value around 220 ohm gives roughly 17 mA through the LED, which is above the 15 mA maximum trigger current of the MOC3021. Larger values reduce the current and may stop the lamp from switching reliably.

Does the MOC3021 have zero-cross detection?

No. It is a random-phase driver. If you need switching at the zero crossing, look at the MOC3041 family or a similar zero-cross part.

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works