April 07, 2019

WiFi controlled fan - Options

My quest (spoiler: ultimately successful) to smart-ify a pedestal or box fan.

Spoiler: The finished product

Overview

I have a Xiaomi smart socket that could turn my fan on or off at the wall, and to be honest that's quite useful, but I wanted more. I wanted to be able to control the speed remotely as well. Fans are not that complicated right? It should be easy enough to modify the internals of a fan to support this.

My list of requirements:

  • The solution must work with a fan that is domestically available, and ideally not too expensive.
  • I need to be able to turn it on and off remotely, as well as control the speed remotely.
  • It should integrate with Home Assistant.
  • Ideally the existing controls on the fan should also work, so it can be controlled manually or remotely.
The first phase of this project was to find out how the speeds of these fans are normally controlled, and how they might be controlled by a micro-controller.

Pulse Width Modulation (PWM) for DC

For a fan that uses a DC motor, PWM might be a good solution. I'm planning on some kind of ESP8266 module as the MCU, and a circuit using the ESP8266's PWM output to switch a suitable MOSFET should work nicely. (I have used this approach for LED lighting in the past.)

While I'm sure they do exist, I looked around for a cheap fan with a DC motor, but didn't find one. I suspect this is partly because fans with 3-speed AC motors are cheap, very common, and they do the job.

If I were to find one, I would still like to build this kind of control. Your maximum speed is when your PWM is at 100% duty cycle. You'd need to do some testing to find out what your minimum duty cycle is for the fan you have. Below a certain minimum and you won't have enough torque to get it started.

PWM for AC

Dimmer circuits often use PWM, but you can't just vary the duty cycle at the 3kHz that your MCU supports. You need to vary it in phase with the AC (50 or 60 Hz). It is possible to get triacs that can switch higher AC voltages (240V for me).

I did explore this option a bit, but there were a few show stoppers for me:
  • Motors that have windings that suit this kind of control are not commonly used in cheap desktop cooling fans. (Common in ceiling fans though.)
  • In order to vary the duty cycle in phase, you need a circuit to detect when the voltage crosses zero, so you know when to turn your triac on and off. This is not such a complex circuit, but there's a high voltage side to this circuit, so a bit of extra care is involved. The former point was more of a problem really.

An AC motor with distinct windings

These kinds of motors are very common. The fan has a concrete number of speeds (generally 3). Each speed has its own winding inside the motor. The switch (or knob) selects which winding to supply power to.

Fan Motor Windings: Gene Haynes http://waterheatertimer.org/How-to-wire-3-speed-fan-switch.html
What if I swap out the speed switch for a set of relays (controlled by the MCU)? The relays would switch power to the windings. Then if I wire up the original switch as a voltage divider, I can get the MCU to detect the switch position by measuring the voltage. Thus the MCU can change the speed if someone moves the switch.

Sounds like a plan.

No comments: