I'm designing a device to switch a heating device driven by mains power. I've done quite a lot of research and realize there's a lot of information out there but as i'm dealing with potentially deadly AC i'd like to validate my design before ordering PCBs. This is my first time working with mains so please assume i know nothing :)


  • Switch a heating device (= resistive) load, up to 1000W
  • Compatible with 110-240V, 50 & 60hz
  • Driven by 5v MCU (ATMega328)
  • No need to pass regulations etc but absolutely needs to be safe
  • edit: Switching rate approx once every 5sec

Here's the schematic: enter image description here


  • D8 is the MCU pin
  • The resistor between the optocoupler and triac is a 1/4W through hole resistor, the other ones 0603
  • 5A quick blow fuse
  • The two 330 resistors in series are there to keep the BOM simpler
  • The triac switches mains neutral


  • First of all: is there anything here that i've missed or overlooked?
  • The heatsink on the triac is a bit unclear for me. I've calculated a maximum value of 10C/W, is this fine? My calculation is: (max temp - room temp)/(max on stage voltage * (milli amps / voltage)) - junction to base themal resistance ((110-25)/(1.65*(1000/230))-1.5 = ~10.35). Does this mean the triac will be at 110c all the time, seems a bit high to me?.. Ideally i would have a smaller heatsink though so i hope this is wrong :)
  • The optocoupler is random phase. The phase is only important for fading lights etc, right? Does the phase matter for a heating device?
  • Is a snubber circuit required? From what i understand this is only necessary for inductive loads?
  • Most of this circuit is on the bottom of a 2 layer 1.6mm board with other components min 4mm away on the top. From what i understand the creepage distance should be min 6mm but is it the same with the board in between?

I need to order the parts anyway so if you have suggestions for swapping components that's totally fine.


Any other tips or tricks are highly appreciated too!


After the tips here i changed the fuse to live (seems obvious now..) and added the snubbers. Updated schematic: Updated schematic

  • \$\begingroup\$ You haven't mentioned the switching rate, but if you only need to switch on/off every few minutes, it may be easier to be certain of your circuit's safety using a (5V or 12V) relay. There should be plenty of information on choosing a relay and driving it. \$\endgroup\$
    – user16324
    Jan 31, 2013 at 11:22
  • \$\begingroup\$ Brian: The switching rate is more than every few minutes, closer to every ~5sec. Also i don't want the noise of a relay \$\endgroup\$
    – Antti
    Jan 31, 2013 at 11:27
  • 2
    \$\begingroup\$ that would be 250W odd at 110V (assuming fixed resistance)... \$\endgroup\$
    – user16324
    Jan 31, 2013 at 12:34
  • 2
    \$\begingroup\$ Do you have a specific reason for fusing the neutral rather than the line? \$\endgroup\$
    – The Photon
    Jan 31, 2013 at 17:09
  • 2
    \$\begingroup\$ The reference designators in your original schmatic were poorly chosen. There's no need to tell the reader that R1 is linked to the opto-coupler ("opto-R1"), just name it "R1". But in your updated schematic you removed the refdes altogether, and that's even worse. If I want to discuss the 330R resistor there's no way to explain which one I mean. Always have a refdes with your components. \$\endgroup\$
    – amadeus
    Sep 1, 2013 at 6:44

4 Answers 4

  1. It's probably safer to have D8 drive a small MOSFET to control the photodiode instead of relying on the current-sourcing capability of the GPIO pin itself. You should also provide a bit more than the absolute minimum 5mA cited by the datasheet.

  2. A fuse should always be in the line - never only in the neutral. (Fusing both is OK.) If you fuse only the neutral, you still have a path from line to earth since in most jurisdictions, neutral is earthed somewhere. Dangerous and potentially lethal.

  3. Your heater load is most likely inductive in nature, so you should consider the resistor-capacitor-resistor gate scheme shown on page 6 of the datasheet to desensitize the gate. You can always no-populate the capacitor later if you don't need it.

  4. The device (without heatsink) has a junction-to-ambient resistance of 60K / W. Since your 1000W heater would draw around 4.34A of current when the triac is conducting, at 230VAC that's ~7W - at 100VAC it's more like 16.5A. You'll definitely need a heat sink :)

  • \$\begingroup\$ The MCU pin can source up to 40mA so i don't think i need the mosfet? I moved the fuse to the live terminal, which in hindsight seems obvious. I also added the snubber circuits as in the datasheet (still not sure on the values). The updated schematic was added as an edit to the question. Thanks! \$\endgroup\$
    – Antti
    Feb 6, 2013 at 10:51
  • \$\begingroup\$ It's usually a good idea to move that power dissipation outside of the microcontroller, even if the pin can source the power. It's extra heat that you don't necessarily want/need. \$\endgroup\$ Feb 6, 2013 at 13:58
  • 1
    \$\begingroup\$ Is it really ok to fuse both line and neutral? If only the neutral side fuse blows, there is still lethal power on the (now 'dead') equipment. \$\endgroup\$ Feb 6, 2013 at 17:45
  • \$\begingroup\$ There will still be protection if there's a fault between line and chassis/earth, and the lethal voltage should not be end-user accessible under any circumstances. \$\endgroup\$ Feb 6, 2013 at 17:58
  • 1
    \$\begingroup\$ National Electric code, article 404 (switches): Switches or circuit breakers shall not disconnect the grounded conductor (neutral) of a circuit. \$\endgroup\$ Feb 9, 2013 at 17:03

I am putting this as an answer, as my comment seems to be buried in the list.

Why are you switching (and fusing) neutral? That is not safe. Your heater will have mains voltage on it even when 'off'.

Add a mechanical switch on mains feed into it all, of course, so you know for sure everything is on or off.

Along those same lines, the ground path on the low voltage side should be solid to mains ground. Imagine what would happen if a stray bit of wire or whatnot drops across the opto-isolator. Will it fail safe? Or put your low voltage side at mains potential? You want it to fail safe, by blowing the fuse.


The snubber is recommended for several reasons.

  • Reduce amplitude of voltage from switched parasitic inductance. ( Egress) This reduces the voltage stress on the breakdown level of the Triac. Whenever you are switching long lines, you are switching inductance. THe OPto has a recommended snubber design. Use one like it on the Triac.

  • Reduce to line spike dv/dt using line inductance and snubber cap to prevent false triggering of triac.

There is no issue driving both the LED indicator and IR LED in parallel as the MCU will source or sink 20mA and the Opto only needs 10mA to reliably switch.

However there is no need to drive the LED's in parallel when you are using a 5V regulator.

- Drop voltage in the MCU driver is ~0.6V at 10mA and **~0.8V@20mA** ( hint search thru the pdf for VOH ) 
- drop voltage for "most" RED LEDs is ~1.3V @10mA, ~1.4V@20mA
- drop voltage for the IR LED used in the Opto is 1.2V @10mA and 1.3V @ 20mA
- so choose your drive current 10 ~ 20mA, add up the drops and choose a single R instead of 3 x 330.
- e.g.add up all drops above,  **0.8 + 1.4 + 1.3 + 20mA*Rs = 5V**  
- thus Rs = 1.5/20mA = **75 ohm**  ( 30mW)
- or   0.6 + 1.3 + 1.2 + 10mA*Rs = 5V   or Rs  = 1.9/10mA = **190 Ohm** ( 19mW)

Maintain >> 5mm safety gap between all AC and DC tracks used by the Optocoupler.

Is your 5V floating or ground to AC? Not required. but for EMI reawsons you may need a line filter to prevent ingress getting into your MCU sensor signals on teh AC input line with LC filter and maybe a small AC cap from DC to AC ground. You don't want your oven switching to get into your MCU signals. Ferrite beads are sometimes used on switched lines.

If the total Rth j-a is 10'W it means the triac will be toasty 110'C when active after thermal time constant which depends on mass and AIR speed. I would suggest closer to 5 'C/W for your heatsink and add the Rj-c of the triac to get thermnal resistance. also use a bit of grease with a small heatsink.


I am designing a similar circuit.

The only thing missing from this circuit is a transil to protect the triac from overvoltage spikes so it doesn't get damaged from external transients.

See - http://www.st.com/st-web-ui/static/active/cn/resource/technical/document/application_note/CD00022856.pdf

It would also be possible to use a MOV but this seems more elegant.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.