PCBWAY PCB service

PCBWAY PCB service


BlueTooth controlled TRIAC dimmer


First of all, this project will be a bit dangerous since I will use mains power, which here in Spain is 220V AC which could injure you in a fraction of a second. So, before you start, if you are not sure about anything, don’t try this project, if you don’t have proper tools, if you don’t check and double check the connections before applying power, and also never, never, touch the circuit while power is on, well, don’t try this project, just sit back and learn.

Una publicación compartida de ELECTRONOOBS®️ (@electronoobs) el

See the full part list here:

PART 1 Zero cross detection

The first thing to do is to analyze the AC voltage. I’ve connected my oscilloscope to the mains input of my home. As you can see below we have a sine wave of 310 volts peak to peak or 220V RMS. The frequency is usually between 50 and 60 HZ.
We have a positive part and a negative one so there will be a zero crossing so we will have to detect that 0 cross. Using a component called TRIAC, we will control the amount of time that this power is ON and OFF. Let’s see how this TRIAC works.

AC wave TRIAC Arduino

We all know diodes. Put just one diode to an AC signal and we’ve got ourselves a half wave rectifier. With just one diode, in this case we will only have the positive part of the AC signal as you can see below, since the diode won’t let the negative part to pass. But what if we could activate or deactivate this diode. There is a component that could do that and it is called a THYTISTOR, which basically is a controlled diode that will be activated when the gate receives a current trigger and continuing to conduct while the voltage across the device is not reversed.

AC wave full rectifier Arduino

So here we have our AC signal below. The negative part won’t pass since we use a diode. But on the positive part, if we don’t switch the THYRISTOR there won’t be the positive part neither. So, let’s say that exactly in the middle position we activate the gate of the THYTISTOR with a pulse, now we let the remaining part of the positive side of the AC wave. So now we have just half of the positive wave, so we have regulated the power.
But if we want to do this with both positive and negative sides, we should use two THYRISTORS in an antiparallel configuration. One will control the positive side and the other the negative. There is a component that dose that, called a TRIAC.

AC triac fire pulse

The TRIAC will remain deactivated till it receives a pulse at its gate. Once received, it will remain activate till the main input will change its polarity.

So, here is what we are going to do. I’ll use the BTA16 TRIAC to control AC voltage. The first thing to do is to detect the zero cross since our pulse needs to be in phase with the AC voltage. So, we have to detect when the voltage passes from positive to negative or from negative to positive and synchronize our pulse with that so it will fire always in the same spot. For that I’ll use a full bridge rectifier. This will give me at the output both the positive and negative curves of the AC wave and I do that since Arduino can’t work with negative values. Here below on my oscilloscope I have the input (green) and the output (yellow) from the full bridge rectifier.

AC full rectifier

Zero cross schematic

I’ll also add two 47 kilo ohms resistors to limit the current. Now I want to separate the high voltage side from the low voltage side, which in this case will be an Arduino microcontroller. For that I’ll use an EL317 optocoupler. In this way there is no direct connection between 220V high voltage and 5V of the Arduino.
I add a pullup and pulldown resistors as in the schematic below, which by the way you could download from a link below and now I connect the oscilloscope to the output.

AC arduino zero cross detection

As expected I have some sort of trapezoidal wave with a peak to peak of 5 volts. Now I read that with the Arduino, and I’ll create an interruption each time I detect these low values, and that will be our zero cross. Since we’ve used a full bridge rectifier, we will have the zero cross for both rising and falling parts of the AC Wave.

AC arduino zero cross detection

Now in order to control the gate of the TRIAC, we will use diode AC switch or better called DI AC or diac. The Diac is a very useful device which can be used to trigger triacs because of its negative resistance characteristics that allows it to switch “ON” rapidly once a certain applied voltage level is reached.

PART 2 Schematic - potentiometer

So, this will be our final schematic. We read the zero cross with the full bridge rectifier and the optocoupler. Then we create a firing pulse applied the opto-insulated DIAC through this resistor and an LED. I say opto-insulated because once again, this IC has a light control of the diode inside so we separate the 5V from the Arduino and the 220V applied to the TRIAC.

AC TRIAC dimmer Arduino schematic