Fan controller

20.1.2021

Controlling DC loads is simple but can be quite tricky for AC, especially for inductive loads. I had set a challenge to control AC fan.

Technical equirements for controller:

Voltage control with triac (suitable for AC fan)

MQTT-protocol for controlling speed

Wireless control through WiFI

Simple to integrate to existing home automation

Max load 2000W@230V, 50Hz

Snubber circuit for AC noise suppression

Safety requirements

Fuse

Casing, plastic, good isolation

Optocoupler to isolate both control- and input- signals

Dedicated power supply for microcontroller

Background

We need to be able to detect phase current and trigger triac at right moment. Our system receives control value from mqtt -server. If not, fan simply does not start, since output voltage is (nearly) zero. To detect phase current, we need to tap into this voltage source. I decided to use PCB-transformer to drop the voltage from 230 to 15V. It also needs to be rectified for both half waves (full bridge rectifier) After this I used optocoupler to pull down one of the input pins in ESP8266 microcontroller and so we have a phase detector.

To control thyristor, we need to have dedicated driver ic, which is also opto isolated. Triac must be controller for both half waves or otherwise it is not conducting.

I used KiCad to create schematic.

Another great feature is to be able to see how it looks in 3D (after selecting all corresponding components)

After this only thing to do was to order components and manufacture the pcb. I used JLCPCB to supply the board (5 pcb for 5,79€). After waiting few months, last parts arrived (some X2 rated capacitors took ages to arrive).

Wemos D1 mini is attached with pin headers, so it can be programmed outside the system (mainly because of safety). There is a jumper to select 3.3V or 5.0V voltage depending which Hi-Link power supply is used. Is had to leave my options open, since availability of these modules was a challege (did no know which one would come first).

Test

It was time the test the circuit. I had already working code, since I had time to think while waiting the parts to arrive. Using mqtt-client is trivial, since I had alot of experience using it with HVAC to IR -controller and many other previous projects. Only thing I had to adjust was the resistor values for phase detection. Next version should have trim-pot. I was using too large resistor value, so I got delayed phase values at first (and loosing ouput power).

After wiring everything and slowly cranking up variac (adjustable voltage supply) I got system running. I had already tested triacs on breadboard so this was just prooving my pcb design was correct.

Ideas for future improvement

Miniaturization by using surface mount components –> wall mount, inside switch box

Getting rid of Hi-Link module, by using full bridge rectifier (similar or same to phase detection).

PCB-transformer –> smaller unit

Software with internal 50Hz timer which is syncronized according to 50Hz outlet reference. This is used to block possible phase detection problems (one or two bad phase detections does not lead to out of sync output).

OTA (over the air) programming (for firmware update)?

Voltage measurement

Current measurement

= Energy meter