220v/110v AC Dimmer/Speed controller for ESP8266

Tags: #<Tag:0x00007f616ca0dca8> #<Tag:0x00007f616ca0db40> #<Tag:0x00007f616ca0d910>

I was looking for something to control my ceilling fan speed at 220v, but I could find only modules that can control LED lights to control the brightness. Recently I found a module that can handle upto 2 Ampheres of power either in 110v/220v AC with a zero cross dectector. I need to use this module using tasmota and OpenHAB. Could somone please help me. I have seen a lot of people wated to control their fan speed and incandesecent lamps using such module. Link to the module is :


There is no information on the site
The board offers VCC, GND, Zero-Crossing and PWM pins thats all
But no details on what they do

but I think somthing related to the LED dimming may work on this module too… Could you please provide details on that using ESP8266 based board…?

Sorry but I don’t have that sort of code at all

ok… may be someone else


int i;
int ZDpin=0;
void setup(){

void light(){

void loop(){


void pwm()
  for (int a=0; a<=255;a++)                
    for (int a=255; a>=0;a--)             

From here

can i use tasmota for this purpose…? Could you please explain this…?

No, somebody has to implement

so what does PWM in tasmota do…? I mean where else I can use it…?

Sorry, no idea. I just found the module and the arduino demo code…
I am not a programmer.

May you ask in Tasmota Github, not a forum but there are friendly skilled programmers :slight_smile:

OK thank you for your advice. Could you please explain the code you wrote above. I saw you used four pins of ESP8266.

That’s arduino code not ESP8266. It may be similar but there are significant differences including pin assignment.
You will have to google around for code ESP code for AC dimmers
Unless someone on the openHAB forum has some code, this is still an openHAB forum and not arduino or ESP.

Sonoff made a new product, specific for controling a ceiling fan! with 3 levels of speed (voltage).
I think it’s already supported by the latest Tasmota firmware whice makes it an ideal MQTT controller.

Ceiling fans should be controlled via capacitive means.
Here is a google quote.
The idea behind a capacitor regulator remains the same, which is to adjust the voltage across the motor of the fan. Now, when you increase the capacitance, the voltage across the capacitor decreases but that across the fan motor increases. Accordingly, the speed of the fan increases.

I used a series of relays to switch several capacitors in series/parallel to adjust to four speeds. When done with capacitors no motor hum is generated.



PWM stands for “Pulse Width Modulation”

Commonly found in low voltage lighting dimmers, or Servo controllers.

What type of PWM signal it expects will determine how you control it.

If you’re really lucky…

It will use a PWM protocol similar to a servo.
In which case you might want to consider a DMX to Servo controller, then use the DMX binding in OpenHab2

If it expects a PWM signal similar to that required by a LED lamp, you will find hundreds of different LED dimmers out there, just take your pick of your preferred protocol. IE.
Velbus, KNX, Modbus, Z-WAVE

1 Like

Now that is a neat solution.

Do you use an IP relay array to select the capacitor ?

No I have Clipsal C-Bus in the house and used a couple of channels on a 12 channel relay. Came up with this solution a few years before Clipsal came out with their fan controller, never had the need to change works.


Like that idea.
Have to keep it in mind.

I love idea and I thought of it… The problem I’m having is 4 channel relay will occupy more space than that dimmer Module, so that I can’t hide it inside my switch board… I have put a separate box near to the da switch. Anyways thank you for
your reply :grinning: