Using ESP8266 [Sinilink XY-WFMS] to control a 5V fan

Hi everyone,

I’m after some brainstorm input here :wink:

I recently got a cheap 5V fan from Amazon. For a small 5V job, it’s surprisingly powerful. Considering it’s size and reduced power consumption, I want to replace a few 240V desk fans that are just connected to smart plugs.

It’s got a button on the back of it to switch:

Low > Medium > High > Off in that order.

I’ve been thinking about how I could make this a smart fan. I have considered using a plain 5V fan and ESP, but the above product obviously has a nice enclosure and stand.

The only way that I can see that I might make this smart, would be:

  1. Gut it - then use an ESP and esphome to control the an directly.

  2. Attach an ESP to monitor the PWM wire and ‘press’ the button multiple times until the required signal is read

  3. Scrap this naff idea entirely, something else

So my question is: What would you do? How would you make a HA controlled smart 5V fan?

Note: It must be 5V. They will be positioned and plugged into existing 5V supplies.

TIA for any help!

Could use this for simple on off control:

Or maybe add a motor control board to an ESP and control motor directly if you really need to adjust the speed

Or add an ESP-01 relay board and connect the relay switch across the button to emulate it

Is it a spring loaded push button to switch mode? If it is, then pressing the button is just making a connection i.e. allowing current to flow across the button to the internal circuitry and that momentary flow of current is switching mode. In a similar way to what Holdestmade suggested with the relay board, you could connect a transistor across the button and have the gate of that transistor controlled by the esp gpio, so you can remotely short out the button, which will simulate it being pressed.

Thank you for the suggestions and pointers.

@Holdestmade The fan defaults to off when power is supplied, so the Sonoff would not be suitable on this occasion. I didn’t realise they even made those, so thanks because I’ve just come up with another use for one :wink: The motor control board might be an option.

@AJStubbsy yes it’s a momentary button that cycles through 4 phases. The fan defaults to off when power is connected then 1 press is low speed, 2nd press is medium, 3rd press is high, finally a 4th press turns it off.

The problem that I have also considered is what to do about being able to monitor the fans current speed. For example: HA thinks the fan is off. It last turned it off so it’s assumed off. Someone comes along and presses the button once. The fan is now in low speed. An automation fires that wants the fan in high speed, so the ESP bridges the button 3 times, now expecting it to be high - but it’s now off.

Maybe the next step would be to disassemble the unit and check if the fan has a PWM wire. If it’s a ‘dumb’ fan with 2 wires and the control board is just adjusting voltage, then I’ll have to take voltage readings on each of the speeds for the ESP to calculate what setting it’s currently on.

The other thing would be if the fan was 2 wire, then the motor control board may actually be the better idea - but I’d need to add a button to allow local control.

I don’t pretend to know too much about any of this, it’s only the 2nd time I’ve even tried tinkering with an ESP, so bear with me! Will post back in a bit.

Right. An update: 2 good news and 2 bad.

The first bad news is that I tried disassembling the fan this evening and it looks like the housing at the back is the same moulded piece of plastic as Most of the fan cage. Looking inside through the blades (after removing the front of the cage, which just pulls off) I could see and remove 2 screws with a very thin driver. It looks like it should just pull out from there, but the only thing you have to pull is the fan itself. Probably super easy to install as you can apply pressure to the front of the fan, but pull it out - not so much as you’re pulling directly on the motor assembly. I gave it a gentle tug, but I think I’m probably going to end up breaking it, I expect it’s either glued in or using clips and it’s been designed to not really come apart. Bummer. :frowning:

However, some minor good news. Contrary to what I thought earlier about the Sonoff USB not being suitable, it looks as if it might be - kind of. If the power button is held down while connecting power, the low speed setting automatically starts. This means that a naff workaround for this model would be to mod the button or tape something on it so it’s always pressed, then use the Sonoff to apply and cut power. Great, getting there.

But second bad news is that the Sonoff only works with their own app! It’s not an ESP8266 so Tasmota or ESP Home aren’t an option, and a quick google didn’t show any other custom firmwares for it. However, I stumbled across the Sinilink XY-WFUSB that is cheaper and can be flashed with Tasmota via serial. Hurrah! :slight_smile: So for now I think I’ll grab a couple of those and tape the button down and use that fan on low speed with the Sinilink. I’m not sure how new the Sinilink is (I didn’t even realise Sonoff made them) but I hope this is of help to someone else pondering the Sonoff but put off by the lack of Tasmota.

Back to the main objective though: smart 5V fan - I guess I’m going to be building my own. Motor controllers were mentioned earlier… is it looking like:

ESP + Motor Controller + 2 wire 5V fan + Self made housing is my best bet now? Any suggestions for fans, housings, controllers would be welcome. :slight_smile:

Not sure if this would work but if you look in the comments it is apparently capable of being used as a dimmer/speed controller

1 Like

Interesting! That looks like it could be exactly what I’m after. I found that on Ali for £3.26 and I also found another desk fan that just has a rocker switch for on/off. It’s only a 3 blade fan though, and the reviews for pretty much any fan I can find that contain a rocker also seem to be a 3 blade and don’t have the usual review buzzwords like “surprisingly powerful” like the unit I already have. A shame I can’t get this one apart because I swear it’s more powerful on setting 2 than my big fan on setting 1, which if you think about it is pretty damn impressive! So I also found this which seems to have those good reviews and whilst it doesn’t have a rocker, it’s got a nice big base that looks as though it’ll come apart easily and the PCB gutted with ease.

I’ll get these bits ordered and post back when I know more, thanks for all the input and help! :ok_hand:

The boards are in the country and should be delivered soon! In the mean time, I have been looking at the board connections and I looked again at the comment:

“If you change GPIO4 to PWM1(37) from Relay1 you will have a dimmer/speed controller”

What does this mean? Is this on the Tasmota config page, where the template would usually populate?

I tried to post a comment on the blog page to ask the OP but my comment never appeared, I guess it’s pending approval.

I saw this on the thingverse link, for the 3D printed case.

In the Tasmota template u can also set the mosfet pin to ‘PWM1 (37)’ instead of using it as a ‘Relay1 (21)’. I use this to dim about 4 meters of 12V LED strip which is working without a problem.

Might be worth contacting the person on thingyverse to see if they have some sort of guide?

Thanks, will do. I didn’t see that because it won’t show comments unless you’re logged in, it seems?!

Boards are here! :slight_smile:

I haven’t had any luck getting in touch with the OPs of those comments, looks like my cheapo generic email is banned from commenting on the blog too :-/ however, I did have a look and after flashing Tasmota via serial (I opted for soldering not pins) it turned out to be straight forward. I used the template that the blog linked to, then pasted it into config other, then in config template you can select PWM from the GPIO drop down. The fan is hooked up and works with varying speed control :slight_smile: As a nice surprise, the button on the board also toggles power. Thank you again to @Holdestmade for suggesting this, it’s an awesome little board!

The only think left to do now is config the pwm. It’s not quite right. When the slider is any less than about 80%, the speed is unusable and I think the top speed is affected too.

Anyone have any idea how I alter the pwm?

Edit:

Looks like it can be done from the console: https://tasmota.github.io/docs/Commands/

Specifically: Pwm, PwmFrequency and PwmRange. It seems like range would be a good starting point. I have absolutely no idea what frequency range to define though, any ideas? I don’t want to set it too high and something go pop.